Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: blocks.js
}
[11000] Fix | Delete
[11001] Fix | Delete
// hash HTML Blocks
[11002] Fix | Delete
for (var i = 0; i < blockTags.length; ++i) {
[11003] Fix | Delete
[11004] Fix | Delete
var opTagPos,
[11005] Fix | Delete
rgx1 = new RegExp('^ {0,3}(<' + blockTags[i] + '\\b[^>]*>)', 'im'),
[11006] Fix | Delete
patLeft = '<' + blockTags[i] + '\\b[^>]*>',
[11007] Fix | Delete
patRight = '</' + blockTags[i] + '>';
[11008] Fix | Delete
// 1. Look for the first position of the first opening HTML tag in the text
[11009] Fix | Delete
while ((opTagPos = showdown.helper.regexIndexOf(text, rgx1)) !== -1) {
[11010] Fix | Delete
[11011] Fix | Delete
// if the HTML tag is \ escaped, we need to escape it and break
[11012] Fix | Delete
[11013] Fix | Delete
[11014] Fix | Delete
//2. Split the text in that position
[11015] Fix | Delete
var subTexts = showdown.helper.splitAtIndex(text, opTagPos),
[11016] Fix | Delete
//3. Match recursively
[11017] Fix | Delete
newSubText1 = showdown.helper.replaceRecursiveRegExp(subTexts[1], repFunc, patLeft, patRight, 'im');
[11018] Fix | Delete
[11019] Fix | Delete
// prevent an infinite loop
[11020] Fix | Delete
if (newSubText1 === subTexts[1]) {
[11021] Fix | Delete
break;
[11022] Fix | Delete
}
[11023] Fix | Delete
text = subTexts[0].concat(newSubText1);
[11024] Fix | Delete
}
[11025] Fix | Delete
}
[11026] Fix | Delete
// HR SPECIAL CASE
[11027] Fix | Delete
text = text.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,
[11028] Fix | Delete
showdown.subParser('hashElement')(text, options, globals));
[11029] Fix | Delete
[11030] Fix | Delete
// Special case for standalone HTML comments
[11031] Fix | Delete
text = showdown.helper.replaceRecursiveRegExp(text, function (txt) {
[11032] Fix | Delete
return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
[11033] Fix | Delete
}, '^ {0,3}<!--', '-->', 'gm');
[11034] Fix | Delete
[11035] Fix | Delete
// PHP and ASP-style processor instructions (<?...?> and <%...%>)
[11036] Fix | Delete
text = text.replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,
[11037] Fix | Delete
showdown.subParser('hashElement')(text, options, globals));
[11038] Fix | Delete
[11039] Fix | Delete
text = globals.converter._dispatch('hashHTMLBlocks.after', text, options, globals);
[11040] Fix | Delete
return text;
[11041] Fix | Delete
});
[11042] Fix | Delete
[11043] Fix | Delete
/**
[11044] Fix | Delete
* Hash span elements that should not be parsed as markdown
[11045] Fix | Delete
*/
[11046] Fix | Delete
showdown.subParser('hashHTMLSpans', function (text, options, globals) {
[11047] Fix | Delete
'use strict';
[11048] Fix | Delete
text = globals.converter._dispatch('hashHTMLSpans.before', text, options, globals);
[11049] Fix | Delete
[11050] Fix | Delete
function hashHTMLSpan (html) {
[11051] Fix | Delete
return '¨C' + (globals.gHtmlSpans.push(html) - 1) + 'C';
[11052] Fix | Delete
}
[11053] Fix | Delete
[11054] Fix | Delete
// Hash Self Closing tags
[11055] Fix | Delete
text = text.replace(/<[^>]+?\/>/gi, function (wm) {
[11056] Fix | Delete
return hashHTMLSpan(wm);
[11057] Fix | Delete
});
[11058] Fix | Delete
[11059] Fix | Delete
// Hash tags without properties
[11060] Fix | Delete
text = text.replace(/<([^>]+?)>[\s\S]*?<\/\1>/g, function (wm) {
[11061] Fix | Delete
return hashHTMLSpan(wm);
[11062] Fix | Delete
});
[11063] Fix | Delete
[11064] Fix | Delete
// Hash tags with properties
[11065] Fix | Delete
text = text.replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g, function (wm) {
[11066] Fix | Delete
return hashHTMLSpan(wm);
[11067] Fix | Delete
});
[11068] Fix | Delete
[11069] Fix | Delete
// Hash self closing tags without />
[11070] Fix | Delete
text = text.replace(/<[^>]+?>/gi, function (wm) {
[11071] Fix | Delete
return hashHTMLSpan(wm);
[11072] Fix | Delete
});
[11073] Fix | Delete
[11074] Fix | Delete
/*showdown.helper.matchRecursiveRegExp(text, '<code\\b[^>]*>', '</code>', 'gi');*/
[11075] Fix | Delete
[11076] Fix | Delete
text = globals.converter._dispatch('hashHTMLSpans.after', text, options, globals);
[11077] Fix | Delete
return text;
[11078] Fix | Delete
});
[11079] Fix | Delete
[11080] Fix | Delete
/**
[11081] Fix | Delete
* Unhash HTML spans
[11082] Fix | Delete
*/
[11083] Fix | Delete
showdown.subParser('unhashHTMLSpans', function (text, options, globals) {
[11084] Fix | Delete
'use strict';
[11085] Fix | Delete
text = globals.converter._dispatch('unhashHTMLSpans.before', text, options, globals);
[11086] Fix | Delete
[11087] Fix | Delete
for (var i = 0; i < globals.gHtmlSpans.length; ++i) {
[11088] Fix | Delete
var repText = globals.gHtmlSpans[i],
[11089] Fix | Delete
// limiter to prevent infinite loop (assume 10 as limit for recurse)
[11090] Fix | Delete
limit = 0;
[11091] Fix | Delete
[11092] Fix | Delete
while (/¨C(\d+)C/.test(repText)) {
[11093] Fix | Delete
var num = RegExp.$1;
[11094] Fix | Delete
repText = repText.replace('¨C' + num + 'C', globals.gHtmlSpans[num]);
[11095] Fix | Delete
if (limit === 10) {
[11096] Fix | Delete
console.error('maximum nesting of 10 spans reached!!!');
[11097] Fix | Delete
break;
[11098] Fix | Delete
}
[11099] Fix | Delete
++limit;
[11100] Fix | Delete
}
[11101] Fix | Delete
text = text.replace('¨C' + i + 'C', repText);
[11102] Fix | Delete
}
[11103] Fix | Delete
[11104] Fix | Delete
text = globals.converter._dispatch('unhashHTMLSpans.after', text, options, globals);
[11105] Fix | Delete
return text;
[11106] Fix | Delete
});
[11107] Fix | Delete
[11108] Fix | Delete
/**
[11109] Fix | Delete
* Hash and escape <pre><code> elements that should not be parsed as markdown
[11110] Fix | Delete
*/
[11111] Fix | Delete
showdown.subParser('hashPreCodeTags', function (text, options, globals) {
[11112] Fix | Delete
'use strict';
[11113] Fix | Delete
text = globals.converter._dispatch('hashPreCodeTags.before', text, options, globals);
[11114] Fix | Delete
[11115] Fix | Delete
var repFunc = function (wholeMatch, match, left, right) {
[11116] Fix | Delete
// encode html entities
[11117] Fix | Delete
var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right;
[11118] Fix | Delete
return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
[11119] Fix | Delete
};
[11120] Fix | Delete
[11121] Fix | Delete
// Hash <pre><code>
[11122] Fix | Delete
text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^ {0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>', '^ {0,3}</code>\\s*</pre>', 'gim');
[11123] Fix | Delete
[11124] Fix | Delete
text = globals.converter._dispatch('hashPreCodeTags.after', text, options, globals);
[11125] Fix | Delete
return text;
[11126] Fix | Delete
});
[11127] Fix | Delete
[11128] Fix | Delete
showdown.subParser('headers', function (text, options, globals) {
[11129] Fix | Delete
'use strict';
[11130] Fix | Delete
[11131] Fix | Delete
text = globals.converter._dispatch('headers.before', text, options, globals);
[11132] Fix | Delete
[11133] Fix | Delete
var headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart),
[11134] Fix | Delete
[11135] Fix | Delete
// Set text-style headers:
[11136] Fix | Delete
// Header 1
[11137] Fix | Delete
// ========
[11138] Fix | Delete
//
[11139] Fix | Delete
// Header 2
[11140] Fix | Delete
// --------
[11141] Fix | Delete
//
[11142] Fix | Delete
setextRegexH1 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm,
[11143] Fix | Delete
setextRegexH2 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm;
[11144] Fix | Delete
[11145] Fix | Delete
text = text.replace(setextRegexH1, function (wholeMatch, m1) {
[11146] Fix | Delete
[11147] Fix | Delete
var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
[11148] Fix | Delete
hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
[11149] Fix | Delete
hLevel = headerLevelStart,
[11150] Fix | Delete
hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
[11151] Fix | Delete
return showdown.subParser('hashBlock')(hashBlock, options, globals);
[11152] Fix | Delete
});
[11153] Fix | Delete
[11154] Fix | Delete
text = text.replace(setextRegexH2, function (matchFound, m1) {
[11155] Fix | Delete
var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
[11156] Fix | Delete
hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
[11157] Fix | Delete
hLevel = headerLevelStart + 1,
[11158] Fix | Delete
hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
[11159] Fix | Delete
return showdown.subParser('hashBlock')(hashBlock, options, globals);
[11160] Fix | Delete
});
[11161] Fix | Delete
[11162] Fix | Delete
// atx-style headers:
[11163] Fix | Delete
// # Header 1
[11164] Fix | Delete
// ## Header 2
[11165] Fix | Delete
// ## Header 2 with closing hashes ##
[11166] Fix | Delete
// ...
[11167] Fix | Delete
// ###### Header 6
[11168] Fix | Delete
//
[11169] Fix | Delete
var atxStyle = (options.requireSpaceBeforeHeadingText) ? /^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm : /^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm;
[11170] Fix | Delete
[11171] Fix | Delete
text = text.replace(atxStyle, function (wholeMatch, m1, m2) {
[11172] Fix | Delete
var hText = m2;
[11173] Fix | Delete
if (options.customizedHeaderId) {
[11174] Fix | Delete
hText = m2.replace(/\s?\{([^{]+?)}\s*$/, '');
[11175] Fix | Delete
}
[11176] Fix | Delete
[11177] Fix | Delete
var span = showdown.subParser('spanGamut')(hText, options, globals),
[11178] Fix | Delete
hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
[11179] Fix | Delete
hLevel = headerLevelStart - 1 + m1.length,
[11180] Fix | Delete
header = '<h' + hLevel + hID + '>' + span + '</h' + hLevel + '>';
[11181] Fix | Delete
[11182] Fix | Delete
return showdown.subParser('hashBlock')(header, options, globals);
[11183] Fix | Delete
});
[11184] Fix | Delete
[11185] Fix | Delete
function headerId (m) {
[11186] Fix | Delete
var title,
[11187] Fix | Delete
prefix;
[11188] Fix | Delete
[11189] Fix | Delete
// It is separate from other options to allow combining prefix and customized
[11190] Fix | Delete
if (options.customizedHeaderId) {
[11191] Fix | Delete
var match = m.match(/\{([^{]+?)}\s*$/);
[11192] Fix | Delete
if (match && match[1]) {
[11193] Fix | Delete
m = match[1];
[11194] Fix | Delete
}
[11195] Fix | Delete
}
[11196] Fix | Delete
[11197] Fix | Delete
title = m;
[11198] Fix | Delete
[11199] Fix | Delete
// Prefix id to prevent causing inadvertent pre-existing style matches.
[11200] Fix | Delete
if (showdown.helper.isString(options.prefixHeaderId)) {
[11201] Fix | Delete
prefix = options.prefixHeaderId;
[11202] Fix | Delete
} else if (options.prefixHeaderId === true) {
[11203] Fix | Delete
prefix = 'section-';
[11204] Fix | Delete
} else {
[11205] Fix | Delete
prefix = '';
[11206] Fix | Delete
}
[11207] Fix | Delete
[11208] Fix | Delete
if (!options.rawPrefixHeaderId) {
[11209] Fix | Delete
title = prefix + title;
[11210] Fix | Delete
}
[11211] Fix | Delete
[11212] Fix | Delete
if (options.ghCompatibleHeaderId) {
[11213] Fix | Delete
title = title
[11214] Fix | Delete
.replace(/ /g, '-')
[11215] Fix | Delete
// replace previously escaped chars (&, ¨ and $)
[11216] Fix | Delete
.replace(/&amp;/g, '')
[11217] Fix | Delete
.replace(/¨T/g, '')
[11218] Fix | Delete
.replace(/¨D/g, '')
[11219] Fix | Delete
// replace rest of the chars (&~$ are repeated as they might have been escaped)
[11220] Fix | Delete
// borrowed from github's redcarpet (some they should produce similar results)
[11221] Fix | Delete
.replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, '')
[11222] Fix | Delete
.toLowerCase();
[11223] Fix | Delete
} else if (options.rawHeaderId) {
[11224] Fix | Delete
title = title
[11225] Fix | Delete
.replace(/ /g, '-')
[11226] Fix | Delete
// replace previously escaped chars (&, ¨ and $)
[11227] Fix | Delete
.replace(/&amp;/g, '&')
[11228] Fix | Delete
.replace(/¨T/g, '¨')
[11229] Fix | Delete
.replace(/¨D/g, '$')
[11230] Fix | Delete
// replace " and '
[11231] Fix | Delete
.replace(/["']/g, '-')
[11232] Fix | Delete
.toLowerCase();
[11233] Fix | Delete
} else {
[11234] Fix | Delete
title = title
[11235] Fix | Delete
.replace(/[^\w]/g, '')
[11236] Fix | Delete
.toLowerCase();
[11237] Fix | Delete
}
[11238] Fix | Delete
[11239] Fix | Delete
if (options.rawPrefixHeaderId) {
[11240] Fix | Delete
title = prefix + title;
[11241] Fix | Delete
}
[11242] Fix | Delete
[11243] Fix | Delete
if (globals.hashLinkCounts[title]) {
[11244] Fix | Delete
title = title + '-' + (globals.hashLinkCounts[title]++);
[11245] Fix | Delete
} else {
[11246] Fix | Delete
globals.hashLinkCounts[title] = 1;
[11247] Fix | Delete
}
[11248] Fix | Delete
return title;
[11249] Fix | Delete
}
[11250] Fix | Delete
[11251] Fix | Delete
text = globals.converter._dispatch('headers.after', text, options, globals);
[11252] Fix | Delete
return text;
[11253] Fix | Delete
});
[11254] Fix | Delete
[11255] Fix | Delete
/**
[11256] Fix | Delete
* Turn Markdown link shortcuts into XHTML <a> tags.
[11257] Fix | Delete
*/
[11258] Fix | Delete
showdown.subParser('horizontalRule', function (text, options, globals) {
[11259] Fix | Delete
'use strict';
[11260] Fix | Delete
text = globals.converter._dispatch('horizontalRule.before', text, options, globals);
[11261] Fix | Delete
[11262] Fix | Delete
var key = showdown.subParser('hashBlock')('<hr />', options, globals);
[11263] Fix | Delete
text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, key);
[11264] Fix | Delete
text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, key);
[11265] Fix | Delete
text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, key);
[11266] Fix | Delete
[11267] Fix | Delete
text = globals.converter._dispatch('horizontalRule.after', text, options, globals);
[11268] Fix | Delete
return text;
[11269] Fix | Delete
});
[11270] Fix | Delete
[11271] Fix | Delete
/**
[11272] Fix | Delete
* Turn Markdown image shortcuts into <img> tags.
[11273] Fix | Delete
*/
[11274] Fix | Delete
showdown.subParser('images', function (text, options, globals) {
[11275] Fix | Delete
'use strict';
[11276] Fix | Delete
[11277] Fix | Delete
text = globals.converter._dispatch('images.before', text, options, globals);
[11278] Fix | Delete
[11279] Fix | Delete
var inlineRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
[11280] Fix | Delete
crazyRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g,
[11281] Fix | Delete
base64RegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
[11282] Fix | Delete
referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g,
[11283] Fix | Delete
refShortcutRegExp = /!\[([^\[\]]+)]()()()()()/g;
[11284] Fix | Delete
[11285] Fix | Delete
function writeImageTagBase64 (wholeMatch, altText, linkId, url, width, height, m5, title) {
[11286] Fix | Delete
url = url.replace(/\s/g, '');
[11287] Fix | Delete
return writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title);
[11288] Fix | Delete
}
[11289] Fix | Delete
[11290] Fix | Delete
function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) {
[11291] Fix | Delete
[11292] Fix | Delete
var gUrls = globals.gUrls,
[11293] Fix | Delete
gTitles = globals.gTitles,
[11294] Fix | Delete
gDims = globals.gDimensions;
[11295] Fix | Delete
[11296] Fix | Delete
linkId = linkId.toLowerCase();
[11297] Fix | Delete
[11298] Fix | Delete
if (!title) {
[11299] Fix | Delete
title = '';
[11300] Fix | Delete
}
[11301] Fix | Delete
// Special case for explicit empty url
[11302] Fix | Delete
if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) {
[11303] Fix | Delete
url = '';
[11304] Fix | Delete
[11305] Fix | Delete
} else if (url === '' || url === null) {
[11306] Fix | Delete
if (linkId === '' || linkId === null) {
[11307] Fix | Delete
// lower-case and turn embedded newlines into spaces
[11308] Fix | Delete
linkId = altText.toLowerCase().replace(/ ?\n/g, ' ');
[11309] Fix | Delete
}
[11310] Fix | Delete
url = '#' + linkId;
[11311] Fix | Delete
[11312] Fix | Delete
if (!showdown.helper.isUndefined(gUrls[linkId])) {
[11313] Fix | Delete
url = gUrls[linkId];
[11314] Fix | Delete
if (!showdown.helper.isUndefined(gTitles[linkId])) {
[11315] Fix | Delete
title = gTitles[linkId];
[11316] Fix | Delete
}
[11317] Fix | Delete
if (!showdown.helper.isUndefined(gDims[linkId])) {
[11318] Fix | Delete
width = gDims[linkId].width;
[11319] Fix | Delete
height = gDims[linkId].height;
[11320] Fix | Delete
}
[11321] Fix | Delete
} else {
[11322] Fix | Delete
return wholeMatch;
[11323] Fix | Delete
}
[11324] Fix | Delete
}
[11325] Fix | Delete
[11326] Fix | Delete
altText = altText
[11327] Fix | Delete
.replace(/"/g, '&quot;')
[11328] Fix | Delete
//altText = showdown.helper.escapeCharacters(altText, '*_', false);
[11329] Fix | Delete
.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
[11330] Fix | Delete
//url = showdown.helper.escapeCharacters(url, '*_', false);
[11331] Fix | Delete
url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
[11332] Fix | Delete
var result = '<img src="' + url + '" alt="' + altText + '"';
[11333] Fix | Delete
[11334] Fix | Delete
if (title && showdown.helper.isString(title)) {
[11335] Fix | Delete
title = title
[11336] Fix | Delete
.replace(/"/g, '&quot;')
[11337] Fix | Delete
//title = showdown.helper.escapeCharacters(title, '*_', false);
[11338] Fix | Delete
.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
[11339] Fix | Delete
result += ' title="' + title + '"';
[11340] Fix | Delete
}
[11341] Fix | Delete
[11342] Fix | Delete
if (width && height) {
[11343] Fix | Delete
width = (width === '*') ? 'auto' : width;
[11344] Fix | Delete
height = (height === '*') ? 'auto' : height;
[11345] Fix | Delete
[11346] Fix | Delete
result += ' width="' + width + '"';
[11347] Fix | Delete
result += ' height="' + height + '"';
[11348] Fix | Delete
}
[11349] Fix | Delete
[11350] Fix | Delete
result += ' />';
[11351] Fix | Delete
[11352] Fix | Delete
return result;
[11353] Fix | Delete
}
[11354] Fix | Delete
[11355] Fix | Delete
// First, handle reference-style labeled images: ![alt text][id]
[11356] Fix | Delete
text = text.replace(referenceRegExp, writeImageTag);
[11357] Fix | Delete
[11358] Fix | Delete
// Next, handle inline images: ![alt text](url =<width>x<height> "optional title")
[11359] Fix | Delete
[11360] Fix | Delete
// base64 encoded images
[11361] Fix | Delete
text = text.replace(base64RegExp, writeImageTagBase64);
[11362] Fix | Delete
[11363] Fix | Delete
// cases with crazy urls like ./image/cat1).png
[11364] Fix | Delete
text = text.replace(crazyRegExp, writeImageTag);
[11365] Fix | Delete
[11366] Fix | Delete
// normal cases
[11367] Fix | Delete
text = text.replace(inlineRegExp, writeImageTag);
[11368] Fix | Delete
[11369] Fix | Delete
// handle reference-style shortcuts: ![img text]
[11370] Fix | Delete
text = text.replace(refShortcutRegExp, writeImageTag);
[11371] Fix | Delete
[11372] Fix | Delete
text = globals.converter._dispatch('images.after', text, options, globals);
[11373] Fix | Delete
return text;
[11374] Fix | Delete
});
[11375] Fix | Delete
[11376] Fix | Delete
showdown.subParser('italicsAndBold', function (text, options, globals) {
[11377] Fix | Delete
'use strict';
[11378] Fix | Delete
[11379] Fix | Delete
text = globals.converter._dispatch('italicsAndBold.before', text, options, globals);
[11380] Fix | Delete
[11381] Fix | Delete
// it's faster to have 3 separate regexes for each case than have just one
[11382] Fix | Delete
// because of backtracing, in some cases, it could lead to an exponential effect
[11383] Fix | Delete
// called "catastrophic backtrace". Ominous!
[11384] Fix | Delete
[11385] Fix | Delete
function parseInside (txt, left, right) {
[11386] Fix | Delete
/*
[11387] Fix | Delete
if (options.simplifiedAutoLink) {
[11388] Fix | Delete
txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
[11389] Fix | Delete
}
[11390] Fix | Delete
*/
[11391] Fix | Delete
return left + txt + right;
[11392] Fix | Delete
}
[11393] Fix | Delete
[11394] Fix | Delete
// Parse underscores
[11395] Fix | Delete
if (options.literalMidWordUnderscores) {
[11396] Fix | Delete
text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
[11397] Fix | Delete
return parseInside (txt, '<strong><em>', '</em></strong>');
[11398] Fix | Delete
});
[11399] Fix | Delete
text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
[11400] Fix | Delete
return parseInside (txt, '<strong>', '</strong>');
[11401] Fix | Delete
});
[11402] Fix | Delete
text = text.replace(/\b_(\S[\s\S]*?)_\b/g, function (wm, txt) {
[11403] Fix | Delete
return parseInside (txt, '<em>', '</em>');
[11404] Fix | Delete
});
[11405] Fix | Delete
} else {
[11406] Fix | Delete
text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
[11407] Fix | Delete
return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
[11408] Fix | Delete
});
[11409] Fix | Delete
text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
[11410] Fix | Delete
return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
[11411] Fix | Delete
});
[11412] Fix | Delete
text = text.replace(/_([^\s_][\s\S]*?)_/g, function (wm, m) {
[11413] Fix | Delete
// !/^_[^_]/.test(m) - test if it doesn't start with __ (since it seems redundant, we removed it)
[11414] Fix | Delete
return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
[11415] Fix | Delete
});
[11416] Fix | Delete
}
[11417] Fix | Delete
[11418] Fix | Delete
// Now parse asterisks
[11419] Fix | Delete
if (options.literalMidWordAsterisks) {
[11420] Fix | Delete
text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]*?)\*\*\*\B(?!\*)/g, function (wm, lead, txt) {
[11421] Fix | Delete
return parseInside (txt, lead + '<strong><em>', '</em></strong>');
[11422] Fix | Delete
});
[11423] Fix | Delete
text = text.replace(/([^*]|^)\B\*\*(\S[\s\S]*?)\*\*\B(?!\*)/g, function (wm, lead, txt) {
[11424] Fix | Delete
return parseInside (txt, lead + '<strong>', '</strong>');
[11425] Fix | Delete
});
[11426] Fix | Delete
text = text.replace(/([^*]|^)\B\*(\S[\s\S]*?)\*\B(?!\*)/g, function (wm, lead, txt) {
[11427] Fix | Delete
return parseInside (txt, lead + '<em>', '</em>');
[11428] Fix | Delete
});
[11429] Fix | Delete
} else {
[11430] Fix | Delete
text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
[11431] Fix | Delete
return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
[11432] Fix | Delete
});
[11433] Fix | Delete
text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
[11434] Fix | Delete
return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
[11435] Fix | Delete
});
[11436] Fix | Delete
text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function (wm, m) {
[11437] Fix | Delete
// !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it)
[11438] Fix | Delete
return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
[11439] Fix | Delete
});
[11440] Fix | Delete
}
[11441] Fix | Delete
[11442] Fix | Delete
[11443] Fix | Delete
text = globals.converter._dispatch('italicsAndBold.after', text, options, globals);
[11444] Fix | Delete
return text;
[11445] Fix | Delete
});
[11446] Fix | Delete
[11447] Fix | Delete
/**
[11448] Fix | Delete
* Form HTML ordered (numbered) and unordered (bulleted) lists.
[11449] Fix | Delete
*/
[11450] Fix | Delete
showdown.subParser('lists', function (text, options, globals) {
[11451] Fix | Delete
'use strict';
[11452] Fix | Delete
[11453] Fix | Delete
/**
[11454] Fix | Delete
* Process the contents of a single ordered or unordered list, splitting it
[11455] Fix | Delete
* into individual list items.
[11456] Fix | Delete
* @param {string} listStr
[11457] Fix | Delete
* @param {boolean} trimTrailing
[11458] Fix | Delete
* @returns {string}
[11459] Fix | Delete
*/
[11460] Fix | Delete
function processListItems (listStr, trimTrailing) {
[11461] Fix | Delete
// The $g_list_level global keeps track of when we're inside a list.
[11462] Fix | Delete
// Each time we enter a list, we increment it; when we leave a list,
[11463] Fix | Delete
// we decrement. If it's zero, we're not in a list anymore.
[11464] Fix | Delete
//
[11465] Fix | Delete
// We do this because when we're not inside a list, we want to treat
[11466] Fix | Delete
// something like this:
[11467] Fix | Delete
//
[11468] Fix | Delete
// I recommend upgrading to version
[11469] Fix | Delete
// 8. Oops, now this line is treated
[11470] Fix | Delete
// as a sub-list.
[11471] Fix | Delete
//
[11472] Fix | Delete
// As a single paragraph, despite the fact that the second line starts
[11473] Fix | Delete
// with a digit-period-space sequence.
[11474] Fix | Delete
//
[11475] Fix | Delete
// Whereas when we're inside a list (or sub-list), that line will be
[11476] Fix | Delete
// treated as the start of a sub-list. What a kludge, huh? This is
[11477] Fix | Delete
// an aspect of Markdown's syntax that's hard to parse perfectly
[11478] Fix | Delete
// without resorting to mind-reading. Perhaps the solution is to
[11479] Fix | Delete
// change the syntax rules such that sub-lists must start with a
[11480] Fix | Delete
// starting cardinal number; e.g. "1." or "a.".
[11481] Fix | Delete
globals.gListLevel++;
[11482] Fix | Delete
[11483] Fix | Delete
// trim trailing blank lines:
[11484] Fix | Delete
listStr = listStr.replace(/\n{2,}$/, '\n');
[11485] Fix | Delete
[11486] Fix | Delete
// attacklab: add sentinel to emulate \z
[11487] Fix | Delete
listStr += '¨0';
[11488] Fix | Delete
[11489] Fix | Delete
var rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm,
[11490] Fix | Delete
isParagraphed = (/\n[ \t]*\n(?!¨0)/.test(listStr));
[11491] Fix | Delete
[11492] Fix | Delete
// Since version 1.5, nesting sublists requires 4 spaces (or 1 tab) indentation,
[11493] Fix | Delete
// which is a syntax breaking change
[11494] Fix | Delete
// activating this option reverts to old behavior
[11495] Fix | Delete
if (options.disableForced4SpacesIndentedSublists) {
[11496] Fix | Delete
rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm;
[11497] Fix | Delete
}
[11498] Fix | Delete
[11499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function