From 69f4a7805f79a57732ca0d9c5e000815fe37bb51 Mon Sep 17 00:00:00 2001
From: 3gg <3gg@shellblade.net>
Date: Sat, 28 May 2022 12:05:19 -0700
Subject: Update for the lack of file/popen in new Janet versions.

---
 webgen.janet | 13 ++++++++++---
 1 file 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 @@
   [path]
   (length (string/find-all path/sep path)))
 
+(defn get-output
+  "Execute a command and get its stdout. command-list is an array consisting of
+  the executable to run and its arguments."
+  [command-list]
+  (def p (os/spawn command-list :p {:out :pipe}))
+  (def stdout (:read (p :out) :all))
+  (:wait p)
+  stdout)
+
 (defn markdown-file-to-html
   "Read and convert a markdown file to html. Return an html buffer."
   [path]
-  (def quoted-path (string "\"" path "\""))
-  (with [stdout (file/popen (string "pandoc -f markdown --mathjax " quoted-path) :r)]
-    (file/read stdout :all)))
+  (get-output ["pandoc" "-f" "markdown" "--mathjax" path]))
 
 (defn substitute-variables
   "Perform variable substitution on the given string."
-- 
cgit v1.2.3