Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: blocks.js
// attacklab: hack around Konqueror 3.5.4 bug:
[10500] Fix | Delete
// "----------bug".replace(/^-/g,"") == "bug"
[10501] Fix | Delete
bq = bq.replace(/^[ \t]*>[ \t]?/gm, ''); // trim one level of quoting
[10502] Fix | Delete
[10503] Fix | Delete
// attacklab: clean up hack
[10504] Fix | Delete
bq = bq.replace(/¨0/g, '');
[10505] Fix | Delete
[10506] Fix | Delete
bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines
[10507] Fix | Delete
bq = showdown.subParser('githubCodeBlocks')(bq, options, globals);
[10508] Fix | Delete
bq = showdown.subParser('blockGamut')(bq, options, globals); // recurse
[10509] Fix | Delete
[10510] Fix | Delete
bq = bq.replace(/(^|\n)/g, '$1 ');
[10511] Fix | Delete
// These leading spaces screw with <pre> content, so we need to fix that:
[10512] Fix | Delete
bq = bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm, function (wholeMatch, m1) {
[10513] Fix | Delete
var pre = m1;
[10514] Fix | Delete
// attacklab: hack around Konqueror 3.5.4 bug:
[10515] Fix | Delete
pre = pre.replace(/^ /mg, '¨0');
[10516] Fix | Delete
pre = pre.replace(/¨0/g, '');
[10517] Fix | Delete
return pre;
[10518] Fix | Delete
});
[10519] Fix | Delete
[10520] Fix | Delete
return showdown.subParser('hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals);
[10521] Fix | Delete
});
[10522] Fix | Delete
[10523] Fix | Delete
text = globals.converter._dispatch('blockQuotes.after', text, options, globals);
[10524] Fix | Delete
return text;
[10525] Fix | Delete
});
[10526] Fix | Delete
[10527] Fix | Delete
/**
[10528] Fix | Delete
* Process Markdown `<pre><code>` blocks.
[10529] Fix | Delete
*/
[10530] Fix | Delete
showdown.subParser('codeBlocks', function (text, options, globals) {
[10531] Fix | Delete
'use strict';
[10532] Fix | Delete
[10533] Fix | Delete
text = globals.converter._dispatch('codeBlocks.before', text, options, globals);
[10534] Fix | Delete
[10535] Fix | Delete
// sentinel workarounds for lack of \A and \Z, safari\khtml bug
[10536] Fix | Delete
text += '¨0';
[10537] Fix | Delete
[10538] Fix | Delete
var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=¨0))/g;
[10539] Fix | Delete
text = text.replace(pattern, function (wholeMatch, m1, m2) {
[10540] Fix | Delete
var codeblock = m1,
[10541] Fix | Delete
nextChar = m2,
[10542] Fix | Delete
end = '\n';
[10543] Fix | Delete
[10544] Fix | Delete
codeblock = showdown.subParser('outdent')(codeblock, options, globals);
[10545] Fix | Delete
codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
[10546] Fix | Delete
codeblock = showdown.subParser('detab')(codeblock, options, globals);
[10547] Fix | Delete
codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
[10548] Fix | Delete
codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines
[10549] Fix | Delete
[10550] Fix | Delete
if (options.omitExtraWLInCodeBlocks) {
[10551] Fix | Delete
end = '';
[10552] Fix | Delete
}
[10553] Fix | Delete
[10554] Fix | Delete
codeblock = '<pre><code>' + codeblock + end + '</code></pre>';
[10555] Fix | Delete
[10556] Fix | Delete
return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
[10557] Fix | Delete
});
[10558] Fix | Delete
[10559] Fix | Delete
// strip sentinel
[10560] Fix | Delete
text = text.replace(/¨0/, '');
[10561] Fix | Delete
[10562] Fix | Delete
text = globals.converter._dispatch('codeBlocks.after', text, options, globals);
[10563] Fix | Delete
return text;
[10564] Fix | Delete
});
[10565] Fix | Delete
[10566] Fix | Delete
/**
[10567] Fix | Delete
*
[10568] Fix | Delete
* * Backtick quotes are used for <code></code> spans.
[10569] Fix | Delete
*
[10570] Fix | Delete
* * You can use multiple backticks as the delimiters if you want to
[10571] Fix | Delete
* include literal backticks in the code span. So, this input:
[10572] Fix | Delete
*
[10573] Fix | Delete
* Just type ``foo `bar` baz`` at the prompt.
[10574] Fix | Delete
*
[10575] Fix | Delete
* Will translate to:
[10576] Fix | Delete
*
[10577] Fix | Delete
* <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
[10578] Fix | Delete
*
[10579] Fix | Delete
* There's no arbitrary limit to the number of backticks you
[10580] Fix | Delete
* can use as delimters. If you need three consecutive backticks
[10581] Fix | Delete
* in your code, use four for delimiters, etc.
[10582] Fix | Delete
*
[10583] Fix | Delete
* * You can use spaces to get literal backticks at the edges:
[10584] Fix | Delete
*
[10585] Fix | Delete
* ... type `` `bar` `` ...
[10586] Fix | Delete
*
[10587] Fix | Delete
* Turns to:
[10588] Fix | Delete
*
[10589] Fix | Delete
* ... type <code>`bar`</code> ...
[10590] Fix | Delete
*/
[10591] Fix | Delete
showdown.subParser('codeSpans', function (text, options, globals) {
[10592] Fix | Delete
'use strict';
[10593] Fix | Delete
[10594] Fix | Delete
text = globals.converter._dispatch('codeSpans.before', text, options, globals);
[10595] Fix | Delete
[10596] Fix | Delete
if (typeof text === 'undefined') {
[10597] Fix | Delete
text = '';
[10598] Fix | Delete
}
[10599] Fix | Delete
text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
[10600] Fix | Delete
function (wholeMatch, m1, m2, m3) {
[10601] Fix | Delete
var c = m3;
[10602] Fix | Delete
c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
[10603] Fix | Delete
c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
[10604] Fix | Delete
c = showdown.subParser('encodeCode')(c, options, globals);
[10605] Fix | Delete
c = m1 + '<code>' + c + '</code>';
[10606] Fix | Delete
c = showdown.subParser('hashHTMLSpans')(c, options, globals);
[10607] Fix | Delete
return c;
[10608] Fix | Delete
}
[10609] Fix | Delete
);
[10610] Fix | Delete
[10611] Fix | Delete
text = globals.converter._dispatch('codeSpans.after', text, options, globals);
[10612] Fix | Delete
return text;
[10613] Fix | Delete
});
[10614] Fix | Delete
[10615] Fix | Delete
/**
[10616] Fix | Delete
* Create a full HTML document from the processed markdown
[10617] Fix | Delete
*/
[10618] Fix | Delete
showdown.subParser('completeHTMLDocument', function (text, options, globals) {
[10619] Fix | Delete
'use strict';
[10620] Fix | Delete
[10621] Fix | Delete
if (!options.completeHTMLDocument) {
[10622] Fix | Delete
return text;
[10623] Fix | Delete
}
[10624] Fix | Delete
[10625] Fix | Delete
text = globals.converter._dispatch('completeHTMLDocument.before', text, options, globals);
[10626] Fix | Delete
[10627] Fix | Delete
var doctype = 'html',
[10628] Fix | Delete
doctypeParsed = '<!DOCTYPE HTML>\n',
[10629] Fix | Delete
title = '',
[10630] Fix | Delete
charset = '<meta charset="utf-8">\n',
[10631] Fix | Delete
lang = '',
[10632] Fix | Delete
metadata = '';
[10633] Fix | Delete
[10634] Fix | Delete
if (typeof globals.metadata.parsed.doctype !== 'undefined') {
[10635] Fix | Delete
doctypeParsed = '<!DOCTYPE ' + globals.metadata.parsed.doctype + '>\n';
[10636] Fix | Delete
doctype = globals.metadata.parsed.doctype.toString().toLowerCase();
[10637] Fix | Delete
if (doctype === 'html' || doctype === 'html5') {
[10638] Fix | Delete
charset = '<meta charset="utf-8">';
[10639] Fix | Delete
}
[10640] Fix | Delete
}
[10641] Fix | Delete
[10642] Fix | Delete
for (var meta in globals.metadata.parsed) {
[10643] Fix | Delete
if (globals.metadata.parsed.hasOwnProperty(meta)) {
[10644] Fix | Delete
switch (meta.toLowerCase()) {
[10645] Fix | Delete
case 'doctype':
[10646] Fix | Delete
break;
[10647] Fix | Delete
[10648] Fix | Delete
case 'title':
[10649] Fix | Delete
title = '<title>' + globals.metadata.parsed.title + '</title>\n';
[10650] Fix | Delete
break;
[10651] Fix | Delete
[10652] Fix | Delete
case 'charset':
[10653] Fix | Delete
if (doctype === 'html' || doctype === 'html5') {
[10654] Fix | Delete
charset = '<meta charset="' + globals.metadata.parsed.charset + '">\n';
[10655] Fix | Delete
} else {
[10656] Fix | Delete
charset = '<meta name="charset" content="' + globals.metadata.parsed.charset + '">\n';
[10657] Fix | Delete
}
[10658] Fix | Delete
break;
[10659] Fix | Delete
[10660] Fix | Delete
case 'language':
[10661] Fix | Delete
case 'lang':
[10662] Fix | Delete
lang = ' lang="' + globals.metadata.parsed[meta] + '"';
[10663] Fix | Delete
metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n';
[10664] Fix | Delete
break;
[10665] Fix | Delete
[10666] Fix | Delete
default:
[10667] Fix | Delete
metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n';
[10668] Fix | Delete
}
[10669] Fix | Delete
}
[10670] Fix | Delete
}
[10671] Fix | Delete
[10672] Fix | Delete
text = doctypeParsed + '<html' + lang + '>\n<head>\n' + title + charset + metadata + '</head>\n<body>\n' + text.trim() + '\n</body>\n</html>';
[10673] Fix | Delete
[10674] Fix | Delete
text = globals.converter._dispatch('completeHTMLDocument.after', text, options, globals);
[10675] Fix | Delete
return text;
[10676] Fix | Delete
});
[10677] Fix | Delete
[10678] Fix | Delete
/**
[10679] Fix | Delete
* Convert all tabs to spaces
[10680] Fix | Delete
*/
[10681] Fix | Delete
showdown.subParser('detab', function (text, options, globals) {
[10682] Fix | Delete
'use strict';
[10683] Fix | Delete
text = globals.converter._dispatch('detab.before', text, options, globals);
[10684] Fix | Delete
[10685] Fix | Delete
// expand first n-1 tabs
[10686] Fix | Delete
text = text.replace(/\t(?=\t)/g, ' '); // g_tab_width
[10687] Fix | Delete
[10688] Fix | Delete
// replace the nth with two sentinels
[10689] Fix | Delete
text = text.replace(/\t/g, '¨A¨B');
[10690] Fix | Delete
[10691] Fix | Delete
// use the sentinel to anchor our regex so it doesn't explode
[10692] Fix | Delete
text = text.replace(/¨B(.+?)¨A/g, function (wholeMatch, m1) {
[10693] Fix | Delete
var leadingText = m1,
[10694] Fix | Delete
numSpaces = 4 - leadingText.length % 4; // g_tab_width
[10695] Fix | Delete
[10696] Fix | Delete
// there *must* be a better way to do this:
[10697] Fix | Delete
for (var i = 0; i < numSpaces; i++) {
[10698] Fix | Delete
leadingText += ' ';
[10699] Fix | Delete
}
[10700] Fix | Delete
[10701] Fix | Delete
return leadingText;
[10702] Fix | Delete
});
[10703] Fix | Delete
[10704] Fix | Delete
// clean up sentinels
[10705] Fix | Delete
text = text.replace(/¨A/g, ' '); // g_tab_width
[10706] Fix | Delete
text = text.replace(/¨B/g, '');
[10707] Fix | Delete
[10708] Fix | Delete
text = globals.converter._dispatch('detab.after', text, options, globals);
[10709] Fix | Delete
return text;
[10710] Fix | Delete
});
[10711] Fix | Delete
[10712] Fix | Delete
showdown.subParser('ellipsis', function (text, options, globals) {
[10713] Fix | Delete
'use strict';
[10714] Fix | Delete
[10715] Fix | Delete
text = globals.converter._dispatch('ellipsis.before', text, options, globals);
[10716] Fix | Delete
[10717] Fix | Delete
text = text.replace(/\.\.\./g, '…');
[10718] Fix | Delete
[10719] Fix | Delete
text = globals.converter._dispatch('ellipsis.after', text, options, globals);
[10720] Fix | Delete
[10721] Fix | Delete
return text;
[10722] Fix | Delete
});
[10723] Fix | Delete
[10724] Fix | Delete
/**
[10725] Fix | Delete
* Turn emoji codes into emojis
[10726] Fix | Delete
*
[10727] Fix | Delete
* List of supported emojis: https://github.com/showdownjs/showdown/wiki/Emojis
[10728] Fix | Delete
*/
[10729] Fix | Delete
showdown.subParser('emoji', function (text, options, globals) {
[10730] Fix | Delete
'use strict';
[10731] Fix | Delete
[10732] Fix | Delete
if (!options.emoji) {
[10733] Fix | Delete
return text;
[10734] Fix | Delete
}
[10735] Fix | Delete
[10736] Fix | Delete
text = globals.converter._dispatch('emoji.before', text, options, globals);
[10737] Fix | Delete
[10738] Fix | Delete
var emojiRgx = /:([\S]+?):/g;
[10739] Fix | Delete
[10740] Fix | Delete
text = text.replace(emojiRgx, function (wm, emojiCode) {
[10741] Fix | Delete
if (showdown.helper.emojis.hasOwnProperty(emojiCode)) {
[10742] Fix | Delete
return showdown.helper.emojis[emojiCode];
[10743] Fix | Delete
}
[10744] Fix | Delete
return wm;
[10745] Fix | Delete
});
[10746] Fix | Delete
[10747] Fix | Delete
text = globals.converter._dispatch('emoji.after', text, options, globals);
[10748] Fix | Delete
[10749] Fix | Delete
return text;
[10750] Fix | Delete
});
[10751] Fix | Delete
[10752] Fix | Delete
/**
[10753] Fix | Delete
* Smart processing for ampersands and angle brackets that need to be encoded.
[10754] Fix | Delete
*/
[10755] Fix | Delete
showdown.subParser('encodeAmpsAndAngles', function (text, options, globals) {
[10756] Fix | Delete
'use strict';
[10757] Fix | Delete
text = globals.converter._dispatch('encodeAmpsAndAngles.before', text, options, globals);
[10758] Fix | Delete
[10759] Fix | Delete
// Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
[10760] Fix | Delete
// http://bumppo.net/projects/amputator/
[10761] Fix | Delete
text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, '&amp;');
[10762] Fix | Delete
[10763] Fix | Delete
// Encode naked <'s
[10764] Fix | Delete
text = text.replace(/<(?![a-z\/?$!])/gi, '&lt;');
[10765] Fix | Delete
[10766] Fix | Delete
// Encode <
[10767] Fix | Delete
text = text.replace(/</g, '&lt;');
[10768] Fix | Delete
[10769] Fix | Delete
// Encode >
[10770] Fix | Delete
text = text.replace(/>/g, '&gt;');
[10771] Fix | Delete
[10772] Fix | Delete
text = globals.converter._dispatch('encodeAmpsAndAngles.after', text, options, globals);
[10773] Fix | Delete
return text;
[10774] Fix | Delete
});
[10775] Fix | Delete
[10776] Fix | Delete
/**
[10777] Fix | Delete
* Returns the string, with after processing the following backslash escape sequences.
[10778] Fix | Delete
*
[10779] Fix | Delete
* attacklab: The polite way to do this is with the new escapeCharacters() function:
[10780] Fix | Delete
*
[10781] Fix | Delete
* text = escapeCharacters(text,"\\",true);
[10782] Fix | Delete
* text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
[10783] Fix | Delete
*
[10784] Fix | Delete
* ...but we're sidestepping its use of the (slow) RegExp constructor
[10785] Fix | Delete
* as an optimization for Firefox. This function gets called a LOT.
[10786] Fix | Delete
*/
[10787] Fix | Delete
showdown.subParser('encodeBackslashEscapes', function (text, options, globals) {
[10788] Fix | Delete
'use strict';
[10789] Fix | Delete
text = globals.converter._dispatch('encodeBackslashEscapes.before', text, options, globals);
[10790] Fix | Delete
[10791] Fix | Delete
text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback);
[10792] Fix | Delete
text = text.replace(/\\([`*_{}\[\]()>#+.!~=|-])/g, showdown.helper.escapeCharactersCallback);
[10793] Fix | Delete
[10794] Fix | Delete
text = globals.converter._dispatch('encodeBackslashEscapes.after', text, options, globals);
[10795] Fix | Delete
return text;
[10796] Fix | Delete
});
[10797] Fix | Delete
[10798] Fix | Delete
/**
[10799] Fix | Delete
* Encode/escape certain characters inside Markdown code runs.
[10800] Fix | Delete
* The point is that in code, these characters are literals,
[10801] Fix | Delete
* and lose their special Markdown meanings.
[10802] Fix | Delete
*/
[10803] Fix | Delete
showdown.subParser('encodeCode', function (text, options, globals) {
[10804] Fix | Delete
'use strict';
[10805] Fix | Delete
[10806] Fix | Delete
text = globals.converter._dispatch('encodeCode.before', text, options, globals);
[10807] Fix | Delete
[10808] Fix | Delete
// Encode all ampersands; HTML entities are not
[10809] Fix | Delete
// entities within a Markdown code span.
[10810] Fix | Delete
text = text
[10811] Fix | Delete
.replace(/&/g, '&amp;')
[10812] Fix | Delete
// Do the angle bracket song and dance:
[10813] Fix | Delete
.replace(/</g, '&lt;')
[10814] Fix | Delete
.replace(/>/g, '&gt;')
[10815] Fix | Delete
// Now, escape characters that are magic in Markdown:
[10816] Fix | Delete
.replace(/([*_{}\[\]\\=~-])/g, showdown.helper.escapeCharactersCallback);
[10817] Fix | Delete
[10818] Fix | Delete
text = globals.converter._dispatch('encodeCode.after', text, options, globals);
[10819] Fix | Delete
return text;
[10820] Fix | Delete
});
[10821] Fix | Delete
[10822] Fix | Delete
/**
[10823] Fix | Delete
* Within tags -- meaning between < and > -- encode [\ ` * _ ~ =] so they
[10824] Fix | Delete
* don't conflict with their use in Markdown for code, italics and strong.
[10825] Fix | Delete
*/
[10826] Fix | Delete
showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text, options, globals) {
[10827] Fix | Delete
'use strict';
[10828] Fix | Delete
text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.before', text, options, globals);
[10829] Fix | Delete
[10830] Fix | Delete
// Build a regex to find HTML tags.
[10831] Fix | Delete
var tags = /<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi,
[10832] Fix | Delete
comments = /<!(--(?:(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>/gi;
[10833] Fix | Delete
[10834] Fix | Delete
text = text.replace(tags, function (wholeMatch) {
[10835] Fix | Delete
return wholeMatch
[10836] Fix | Delete
.replace(/(.)<\/?code>(?=.)/g, '$1`')
[10837] Fix | Delete
.replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
[10838] Fix | Delete
});
[10839] Fix | Delete
[10840] Fix | Delete
text = text.replace(comments, function (wholeMatch) {
[10841] Fix | Delete
return wholeMatch
[10842] Fix | Delete
.replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
[10843] Fix | Delete
});
[10844] Fix | Delete
[10845] Fix | Delete
text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.after', text, options, globals);
[10846] Fix | Delete
return text;
[10847] Fix | Delete
});
[10848] Fix | Delete
[10849] Fix | Delete
/**
[10850] Fix | Delete
* Handle github codeblocks prior to running HashHTML so that
[10851] Fix | Delete
* HTML contained within the codeblock gets escaped properly
[10852] Fix | Delete
* Example:
[10853] Fix | Delete
* ```ruby
[10854] Fix | Delete
* def hello_world(x)
[10855] Fix | Delete
* puts "Hello, #{x}"
[10856] Fix | Delete
* end
[10857] Fix | Delete
* ```
[10858] Fix | Delete
*/
[10859] Fix | Delete
showdown.subParser('githubCodeBlocks', function (text, options, globals) {
[10860] Fix | Delete
'use strict';
[10861] Fix | Delete
[10862] Fix | Delete
// early exit if option is not enabled
[10863] Fix | Delete
if (!options.ghCodeBlocks) {
[10864] Fix | Delete
return text;
[10865] Fix | Delete
}
[10866] Fix | Delete
[10867] Fix | Delete
text = globals.converter._dispatch('githubCodeBlocks.before', text, options, globals);
[10868] Fix | Delete
[10869] Fix | Delete
text += '¨0';
[10870] Fix | Delete
[10871] Fix | Delete
text = text.replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g, function (wholeMatch, delim, language, codeblock) {
[10872] Fix | Delete
var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
[10873] Fix | Delete
[10874] Fix | Delete
// First parse the github code block
[10875] Fix | Delete
codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
[10876] Fix | Delete
codeblock = showdown.subParser('detab')(codeblock, options, globals);
[10877] Fix | Delete
codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
[10878] Fix | Delete
codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
[10879] Fix | Delete
[10880] Fix | Delete
codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>';
[10881] Fix | Delete
[10882] Fix | Delete
codeblock = showdown.subParser('hashBlock')(codeblock, options, globals);
[10883] Fix | Delete
[10884] Fix | Delete
// Since GHCodeblocks can be false positives, we need to
[10885] Fix | Delete
// store the primitive text and the parsed text in a global var,
[10886] Fix | Delete
// and then return a token
[10887] Fix | Delete
return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
[10888] Fix | Delete
});
[10889] Fix | Delete
[10890] Fix | Delete
// attacklab: strip sentinel
[10891] Fix | Delete
text = text.replace(/¨0/, '');
[10892] Fix | Delete
[10893] Fix | Delete
return globals.converter._dispatch('githubCodeBlocks.after', text, options, globals);
[10894] Fix | Delete
});
[10895] Fix | Delete
[10896] Fix | Delete
showdown.subParser('hashBlock', function (text, options, globals) {
[10897] Fix | Delete
'use strict';
[10898] Fix | Delete
text = globals.converter._dispatch('hashBlock.before', text, options, globals);
[10899] Fix | Delete
text = text.replace(/(^\n+|\n+$)/g, '');
[10900] Fix | Delete
text = '\n\n¨K' + (globals.gHtmlBlocks.push(text) - 1) + 'K\n\n';
[10901] Fix | Delete
text = globals.converter._dispatch('hashBlock.after', text, options, globals);
[10902] Fix | Delete
return text;
[10903] Fix | Delete
});
[10904] Fix | Delete
[10905] Fix | Delete
/**
[10906] Fix | Delete
* Hash and escape <code> elements that should not be parsed as markdown
[10907] Fix | Delete
*/
[10908] Fix | Delete
showdown.subParser('hashCodeTags', function (text, options, globals) {
[10909] Fix | Delete
'use strict';
[10910] Fix | Delete
text = globals.converter._dispatch('hashCodeTags.before', text, options, globals);
[10911] Fix | Delete
[10912] Fix | Delete
var repFunc = function (wholeMatch, match, left, right) {
[10913] Fix | Delete
var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right;
[10914] Fix | Delete
return '¨C' + (globals.gHtmlSpans.push(codeblock) - 1) + 'C';
[10915] Fix | Delete
};
[10916] Fix | Delete
[10917] Fix | Delete
// Hash naked <code>
[10918] Fix | Delete
text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '<code\\b[^>]*>', '</code>', 'gim');
[10919] Fix | Delete
[10920] Fix | Delete
text = globals.converter._dispatch('hashCodeTags.after', text, options, globals);
[10921] Fix | Delete
return text;
[10922] Fix | Delete
});
[10923] Fix | Delete
[10924] Fix | Delete
showdown.subParser('hashElement', function (text, options, globals) {
[10925] Fix | Delete
'use strict';
[10926] Fix | Delete
[10927] Fix | Delete
return function (wholeMatch, m1) {
[10928] Fix | Delete
var blockText = m1;
[10929] Fix | Delete
[10930] Fix | Delete
// Undo double lines
[10931] Fix | Delete
blockText = blockText.replace(/\n\n/g, '\n');
[10932] Fix | Delete
blockText = blockText.replace(/^\n/, '');
[10933] Fix | Delete
[10934] Fix | Delete
// strip trailing blank lines
[10935] Fix | Delete
blockText = blockText.replace(/\n+$/g, '');
[10936] Fix | Delete
[10937] Fix | Delete
// Replace the element text with a marker ("¨KxK" where x is its key)
[10938] Fix | Delete
blockText = '\n\n¨K' + (globals.gHtmlBlocks.push(blockText) - 1) + 'K\n\n';
[10939] Fix | Delete
[10940] Fix | Delete
return blockText;
[10941] Fix | Delete
};
[10942] Fix | Delete
});
[10943] Fix | Delete
[10944] Fix | Delete
showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
[10945] Fix | Delete
'use strict';
[10946] Fix | Delete
text = globals.converter._dispatch('hashHTMLBlocks.before', text, options, globals);
[10947] Fix | Delete
[10948] Fix | Delete
var blockTags = [
[10949] Fix | Delete
'pre',
[10950] Fix | Delete
'div',
[10951] Fix | Delete
'h1',
[10952] Fix | Delete
'h2',
[10953] Fix | Delete
'h3',
[10954] Fix | Delete
'h4',
[10955] Fix | Delete
'h5',
[10956] Fix | Delete
'h6',
[10957] Fix | Delete
'blockquote',
[10958] Fix | Delete
'table',
[10959] Fix | Delete
'dl',
[10960] Fix | Delete
'ol',
[10961] Fix | Delete
'ul',
[10962] Fix | Delete
'script',
[10963] Fix | Delete
'noscript',
[10964] Fix | Delete
'form',
[10965] Fix | Delete
'fieldset',
[10966] Fix | Delete
'iframe',
[10967] Fix | Delete
'math',
[10968] Fix | Delete
'style',
[10969] Fix | Delete
'section',
[10970] Fix | Delete
'header',
[10971] Fix | Delete
'footer',
[10972] Fix | Delete
'nav',
[10973] Fix | Delete
'article',
[10974] Fix | Delete
'aside',
[10975] Fix | Delete
'address',
[10976] Fix | Delete
'audio',
[10977] Fix | Delete
'canvas',
[10978] Fix | Delete
'figure',
[10979] Fix | Delete
'hgroup',
[10980] Fix | Delete
'output',
[10981] Fix | Delete
'video',
[10982] Fix | Delete
'p'
[10983] Fix | Delete
],
[10984] Fix | Delete
repFunc = function (wholeMatch, match, left, right) {
[10985] Fix | Delete
var txt = wholeMatch;
[10986] Fix | Delete
// check if this html element is marked as markdown
[10987] Fix | Delete
// if so, it's contents should be parsed as markdown
[10988] Fix | Delete
if (left.search(/\bmarkdown\b/) !== -1) {
[10989] Fix | Delete
txt = left + globals.converter.makeHtml(match) + right;
[10990] Fix | Delete
}
[10991] Fix | Delete
return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
[10992] Fix | Delete
};
[10993] Fix | Delete
[10994] Fix | Delete
if (options.backslashEscapesHTMLTags) {
[10995] Fix | Delete
// encode backslash escaped HTML tags
[10996] Fix | Delete
text = text.replace(/\\<(\/?[^>]+?)>/g, function (wm, inside) {
[10997] Fix | Delete
return '&lt;' + inside + '&gt;';
[10998] Fix | Delete
});
[10999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function