|
@@ -127,6 +127,11 @@ function getDefaultOpts (simple) {
|
|
defaultValue: false,
|
|
defaultValue: false,
|
|
description: 'Open all links in new windows',
|
|
description: 'Open all links in new windows',
|
|
type: 'boolean'
|
|
type: 'boolean'
|
|
|
|
+ },
|
|
|
|
+ backslashEscapesHTMLTags: {
|
|
|
|
+ defaultValue: false,
|
|
|
|
+ description: 'Support for HTML Tag escaping. ex: \<div>foo\</div>',
|
|
|
|
+ type: 'boolean'
|
|
}
|
|
}
|
|
};
|
|
};
|
|
if (simple === false) {
|
|
if (simple === false) {
|
|
@@ -1940,14 +1945,26 @@ showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
|
|
return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
|
|
return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ if (options.backslashEscapesHTMLTags) {
|
|
|
|
+ // encode backslash escaped HTML tags
|
|
|
|
+ text = text.replace(/\\<(\/?[^>]+?)>/g, function (wm, inside) {
|
|
|
|
+ return '<' + inside + '>';
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // hash HTML Blocks
|
|
for (var i = 0; i < blockTags.length; ++i) {
|
|
for (var i = 0; i < blockTags.length; ++i) {
|
|
|
|
|
|
var opTagPos,
|
|
var opTagPos,
|
|
- rgx1 = new RegExp('^ {0,3}<' + blockTags[i] + '\\b[^>]*>', 'im'),
|
|
|
|
|
|
+ rgx1 = new RegExp('^ {0,3}(<' + blockTags[i] + '\\b[^>]*>)', 'im'),
|
|
patLeft = '<' + blockTags[i] + '\\b[^>]*>',
|
|
patLeft = '<' + blockTags[i] + '\\b[^>]*>',
|
|
patRight = '</' + blockTags[i] + '>';
|
|
patRight = '</' + blockTags[i] + '>';
|
|
// 1. Look for the first position of the first opening HTML tag in the text
|
|
// 1. Look for the first position of the first opening HTML tag in the text
|
|
while ((opTagPos = showdown.helper.regexIndexOf(text, rgx1)) !== -1) {
|
|
while ((opTagPos = showdown.helper.regexIndexOf(text, rgx1)) !== -1) {
|
|
|
|
+
|
|
|
|
+ // if the HTML tag is \ escaped, we need to escape it and break
|
|
|
|
+
|
|
|
|
+
|
|
//2. Split the text in that position
|
|
//2. Split the text in that position
|
|
var subTexts = showdown.helper.splitAtIndex(text, opTagPos),
|
|
var subTexts = showdown.helper.splitAtIndex(text, opTagPos),
|
|
//3. Match recursively
|
|
//3. Match recursively
|