summaryrefslogtreecommitdiffstats
path: root/article-dates.lua
blob: 72bdba5ccabdf070dc174339ea71a5583f6cee9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function Pandoc(doc)
  local heading

  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", '<span class="article-date">' .. date .. "</span>"
      ))
      heading = nil
    else
      heading = nil
    end
  end

  return doc
end