Skip to content

Commit

Permalink
Cleanup deps.edn
Browse files Browse the repository at this point in the history
  • Loading branch information
zampino committed Sep 27, 2024
1 parent 0fe5eed commit 351c26f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
5 changes: 2 additions & 3 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -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"}
Expand Down Expand Up @@ -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"}}}

Expand Down
14 changes: 7 additions & 7 deletions src/nextjournal/markdown.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down
28 changes: 18 additions & 10 deletions test/nextjournal/markdown_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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"))))
Expand Down

0 comments on commit 351c26f

Please sign in to comment.