Skip to content

Commit

Permalink
Restore n.markdown/parse arity 2
Browse files Browse the repository at this point in the history
  • Loading branch information
zampino committed Sep 27, 2024
1 parent 9f8e8ce commit 0fe5eed
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/nextjournal/markdown.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(def empty-doc u/empty-doc)

(defn parse*
"Turns a markdown string into a nested clojure structure.
"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))
Expand All @@ -18,17 +18,21 @@
(impl/parse markdown-text))))

(defn parse
"Turns a markdown string into a nested clojure structure."
[markdown-text]
(-> u/empty-doc
(parse* 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)))
"Turns a markdown string into an AST of nested clojure data.
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))
([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))))

(comment
(-> u/empty-doc
Expand Down

0 comments on commit 0fe5eed

Please sign in to comment.