From d41c7d0e1d864bec20cd917354fe82330d0781d5 Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 9 Feb 2024 21:38:17 +0100 Subject: Removed duplication in svg itself Design is still quite questionable. Main point would be to make them stateful in a non-awkward/hacky way like currently. --- activity.lua | 3 ++- activity/formats/svg.lua | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/activity.lua b/activity.lua index 398d2e8..55cb061 100644 --- a/activity.lua +++ b/activity.lua @@ -33,6 +33,7 @@ function generate_rolling (lookup, format, date) return at.year, dates.day_of_year(at) end + local head = format.start_document"Activity" .. format.start_table() for index, weekday in pairs(weekdays) do rows = rows .. format.start_row() .. format.label(weekday) for week=0,51 do @@ -45,7 +46,7 @@ function generate_rolling (lookup, format, date) end rows = rows .. format.end_row() end - return format.start_document"Activity" .. format.start_table() .. rows .. format.end_table() .. format.end_document() + return head .. rows .. format.end_table() .. format.end_document() end diff --git a/activity/formats/svg.lua b/activity/formats/svg.lua index ab3ab69..f7e2700 100644 --- a/activity/formats/svg.lua +++ b/activity/formats/svg.lua @@ -44,7 +44,7 @@ function svg.end_table () end -local cell_offset = 28 +local cell_offset function svg.start_row () @@ -73,7 +73,7 @@ end function svg.cell (level) local cell = ([[]]):format(level, cell_offset) - cell_offset = cell_offset + 12 + svg.spot() -- Increment cell_offset in one place in code. return cell end -- cgit v1.1