Skip to content

Commit c640239

Browse files
authored
Preserve TOC opts (#806)
Fixes #804.
1 parent 3616655 commit c640239

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/nextjournal/clerk/parser.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@
479479
(assoc :add-comment-on-line? true)
480480
(update :nodes rest)
481481
(assoc :block-settings next-block-settings)
482-
(assoc-in [:md-context :opts] md-settings)
482+
(update-in [:md-context :opts] merge md-settings)
483483
(update :blocks conj (add-block-id code-block)))
484484
(not (contains? state :ns))
485485
(assoc :ns *ns*)))

test/nextjournal/clerk/parser_test.clj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@ line\""}]
6666
(is (match? '([{:type :text, :text "$1 + $2 = $3"}]
6767
[{:type :formula, :text "1 + "} {:type :text, :text "2 = $3"}]
6868
[{:type :text, :text "$1 + $2 = $3"}])
69-
contents)))))
69+
contents))))
70+
71+
(testing "heading ids are preserved in toc (#804)"
72+
(let [parsed (parser/parse-clojure-string "^:nextjournal.clerk/toc (ns example)
73+
74+
;; # Workload Analysis
75+
76+
;; some text")]
77+
(is (match? {:toc {:children [{:type :toc :attrs {:id "workload-analysis"}}]}}
78+
parsed)))))
7079

7180
(deftest parse-inline-comments
7281
(is (match? {:blocks [{:doc {:content [{:content [{:text "text before"}]}]}}

0 commit comments

Comments
 (0)