From 351c26fabbd7ad161327f0f9f0a366c276693c29 Mon Sep 17 00:00:00 2001 From: Andrea Amantini Date: Fri, 27 Sep 2024 15:35:22 +0200 Subject: [PATCH] Cleanup deps.edn --- deps.edn | 5 ++--- src/nextjournal/markdown.cljc | 14 +++++++------- test/nextjournal/markdown_test.cljc | 28 ++++++++++++++++++---------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/deps.edn b/deps.edn index 960fc66..21293c2 100644 --- a/deps.edn +++ b/deps.edn @@ -1,7 +1,5 @@ -{:paths ["src" "resources" "classes"] - :mvn/repos {"jitpack.io" {:url "https://jitpack.io"}} +{:paths ["src" "resources"] :deps {applied-science/js-interop {:mvn/version "0.3.3"} - org.clojure/data.json {:mvn/version "2.4.0"} org.commonmark/commonmark {:mvn/version "0.23.0"} org.commonmark/commonmark-ext-autolink {:mvn/version "0.23.0"} org.commonmark/commonmark-ext-footnotes {:mvn/version "0.23.0"} @@ -33,6 +31,7 @@ :dev {:extra-paths ["dev"] :extra-deps {org.babashka/http-client {:mvn/version "0.3.11"} + org.clojure/data.json {:mvn/version "2.4.0"} org.clojure/test.check {:mvn/version "1.1.1"} org.graalvm.js/js {:mvn/version "21.3.2.1"}}} diff --git a/src/nextjournal/markdown.cljc b/src/nextjournal/markdown.cljc index 74bc661..1cf87cc 100644 --- a/src/nextjournal/markdown.cljc +++ b/src/nextjournal/markdown.cljc @@ -11,7 +11,7 @@ "Turns a markdown string into an AST of nested clojure data. Allows to parse multiple strings into the same document e.g. `(-> u/empty-doc (parse* text-1) (parse* text-2))`." - ([markdown-text] (parse* u/empty-doc markdown-text)) + ([markdown-text] (parse* empty-doc markdown-text)) ([ctx markdown-text] (-> ctx (update :text-tokenizers (partial map u/normalize-tokenizer)) @@ -23,16 +23,16 @@ Accept options: - `:text-tokenizers` to customize parsing of text in leaf nodes (see https://nextjournal.github.io/markdown/notebooks/parsing_extensibility). " - ([markdown-text] (parse u/empty-doc markdown-text)) + ([markdown-text] (parse empty-doc markdown-text)) ([ctx markdown-text] (-> (parse* ctx markdown-text) (dissoc :text-tokenizers :text->id+emoji-fn - :nextjournal.markdown.impl/footnote-offset - :nextjournal.markdown.impl/id->index - :nextjournal.markdown.impl/label->footnote-ref - :nextjournal.markdown.impl/path - :nextjournal.markdown.impl/root)))) + ::impl/footnote-offset + ::impl/id->index + ::impl/label->footnote-ref + ::impl/path + ::impl/root)))) (comment (-> u/empty-doc diff --git a/test/nextjournal/markdown_test.cljc b/test/nextjournal/markdown_test.cljc index ff9ceb8..ce89d02 100644 --- a/test/nextjournal/markdown_test.cljc +++ b/test/nextjournal/markdown_test.cljc @@ -11,16 +11,24 @@ #?(:cljs (matcher-combinators.ansi-color/disable!)) (deftest simple-parsing - (is (match? {:type :doc, - :content [{:type :heading - :heading-level 1 - :content [{:type :text, :text "Ahoi"}]} - {:type :bullet-list, - :content [{:type :list-item, :content [{:type :plain, :content [{:type :text, :text "one"}]}]} - {:type :list-item, :content [{:type :plain, :content [{:type :em, :content [{:type :text, :text "nice"}]}]}]} - {:type :list-item, :content [{:type :plain, :content [{:type :text, :text "list"}]}]}]}] - :footnotes []} - (md/parse "# Ahoi + (is (= {:type :doc + :title "Ahoi" + :toc {:type :toc, + :children [{:type :toc, + :heading-level 1, + :content [{:type :text, :text "Ahoi"}], + :attrs {:id "ahoi"}, + :path [:content 0]}]} + :content [{:type :heading + :heading-level 1 + :attrs {:id "ahoi"} + :content [{:type :text, :text "Ahoi"}]} + {:type :bullet-list, + :content [{:type :list-item, :content [{:type :plain, :content [{:type :text, :text "one"}]}]} + {:type :list-item, :content [{:type :plain, :content [{:type :em, :content [{:type :text, :text "nice"}]}]}]} + {:type :list-item, :content [{:type :plain, :content [{:type :text, :text "list"}]}]}]}] + :footnotes []} + (md/parse "# Ahoi * one * _nice_ * list"))))