robin/maivi
a tiny cute lua web framework
git clone https://git.robinwobin.dev/robin/maivi
1be4c9c
push-srxvuswpkqxx
1local md4c ---@module 'md4c' 2 3do 4local ok 5ok , md4c =pcall ( require , "md4c" ) 6if not ok then 7error (( "could not initialise markdown plugin:\n\t%s" ): format ( md4c )) 8return 9end 10end 11 12local function skip_frontmatter ( str ) 13if string . sub ( str , 0 , 3 ) ~= "+++" then 14return str 15end 16 17local pat ="\n+++" 18local i =string . find ( str , pat ) 19return string . sub ( str , i and i + # pat or 0 ) 20end 21 22maivi . hook ( "read_data" , { pattern ="%.md$" } , function ( ctx ) 23local content =skip_frontmatter ( ctx . content ) 24local ret =md4c . tohtml ( content ) 25ctx : use ( ret ) 26end )