Liking cljdoc? Tell your friends :D

cljmd

Clojure implementation of CommonMark.

Installation

Leiningen

Add the following to :dependencies in your project.clj:

[org.clojars.eureton/cljmd "0.1.0"]

Usage

Get an AST:

cljmd.core=> (cljmd.ast/from-string "[_awesome_ stuff](http://example.com)")
{:data {:tag :doc}, :children [{:data {:tag :p}, :children [{:data {:tag :a, :destination "http://example.com"}, :children [{:data {:tag :em}, :children [{:data {:tag :txt, :content "awesome"}}]} {:data {:tag :txt, :content " stuff"}}]}]}]}

Pretty-print it:

cljmd.core=> (pp)
{:data {:tag :doc},
 :children
 [{:data {:tag :p},
   :children
   [{:data {:tag :a, :destination "http://example.com"},
     :children
     [{:data {:tag :em},
       :children [{:data {:tag :txt, :content "awesome"}}]}
      {:data {:tag :txt, :content " stuff"}}]}]}]}

Even better, pretty-print it using the AST printer:

cljmd.core=> (ppp)
<doc>
  <p>
    <a destination="http://example.com">
      <em>awesome</em>
      <txt> stuff</txt>
    </a>
  </p>
</doc>

Get HTML:

cljmd.core=> (cljmd.render/from-string "[_awesome_ stuff](http://example.com)")
"<p><a href=\"http://example.com\"><em>awesome</em> stuff</a></p>\n"

License

MIT License

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close