Created
March 8, 2011 08:39
-
-
Save osima/860037 to your computer and use it in GitHub Desktop.
convert markdown text to html using clojure
This file contains hidden or 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
| (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