diff options
author | 3gg <3gg@shellblade.net> | 2022-05-28 12:05:19 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2022-05-28 12:05:19 -0700 |
commit | 69f4a7805f79a57732ca0d9c5e000815fe37bb51 (patch) | |
tree | b4ef6a7009495573b7d6717262516b972c8cf431 | |
parent | 8c186f6e9145666cbabd5cca0a250d74a1e009d7 (diff) |
Update for the lack of file/popen in new Janet versions.
-rw-r--r-- | webgen.janet | 13 |
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." |