Created
March 28, 2013 12:01
-
-
Save modius/5262626 to your computer and use it in GitHub Desktop.
CFML Markdown using showdown.js
http://stackoverflow.com/questions/4600535/implementating-showdown-js-markdown-parser-on-the-server-side-for-coldfusion
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
<!--- | |
Have files showdown.js and a markdown file in the same directory. | |
---> | |
<cfscript> | |
manager = createObject("java", "javax.script.ScriptEngineManager").init(); | |
jsEngine = manager.getEngineByName("js"); | |
showdownJS = fileRead('#getDirectoryFromPath(getCurrentTemplatePath())#/showdown.js'); | |
jsEngine.eval(showdownJS); | |
showdownConverter = jsEngine.eval("new Showdown.converter()"); | |
markdownString = fileRead("#getDirectoryFromPath(getCurrentTemplatePath())#/markdown.txt"); | |
args = [markdownString]; | |
result = jsEngine.invokeMethod( | |
showdownConverter, | |
"makeHtml", | |
args | |
) & ""; | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment