diff options
author | Ben Sima <ben@bsima.me> | 2020-05-15 12:57:44 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2020-05-15 12:58:13 -0700 |
commit | 25431cd8f97313a64826eff6e794598f09b2490b (patch) | |
tree | 05592132db74b10d4074b0cde25faa02738a99a2 | |
parent | 66f61f0049d8ac056c916bace794d05c073f5707 (diff) |
Process markdown with pandoc before HTML render
-rw-r--r-- | z.scm | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -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) |