diff --git a/blog.janet b/blog.janet index e36b899..5767a7c 100644 --- a/blog.janet +++ b/blog.janet @@ -65,29 +65,38 @@ (defn ast-to-html "Convert an AST to html" [ast] + (defn to-codeblock [lang value] (string "
" (htmlspecialchars value) "
")) + (defn to-codeline [value] (string "" (ast-to-html value) "")) + (defn to-heading [level value] (string "" (htmlspecialchars value) "")) + (defn to-quote [value] (string "
" (ast-to-html value) "
")) + (defn to-line [value] (string "

" (ast-to-html value) "

")) + (defn to-italic [value] (string "" (ast-to-html value) "")) + (defn to-bold [value] (string "" (ast-to-html value) "")) + (defn to-stroke [value] (string "" (ast-to-html value) "")) + (string/join (map |(match $0 [:code-block lang value] - (string "
" (htmlspecialchars value) "
") + (to-codeblock lang value) [:heading level value] - (string "" (htmlspecialchars value) "") + (to-heading level value) [:quote value] - (string "
" (ast-to-html value) "
") + (to-quote value) [:hr] "
" [:line value] - (string "

" (ast-to-html value) "

") + (to-line value) [:text value] (htmlspecialchars value) [:italic value] - (string "" (ast-to-html value) "") + (to-italic value) [:stroke value] - (string "" (ast-to-html value) "") + (to-stroke value) [:bold value] - (string "" (ast-to-html value) "") + (to-bold value) [:code-line value] - (string "" (ast-to-html value) "") + (to-codeline value) _ (error (string "Invalid symbol: " (get $0 0)))) ast)