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
6 changes: 4 additions & 2 deletions src/nextjournal/markdown/impl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@
(defmethod open-node BulletList [ctx ^ListBlock _node]
(u/update-current-loc ctx (fn [loc] (u/zopen-node loc {:type :bullet-list :content [] #_#_:tight? (.isTight node)}))))

(defmethod open-node OrderedList [ctx _node]
(u/update-current-loc ctx (fn [loc] (u/zopen-node loc {:type :numbered-list :content []}))))
(defmethod open-node OrderedList [ctx ^OrderedList node]
(u/update-current-loc ctx (fn [loc] (u/zopen-node loc {:type :numbered-list
:content []
:start (.getStartNumber node)}))))

(defmethod open-node ListItem [ctx _node]
(u/update-current-loc ctx (fn [loc] (u/zopen-node loc {:type :list-item :content []}))))
Expand Down
22 changes: 22 additions & 0 deletions test/nextjournal/markdown_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,28 @@ $$\\int_a^bf(t)dt$$
(md/->hiccup "Please don't inter\\
rupt me when I'm writing."))))

(deftest ordered-list-start-number
(testing "ordered list starting with 1 has start 1"
(is (match? {:type :doc
:content [{:type :numbered-list
:start 1
:content [{:type :list-item}]}]}
(md/parse "1. First item"))))
(testing "ordered list starting with number > 1 has that start number"
(is (match? {:type :doc
:content [{:type :numbered-list
:start 5
:content [{:type :list-item}]}]}
(md/parse "5. Fifth item"))))
(testing "interrupted list preserves start numbers"
(is (match? {:type :doc
:content [{:type :numbered-list
:start 1}
{:type :code}
{:type :numbered-list
:start 2}]}
(md/parse "1. First\n\n```\ncode\n```\n\n2. Second")))))

(deftest set-title-when-missing
(testing "sets title in document structure to the first heading of whatever level"
(is (= "and some title"
Expand Down