yum-slop/yummers.dev
source code for https://yummers.dev
git clone https://git.yummers.dev/yum-slop/yummers.dev
de3687b
master
1local function parse_inlines ( text ) 2return pandoc . read ( text , "markdown" ). blocks [ 1 ]. content 3end 4 5function Pandoc ( doc ) 6local articles =pandoc . List () 7local blocks =pandoc . Blocks ( {} ) 8 9for _ , block in ipairs ( doc . blocks ) do 10if block . t == "Header" and block . level == 1 then 11local date =block . attributes [ "data-date" ] 12if not date or date == "" then 13error ( "article is missing data-date: " .. pandoc . utils . stringify ( block . content )) 14end 15 16block . attributes [ "data-date" ] =nil 17 18local label =pandoc . Inlines ( block . content ) 19label : insert ( pandoc . Span ( parse_inlines ( date ), { class ="article-date" } )) 20articles : insert ( { pandoc . Plain ( { pandoc . Link ( label , block . identifier .. ".html" ) } ) } ) 21 22blocks : insert ( block ) 23blocks : insert ( pandoc . Para ( parse_inlines ( date ))) 24else 25blocks : insert ( block ) 26end 27end 28 29doc . blocks =blocks 30doc . meta [ "article-list" ] =pandoc . MetaBlocks ( { pandoc . BulletList ( articles ) } ) 31return doc 32end