-
Notifications
You must be signed in to change notification settings - Fork 294
Expand file tree
/
Copy pathMarkdown.cfc
More file actions
42 lines (38 loc) · 1.4 KB
/
Markdown.cfc
File metadata and controls
42 lines (38 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
component
javaSettings='{
"maven": [
"org.commonmark:commonmark:0.24.0"
, "org.commonmark:commonmark-ext-gfm-strikethrough:0.24.0"
, "org.commonmark:commonmark-ext-gfm-tables:0.24.0"
, "org.commonmark:commonmark-ext-ins:0.24.0"
, "org.commonmark:commonmark-ext-autolink:0.24.0"
, "org.commonmark:commonmark-ext-image-attributes:0.24.0"
]
}'
{
import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
import org.commonmark.Extension;
import org.commonmark.ext.autolink.AutolinkExtension;
import org.commonmark.ext.gfm.strikethrough.StrikethroughExtension;
import org.commonmark.ext.gfm.tables.TablesExtension;
import org.commonmark.ext.image.attributes.ImageAttributesExtension;
import org.commonmark.ext.ins.InsExtension;
function render( string markdown, boolean safemode=false ){
var extensions = [
AutolinkExtension::create(),
ImageAttributesExtension::create(),
InsExtension::create(),
StrikethroughExtension::create(),
TablesExtension::create()
];
var parser = Parser::builder().extensions(extensions).build();
// Parse the markdown to a Node
var document = parser.parse( arguments.markdown);
// Create a HTML renderer
var renderer = HtmlRenderer::builder().extensions(extensions).escapeHtml( arguments.safeMode ).build();
// Render the Node to HTML
return renderer.render(document);
}
}