aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--webgen.janet13
1 files changed, 10 insertions, 3 deletions
diff --git a/webgen.janet b/webgen.janet
index 922dba0..119c1d6 100644
--- a/webgen.janet
+++ b/webgen.janet
@@ -20,12 +20,19 @@
20 [path] 20 [path]
21 (length (string/find-all path/sep path))) 21 (length (string/find-all path/sep path)))
22 22
23(defn get-output
24 "Execute a command and get its stdout. command-list is an array consisting of
25 the executable to run and its arguments."
26 [command-list]
27 (def p (os/spawn command-list :p {:out :pipe}))
28 (def stdout (:read (p :out) :all))
29 (:wait p)
30 stdout)
31
23(defn markdown-file-to-html 32(defn markdown-file-to-html
24 "Read and convert a markdown file to html. Return an html buffer." 33 "Read and convert a markdown file to html. Return an html buffer."
25 [path] 34 [path]
26 (def quoted-path (string "\"" path "\"")) 35 (get-output ["pandoc" "-f" "markdown" "--mathjax" path]))
27 (with [stdout (file/popen (string "pandoc -f markdown --mathjax " quoted-path) :r)]
28 (file/read stdout :all)))
29 36
30(defn substitute-variables 37(defn substitute-variables
31 "Perform variable substitution on the given string." 38 "Perform variable substitution on the given string."