diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5007e83aa..3b988b0c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -144,6 +144,9 @@ jobs: - name: 🧪 Run tests shell: bash run: | + # # temporarily using dev build because of https://github.com/babashka/sci/issues/1011 + # bash <(curl https://raw.githubusercontent.com/babashka/babashka/master/install) --dev-build --dir /tmp + # /tmp/bb test:bb bb test:bb static-build: diff --git a/deps.edn b/deps.edn index e11696341..b02b1757f 100644 --- a/deps.edn +++ b/deps.edn @@ -7,7 +7,7 @@ weavejester/dependency {:mvn/version "0.2.1"} com.nextjournal/beholder {:mvn/version "1.0.3"} org.flatland/ordered {:mvn/version "1.15.12"} - io.github.nextjournal/markdown {:mvn/version "0.7.189"} + io.github.nextjournal/markdown {:mvn/version "0.7.222"} babashka/process {:mvn/version "0.4.16"} io.github.nextjournal/dejavu {:git/sha "7276cd9cec1bad001d595b52cee9e83a60d43bf0"} io.github.babashka/sci.nrepl {:mvn/version "0.0.2"} diff --git a/src/nextjournal/clerk/parser.cljc b/src/nextjournal/clerk/parser.cljc index bdf337f53..750615d05 100644 --- a/src/nextjournal/clerk/parser.cljc +++ b/src/nextjournal/clerk/parser.cljc @@ -93,7 +93,8 @@ :nextjournal.clerk/page-size :nextjournal.clerk/render-evaluator :nextjournal.clerk/visibility - :nextjournal.clerk/width}) + :nextjournal.clerk/width + :nextjournal.clerk/markdown}) (defn settings-marker? [form] (boolean (and (map? form) @@ -435,7 +436,6 @@ ([{:as opts :keys [skip-doc?]} initial-state s] (binding [*ns* (:ns initial-state *ns*)] (loop [{:as state :keys [nodes blocks block-settings add-comment-on-line? add-block-id]} - (assoc initial-state :nodes (:children (try (p/parse-string-all s) (catch Exception e @@ -467,6 +467,7 @@ {:nextjournal.clerk/visibility {:code :show :result :show}} (parse-global-block-settings form))) (parse-global-block-settings form)) + md-settings (:nextjournal.clerk/markdown next-block-settings) code-block {:type :code :settings (merge-settings next-block-settings (parse-local-block-settings form)) :text nstring @@ -478,6 +479,7 @@ (assoc :add-comment-on-line? true) (update :nodes rest) (assoc :block-settings next-block-settings) + (assoc-in [:md-context :opts] md-settings) (update :blocks conj (add-block-id code-block))) (not (contains? state :ns)) (assoc :ns *ns*))) diff --git a/test/nextjournal/clerk/parser_test.clj b/test/nextjournal/clerk/parser_test.clj index d7a5a2d9b..a69e8ddda 100644 --- a/test/nextjournal/clerk/parser_test.clj +++ b/test/nextjournal/clerk/parser_test.clj @@ -46,7 +46,27 @@ line\""}] (testing "reading a bad block shows block and file info in raised exception" (is (thrown-match? clojure.lang.ExceptionInfo {:file string?} - (parser/parse-clojure-string {:doc? true :file "foo.clj"} "##boom"))))) + (parser/parse-clojure-string {:doc? true :file "foo.clj"} "##boom")))) + (testing "markdown settings" + (let [parsed (parser/parse-clojure-string "(ns scratch + {:nextjournal.clerk/markdown {:disable-inline-formulas true}} + (:require [nextjournal.clerk :as clerk])) + +;; $1 + $2 = $3 + +{:nextjournal.clerk/markdown {:disable-inline-formulas false}} + +;; $1 + $2 = $3 + +{:nextjournal.clerk/markdown {:disable-inline-formulas true}} + +;; $1 + $2 = $3") + blocks (take-nth 2 (rest (:blocks parsed))) + contents (map #(-> % :doc :content first :content) blocks)] + (is (match? '([{:type :text, :text "$1 + $2 = $3"}] + [{:type :formula, :text "1 + "} {:type :text, :text "2 = $3"}] + [{:type :text, :text "$1 + $2 = $3"}]) + contents))))) (deftest parse-inline-comments (is (match? {:blocks [{:doc {:content [{:content [{:text "text before"}]}]}}