From 25431cd8f97313a64826eff6e794598f09b2490b Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 15 May 2020 12:57:44 -0700 Subject: Process markdown with pandoc before HTML render --- z.scm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/z.scm b/z.scm index 745cf4c..73e6dfc 100644 --- a/z.scm +++ b/z.scm @@ -43,6 +43,18 @@ (define (subprocess.call argv) (apply system* argv)) +(import (ice-9 receive)) +(import (only (ice-9 rdelim) read-string)) +(define (pandoc text) + (receive (from to pid) + ((@@ (ice-9 popen) open-process) OPEN_BOTH + "pandoc" "-f" "markdown" "-t" "html") + (display text to) + (close to) + (let ((ret (read-string from))) + (close from) + ret))) + ;; z program (define *zdir* (os.path.expanduser "~/test-z-wiki")) @@ -254,8 +266,13 @@ NL < '\n' [("node" id) (let* ([node (load-node (string->id id))] [txt (or (get-content node) "")]) - (respond `((pre ,txt)) - #:title (fmt "z - ~a" (title node))))] + (respond + `(,(->> txt + pandoc + ;; wrap in article tags so sxml includes all of the content + ((/. s (string.str "
" s "
"))) + xml->sxml)) + #:title (fmt "z - ~a" (title node))))] [("tag") (begin (reindex) -- cgit v1.2.3