-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from nextjournal/commonmark-java
This switches the implementation for when using this library from the JVM from markdown-it to commonmark-java. We use generative testing to compare both implementations return the same markup. This comes with an approximate speedup of 10x and fixes #23.
- Loading branch information
Showing
25 changed files
with
1,841 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
((clojure-mode | ||
(cider-clojure-cli-aliases . ":test:repl"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
(ns old-vs-new | ||
(:require [clojure.string :as str] | ||
[nextjournal.markdown.graaljs :as md-old] | ||
[nextjournal.markdown :as md] | ||
[babashka.http-client :as http] | ||
[clojure.test.check :as tc] | ||
[clojure.test.check.generators :as gen] | ||
[clojure.test.check.properties :as prop] | ||
[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"))] | ||
[(with-out-str (time (md-old/parse sample))) | ||
(with-out-str (time (md/parse sample)))])) | ||
|
||
(def feature-keys | ||
(list "no-headers" | ||
"no-code" | ||
"no-quotes" | ||
"no-lists" | ||
"no-inline-markup" | ||
"no-external-links" | ||
"underline-headers" | ||
"underscore-em" | ||
"underscore-strong" | ||
"no-wrapping" | ||
"fenced-code-blocks" | ||
"reference-links")) | ||
|
||
(defn opts->query [opts] | ||
(str/join "&" (keep (fn [[k v]] (when v (str k "=on"))) opts))) | ||
|
||
(defn size+opts->random-md-str [size opts] | ||
(:body (http/get (format "https://jaspervdj.be/lorem-markdownum/markdown.txt?%s&num-blocks=%s" (opts->query opts) size)))) | ||
|
||
(def md-generator | ||
(gen/sized (fn [size] | ||
#_(prn :size size) | ||
(gen/fmap #(size+opts->random-md-str size %) | ||
(gen/fmap (partial zipmap feature-keys) (gen/vector gen/boolean 12)))))) | ||
|
||
#_(gen/sample md-generator) | ||
|
||
(def compare-old-vs-new-parse-implementations | ||
(prop/for-all [s md-generator] | ||
(= (md/parse s) | ||
(md-old/parse s)))) | ||
|
||
#_(tc/quick-check 100 compare-old-vs-new-parse-implementations) | ||
|
||
(defspec test-old-vs-new-implem 100 | ||
compare-old-vs-new-parse-implementations) | ||
|
||
#_(test-old-vs-new-implem) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.