Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
6 changes: 4 additions & 2 deletions src/nextjournal/clerk/parser.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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*)))
Expand Down
22 changes: 21 additions & 1 deletion test/nextjournal/clerk/parser_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]}]}}
Expand Down
Loading