Adding Markdown to CFWheels

I needed to do this the other day, so thought I might as well document quite how easy it is! The following was done on Lucee, so if you use ACF your mileage may vary. This uses MarkdownJ, a Java port of Markdown written by Pete Bevin.

Download markdownj.jar (I’ve included a copy here, as it can be a little tricky to track down these days). The attached is zipped, so unzip into your miscellaneous folder, so you have markdownj.jar in there.

In /config/app.cfm, add a mapping to your miscellaneous folder so we can load .jar files easily.

this.javaSettings = {
LoadPaths = ["/miscellaneous"]

In /events/onapplicationstart.cfm, add the createObject call:

application.m = CreateObject( "java", "com.petebevin.markdown.MarkdownProcessor" ).init();

Now, after an application restart, you can just do application.m.markdown(myContent) to parse.