Skip to content

Instantly share code, notes, and snippets.

@osima
Created March 8, 2011 08:39
Show Gist options
  • Select an option

  • Save osima/860037 to your computer and use it in GitHub Desktop.

Select an option

Save osima/860037 to your computer and use it in GitHub Desktop.
convert markdown text to html using clojure
(import (javax.script ScriptEngineManager ScriptEngine))
(defn markdown-to-html [txt]
(let [e (.getEngineByName (ScriptEngineManager.) "JavaScript")]
(.eval e (str
(slurp "showdown.js")
(System/getProperty "line.separator")
"var toHtml = function(mdtext){ return new Showdown.converter().makeHtml(mdtext); }"))
(.invokeFunction e "toHtml" (let [arr (make-array String 1)] (aset arr 0 txt ) arr))))
(print (markdown-to-html "*Hello World!*"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment