diff --git a/deps.edn b/deps.edn index 330f79f..45327f8 100644 --- a/deps.edn +++ b/deps.edn @@ -3,6 +3,7 @@ :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"} org.commonmark/commonmark-ext-task-list-items {:mvn/version "0.23.0"} org.commonmark/commonmark-ext-gfm-tables {:mvn/version "0.23.0"} diff --git a/dev/old_vs_new.clj b/dev/old_vs_new.clj index 697a4f0..36a1bb9 100644 --- a/dev/old_vs_new.clj +++ b/dev/old_vs_new.clj @@ -9,6 +9,9 @@ [clojure.test.check.clojure-test :refer [defspec]])) (comment + (= (md/parse "https://github.com") + (md-old/parse "https://github.com")) + (:body (http/get "https://jaspervdj.be/lorem-markdownum/markdown.txt?fenced-code-blocks=on")) (let [sample (:body (http/get "https://jaspervdj.be/lorem-markdownum/markdown.txt?num-blocks=1000&fenced-code-blocks=on"))] diff --git a/src/nextjournal/markdown/impl.clj b/src/nextjournal/markdown/impl.clj index e8d079a..37697c8 100644 --- a/src/nextjournal/markdown/impl.clj +++ b/src/nextjournal/markdown/impl.clj @@ -4,11 +4,11 @@ [nextjournal.markdown.impl.types] [nextjournal.markdown.impl.extensions :as extensions] [nextjournal.markdown.utils :as u]) - (:import (org.commonmark.ext.gfm.tables TableBlock TableBody TableRow TableHead TableCell TablesExtension) + (:import (org.commonmark.ext.autolink AutolinkExtension) + (org.commonmark.ext.footnotes FootnotesExtension FootnoteReference FootnoteDefinition InlineFootnote) (org.commonmark.ext.gfm.strikethrough Strikethrough StrikethroughExtension) + (org.commonmark.ext.gfm.tables TableBlock TableBody TableRow TableHead TableCell TablesExtension) (org.commonmark.ext.task.list.items TaskListItemsExtension TaskListItemMarker) - (org.commonmark.parser Parser) - (org.commonmark.ext.footnotes FootnotesExtension FootnoteReference FootnoteDefinition InlineFootnote) (org.commonmark.node Node AbstractVisitor Document BlockQuote @@ -30,6 +30,7 @@ SoftLineBreak HardLineBreak Image) + (org.commonmark.parser Parser) (nextjournal.markdown.impl.types BlockFormula InlineFormula ToC))) (set! *warn-on-reflection* true) @@ -56,6 +57,7 @@ (.. Parser builder (extensions [(extensions/create) + (AutolinkExtension/create) (TaskListItemsExtension/create) (TablesExtension/create) (StrikethroughExtension/create) diff --git a/test/nextjournal/markdown_test.cljc b/test/nextjournal/markdown_test.cljc index 0256a6f..1e984e0 100644 --- a/test/nextjournal/markdown_test.cljc +++ b/test/nextjournal/markdown_test.cljc @@ -43,6 +43,13 @@ $$\\int_a^bf(t)dt$$ [link]:/path/to/something ") +(deftest autolinks + (is (match? {:type :doc + :content [{:type :paragraph + :content [{:type :link + :content [{:type :text, :text "https://clerk.vision"}]}]}]} + (md/parse "https://clerk.vision")))) + (defn parse-internal-links [text] (md/parse* (update u/empty-doc :text-tokenizers conj u/internal-link-tokenizer) text))