From 077ce0571096cf1bee3b3219991088d844de8700 Mon Sep 17 00:00:00 2001 From: Superkooka Date: Wed, 14 Feb 2024 21:07:21 +0100 Subject: [PATCH] write page to stdout Signed-off-by: Superkooka --- blog.janet | 42 +++++++++++++++--------------------- partial-template/footer.html | 13 +++++++++++ partial-template/header.html | 37 +++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 25 deletions(-) create mode 100644 partial-template/footer.html create mode 100644 partial-template/header.html diff --git a/blog.janet b/blog.janet index 5767a7c..afe4502 100644 --- a/blog.janet +++ b/blog.janet @@ -65,11 +65,11 @@ (defn ast-to-html "Convert an AST to html" [ast] - (defn to-codeblock [lang value] (string "
" (htmlspecialchars value) "
")) + (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-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) "")) @@ -77,26 +77,16 @@ (string/join (map |(match $0 - [:code-block lang value] - (to-codeblock lang value) - [:heading level value] - (to-heading level value) - [:quote value] - (to-quote value) - [:hr] - "
" - [:line value] - (to-line value) - [:text value] - (htmlspecialchars value) - [:italic value] - (to-italic value) - [:stroke value] - (to-stroke value) - [:bold value] - (to-bold value) - [:code-line value] - (to-codeline value) + [:code-block lang value] (to-codeblock lang value) + [:heading level value] (to-heading level value) + [:quote value] (to-quote value) + [:hr] "
" + [:line value] (to-line value) + [:text value] (htmlspecialchars value) + [:italic value] (to-italic value) + [:stroke value] (to-stroke value) + [:bold value] (to-bold value) + [:code-line value] (to-codeline value) _ (error (string "Invalid symbol: " (get $0 0)))) ast) @@ -113,4 +103,6 @@ (defn main [bin & args] # (pp-ast (peg/match md-to-ast (read-from-file "raw/~blog/blog.md"))) - (print (ast-to-html (peg/match md-to-ast (read-from-file "raw/~blog/blog.md"))))) + (print (read-from-file "partial-template/header.html")) + (print (ast-to-html (peg/match md-to-ast (read-from-file "raw/~blog/blog.md")))) + (print (read-from-file "partial-template/footer.html"))) diff --git a/partial-template/footer.html b/partial-template/footer.html new file mode 100644 index 0000000..feecd54 --- /dev/null +++ b/partial-template/footer.html @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/partial-template/header.html b/partial-template/header.html new file mode 100644 index 0000000..68463eb --- /dev/null +++ b/partial-template/header.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + + Meow + + + + +