(local cmark (require :cmark)) (local lfs (require :lfs)) (local page-handler {}) (fn page-handler.read-pages [] (each [file (lfs.dir :pages)] (when (and (not= file ".") (not= file "..")) (local markdown (with-open [markdown-file (io.open (.. :pages/ file) :r)] (markdown-file:read :*a))) (local html-template (with-open [html-template-file (io.open :template.html :r)] (html-template-file:read :*a))) (local html (cmark.markdown_to_html markdown (markdown:len) (+ cmark.OPT_HARDBREAKS cmark.OPT_UNSAFE))) (tset _G.files (file:match "(.+)%..+") (html-template:format html))))) page-handler