Last active
December 15, 2015 12:49
-
-
Save modius/5262609 to your computer and use it in GitHub Desktop.
CFML Example of PEGDOWN (https://github.com/sirthias/pegdown)
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
<!--- Load some demo markdown content ---> | |
<cfset markdownString = fileRead("#getDirectoryFromPath(getCurrentTemplatePath())#/demo.txt")> | |
<!--- Directory containing all the necessary jar files. ---> | |
<cfset jarDir = "#getDirectoryFromPath(getCurrentTemplatePath())#pegdown" /> | |
<!--- Array of necessary classes ---> | |
<cfset jClass = [ | |
"#jarDir#/parboiled-java-1.1.3.jar" | |
, "#jarDir#/asm-all-4.1.jar" | |
, "#jarDir#/parboiled-core-1.1.3.jar" | |
, "#jarDir#/pegdown-1.2.1.jar" | |
] /> | |
<cfset javaloader = createObject('component','components.javaloader.JavaLoader').init(jClass, false) /> | |
<!--- Hex values for different extensions can be found in org.pegdown.Extensions.java (0x20 is for tables support) ---> | |
<cfset variables.pegdown = javaloader.create("org.pegdown.PegDownProcessor").init(javaCast("int", InputBaseN("0x20", 16))) /> | |
<!--- Output the HTML conversion ---> | |
<cfoutput>#variables.pegdown.markdownToHtml(markdownString)#</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment