summaryrefslogtreecommitdiff
path: root/z.scm
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-05-15 12:57:44 -0700
committerBen Sima <ben@bsima.me>2020-05-15 12:58:13 -0700
commit25431cd8f97313a64826eff6e794598f09b2490b (patch)
tree05592132db74b10d4074b0cde25faa02738a99a2 /z.scm
parent66f61f0049d8ac056c916bace794d05c073f5707 (diff)
Process markdown with pandoc before HTML render
Diffstat (limited to 'z.scm')
-rw-r--r--z.scm21
1 files 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 "<article>" s "</article>")))
+ xml->sxml))
+ #:title (fmt "z - ~a" (title node))))]
[("tag")
(begin
(reindex)