Turn # Hello, world!
into a Hiccup-esque Clojure data structure [:document {} [:heading {:level 1} "Hello, world!"]]
or into HTML. Uses flexmark-java under the hood to parse and render.
Warning
|
Pre-alpha Library
The public facing API can (and will) change. Do not use for serious projects. |
There are no releases yet. Depend on the git
coordinates directly.
deps.edn
{:deps
{com.github.hindol/flexmark-clj
{:git/url "https://github.com/hindol/flexmark-clj"
:sha "79d00514254a086bcd6d174b41c6d5b49790579c"}}} ;; (1)
-
The latest commit hash from
master
branch.
The API consists of three functions.
(defn markdown->tree
"Parses a Markdown string into a tree of Flexmark nodes."
[markdown]
...)
(defn tree->marccup
"Walks the tree of Flexmark nodes, returns a Hiccup-esque Clojure array."
[parsed]
...)
(defn tree->html
"Takes in a tree of Flexmark nodes, returns the rendered HTML in a string."
[parsed]
...)
main.clj
(with-open [reader (io/reader "./resources/API-Methods.md") ;; (1)
writer (io/writer "./resources/API-Methods.html") ;; (2)
edn (io/writer "./resources/API-Methods.edn")] ;; (3)
(let [markdown (->> reader line-seq (str/join "\n"))
tree (markdown->tree markdown)
marccup (tree->marccup tree) ;; (4)
html (tree->html tree)]
(pp/pprint marccup edn)
(.write writer html)))
-
See: API-Methods.md
-
See: API-Methods.html
-
See: API-Methods.edn
-
Marccup = Hiccup-esque Markdown