2015-01-16 05:21:33 +08:00
|
|
|
showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
|
2015-01-19 19:37:21 +08:00
|
|
|
'use strict';
|
|
|
|
|
2016-01-02 07:33:33 +08:00
|
|
|
var blockTags = [
|
|
|
|
'pre',
|
|
|
|
'div',
|
|
|
|
'h1',
|
|
|
|
'h2',
|
|
|
|
'h3',
|
|
|
|
'h4',
|
|
|
|
'h5',
|
|
|
|
'h6',
|
|
|
|
'blockquote',
|
|
|
|
'table',
|
|
|
|
'dl',
|
|
|
|
'ol',
|
|
|
|
'ul',
|
|
|
|
'script',
|
|
|
|
'noscript',
|
|
|
|
'form',
|
|
|
|
'fieldset',
|
|
|
|
'iframe',
|
|
|
|
'math',
|
|
|
|
'style',
|
|
|
|
'section',
|
|
|
|
'header',
|
|
|
|
'footer',
|
|
|
|
'nav',
|
|
|
|
'article',
|
|
|
|
'aside',
|
|
|
|
'address',
|
|
|
|
'audio',
|
|
|
|
'canvas',
|
|
|
|
'figure',
|
|
|
|
'hgroup',
|
|
|
|
'output',
|
|
|
|
'video',
|
|
|
|
'p'
|
|
|
|
],
|
|
|
|
repFunc = function (match) {
|
|
|
|
return '\n\n~K' + (globals.gHtmlBlocks.push(match) - 1) + 'K\n\n';
|
|
|
|
};
|
|
|
|
|
|
|
|
for (var i = 0; i < blockTags.length; ++i) {
|
|
|
|
text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^(?: |\\t){0,3}<' + blockTags[i] + '\\b[^>]*>', '</' + blockTags[i] + '>', 'gim');
|
|
|
|
}
|
|
|
|
|
|
|
|
// HR SPECIAL CASE
|
2015-01-19 19:37:21 +08:00
|
|
|
text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,
|
2016-01-02 07:33:33 +08:00
|
|
|
showdown.subParser('hashElement')(text, options, globals));
|
2015-01-19 19:37:21 +08:00
|
|
|
|
|
|
|
// Special case for standalone HTML comments:
|
2016-01-02 07:33:33 +08:00
|
|
|
text = text.replace(/(<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,
|
|
|
|
showdown.subParser('hashElement')(text, options, globals));
|
2015-01-19 19:37:21 +08:00
|
|
|
|
|
|
|
// PHP and ASP-style processor instructions (<?...?> and <%...%>)
|
|
|
|
text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,
|
2016-01-02 07:33:33 +08:00
|
|
|
showdown.subParser('hashElement')(text, options, globals));
|
2015-01-19 19:37:21 +08:00
|
|
|
|
|
|
|
return text;
|
2015-01-16 05:21:33 +08:00
|
|
|
});
|