From de3687b4b53cfbe0188309e3ea41de31ec769c92 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 28 Jul 2026 15:40:18 -0700 Subject: redo date parsing stuff; add about section to homepage --- article-dates.lua | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'article-dates.lua') diff --git a/article-dates.lua b/article-dates.lua index 72bdba5..df4e2a0 100644 --- a/article-dates.lua +++ b/article-dates.lua @@ -1,19 +1,32 @@ +local function parse_inlines(text) + return pandoc.read(text, "markdown").blocks[1].content +end + function Pandoc(doc) - local heading + local articles = pandoc.List() + local blocks = pandoc.Blocks({}) for _, block in ipairs(doc.blocks) do if block.t == "Header" and block.level == 1 then - heading = block - elseif heading and block.t == "Para" then - local date = pandoc.utils.stringify(block.content) - table.insert(heading.content, pandoc.RawInline( - "html", '' .. date .. "" - )) - heading = nil + local date = block.attributes["data-date"] + if not date or date == "" then + error("article is missing data-date: " .. pandoc.utils.stringify(block.content)) + end + + block.attributes["data-date"] = nil + + local label = pandoc.Inlines(block.content) + label:insert(pandoc.Span(parse_inlines(date), {class = "article-date"})) + articles:insert({pandoc.Plain({pandoc.Link(label, block.identifier .. ".html")})}) + + blocks:insert(block) + blocks:insert(pandoc.Para(parse_inlines(date))) else - heading = nil + blocks:insert(block) end end + doc.blocks = blocks + doc.meta["article-list"] = pandoc.MetaBlocks({pandoc.BulletList(articles)}) return doc end -- cgit v1.2.3