From 762324d9f06f958e0887d1a2af324b3a50ddf5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madeleine=20Sydney=20=C5=9Alaga?= Date: Mon, 2 Mar 2026 14:05:39 -0700 Subject: [PATCH] fix: config spec --- doerg/src/net/deertopia/doerg/config.clj | 26 ++++++++++++++++-------- doerg/src/net/deertopia/doerg/repl.clj | 7 +++++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/doerg/src/net/deertopia/doerg/config.clj b/doerg/src/net/deertopia/doerg/config.clj index 628c1a7..3b1c374 100644 --- a/doerg/src/net/deertopia/doerg/config.clj +++ b/doerg/src/net/deertopia/doerg/config.clj @@ -6,30 +6,38 @@ (s/def ::config (s/keys :req [::ibm-plex-web ::latex - ::dvisvgm])) + ::dvisvgm + ::doerg-temml-worker + ::doerg-parser])) (s/def ::file #(or (instance? java.io.File %) (string? %))) +(s/def ::executable #(or (fs/executable? %) + (and (fs/relative? %) + (fs/which %)))) + (def default {::ibm-plex-web - (or (System/getenv "DOERG_IBM_PLEX_WEB") - (fs/file (some #(let [x (fs/path % "ibm-plex-web")] - (and (fs/exists? x) x)) - (fs/split-paths (System/getenv "XDG_DATA_DIRS"))))) + (fs/file (some #(let [x (fs/path % "ibm-plex-web")] + (and (fs/exists? x) x)) + (fs/split-paths (System/getenv "XDG_DATA_DIRS")))) ::latex "xelatex" ::dvisvgm "dvisvgm" ;; TODO: Can we automatically set this to "./doerg-temml-worker/index.js" in ;; a development environment? - ::doerg-temml-worker "doerg-temml-worker"}) + ::doerg-temml-worker "doerg-temml-worker" + ::doerg-parser "doerg-parser"}) (def ^:dynamic *cfg* default) (s/def ::ibm-plex-web ::file) -(s/def ::latex ::file) +(s/def ::latex ::executable) -(s/def ::dvisvgm ::file) +(s/def ::dvisvgm ::executable) -(s/def ::doerg-temml-worker ::file) +(s/def ::doerg-temml-worker ::executable) + +(s/def ::doerg-parser ::executable) diff --git a/doerg/src/net/deertopia/doerg/repl.clj b/doerg/src/net/deertopia/doerg/repl.clj index f2313cf..956fbc5 100644 --- a/doerg/src/net/deertopia/doerg/repl.clj +++ b/doerg/src/net/deertopia/doerg/repl.clj @@ -24,6 +24,13 @@ (fs/delete-if-exists path) (fs/create-sym-link path target)) +(defn reconfigure-doerg! [] + (alter-var-root + #'cfg/*cfg* + #(assoc % + ::cfg/doerg-temml-worker "./doerg-temml-worker/index.js" + ::cfg/doerg-parser "./doerg-parser/index.js"))) + (defn render-html [& {:keys [src dest] :or {src some-org-file dest "/tmp/doerg-test"}}]