From 0f73e870392c709194feb848ffc1b92a9fbdc688 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 1 Nov 2011 11:08:11 +0100 Subject: [PATCH] Support inline HTML As per http://daringfireball.net/projects/markdown/syntax#html The __RAW extension to jsonml is a bit ugly. Feel free to suggest a better approach. --- lib/markdown.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/markdown.js b/lib/markdown.js index da5d29cc..e915e6ee 100644 --- a/lib/markdown.js +++ b/lib/markdown.js @@ -287,6 +287,11 @@ Markdown.dialects = {}; **/ Markdown.dialects.Gruber = { block: { + htmlBlock: function htmlBlock( block, next ) { + if ( block.match( /^\s*<\w/ ) && block.match( /<\/\s*\w+\s*>\s*$/ ) ) + return [["__RAW", block.toString()]]; + }, + atxHeader: function atxHeader( block, next ) { var m = block.match( /^(#{1,6})\s*(.*?)\s*#*\s*(?:\n|$)/ ); @@ -1293,6 +1298,9 @@ function render_tree( jsonml ) { if ( typeof jsonml === "string" ) { return escapeHTML( jsonml ); } + if ( jsonml[0] == "__RAW" ) { + return jsonml[1]; + } var tag = jsonml.shift(), attributes = {},