grgr.me

latest commits to https://grgr.me/
Log | Files | Refs

toc.lua (429B)


      1 sections = {}
      2 
      3 function collect(header)
      4   if header.level == 2 then
      5     section = {}
      6     link = pandoc.Link(header.content, "#" .. header.identifier)
      7     table.insert(section, link)
      8     table.insert(sections, pandoc.Plain(section))
      9   end
     10 end
     11 
     12 function replace(el)
     13   if el.identifier == "toc" then
     14     toc = pandoc.BulletList(sections)
     15     return toc
     16   else
     17     return el
     18   end
     19 end
     20 
     21 return {{Header = collect}, {Block = replace}}