local stringx = require "pl.stringx"
local svg = {}
function svg.start_document (title)
return stringx.dedent[==[
\n"
end
local row_offset = 0 -- Format(s) should be stateful and instantiable.
function svg.start_table ()
row_offset = 0
return ""
end
function svg.end_table ()
return ""
end
local cell_offset
function svg.start_row ()
local row = ([[]]):format(row_offset)
cell_offset = 28
row_offset = row_offset + 14
return row
end
function svg.end_row ()
return "\n"
end
function svg.label (name)
return ([[%s]]):format(name)
end
function svg.spot ()
cell_offset = cell_offset + 12
return ""
end
function svg.cell (level)
local cell = ([[]]):format(level, cell_offset)
svg.spot() -- Increment cell_offset in one place in code.
return cell
end
return svg