Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: blocks.js
listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
[11500] Fix | Delete
checked = (checked && checked.trim() !== '');
[11501] Fix | Delete
[11502] Fix | Delete
var item = showdown.subParser('outdent')(m4, options, globals),
[11503] Fix | Delete
bulletStyle = '';
[11504] Fix | Delete
[11505] Fix | Delete
// Support for github tasklists
[11506] Fix | Delete
if (taskbtn && options.tasklists) {
[11507] Fix | Delete
bulletStyle = ' class="task-list-item" style="list-style-type: none;"';
[11508] Fix | Delete
item = item.replace(/^[ \t]*\[(x|X| )?]/m, function () {
[11509] Fix | Delete
var otp = '<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';
[11510] Fix | Delete
if (checked) {
[11511] Fix | Delete
otp += ' checked';
[11512] Fix | Delete
}
[11513] Fix | Delete
otp += '>';
[11514] Fix | Delete
return otp;
[11515] Fix | Delete
});
[11516] Fix | Delete
}
[11517] Fix | Delete
[11518] Fix | Delete
// ISSUE #312
[11519] Fix | Delete
// This input: - - - a
[11520] Fix | Delete
// causes trouble to the parser, since it interprets it as:
[11521] Fix | Delete
// <ul><li><li><li>a</li></li></li></ul>
[11522] Fix | Delete
// instead of:
[11523] Fix | Delete
// <ul><li>- - a</li></ul>
[11524] Fix | Delete
// So, to prevent it, we will put a marker (¨A)in the beginning of the line
[11525] Fix | Delete
// Kind of hackish/monkey patching, but seems more effective than overcomplicating the list parser
[11526] Fix | Delete
item = item.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g, function (wm2) {
[11527] Fix | Delete
return '¨A' + wm2;
[11528] Fix | Delete
});
[11529] Fix | Delete
[11530] Fix | Delete
// m1 - Leading line or
[11531] Fix | Delete
// Has a double return (multi paragraph) or
[11532] Fix | Delete
// Has sublist
[11533] Fix | Delete
if (m1 || (item.search(/\n{2,}/) > -1)) {
[11534] Fix | Delete
item = showdown.subParser('githubCodeBlocks')(item, options, globals);
[11535] Fix | Delete
item = showdown.subParser('blockGamut')(item, options, globals);
[11536] Fix | Delete
} else {
[11537] Fix | Delete
// Recursion for sub-lists:
[11538] Fix | Delete
item = showdown.subParser('lists')(item, options, globals);
[11539] Fix | Delete
item = item.replace(/\n$/, ''); // chomp(item)
[11540] Fix | Delete
item = showdown.subParser('hashHTMLBlocks')(item, options, globals);
[11541] Fix | Delete
[11542] Fix | Delete
// Colapse double linebreaks
[11543] Fix | Delete
item = item.replace(/\n\n+/g, '\n\n');
[11544] Fix | Delete
if (isParagraphed) {
[11545] Fix | Delete
item = showdown.subParser('paragraphs')(item, options, globals);
[11546] Fix | Delete
} else {
[11547] Fix | Delete
item = showdown.subParser('spanGamut')(item, options, globals);
[11548] Fix | Delete
}
[11549] Fix | Delete
}
[11550] Fix | Delete
[11551] Fix | Delete
// now we need to remove the marker (¨A)
[11552] Fix | Delete
item = item.replace('¨A', '');
[11553] Fix | Delete
// we can finally wrap the line in list item tags
[11554] Fix | Delete
item = '<li' + bulletStyle + '>' + item + '</li>\n';
[11555] Fix | Delete
[11556] Fix | Delete
return item;
[11557] Fix | Delete
});
[11558] Fix | Delete
[11559] Fix | Delete
// attacklab: strip sentinel
[11560] Fix | Delete
listStr = listStr.replace(/¨0/g, '');
[11561] Fix | Delete
[11562] Fix | Delete
globals.gListLevel--;
[11563] Fix | Delete
[11564] Fix | Delete
if (trimTrailing) {
[11565] Fix | Delete
listStr = listStr.replace(/\s+$/, '');
[11566] Fix | Delete
}
[11567] Fix | Delete
[11568] Fix | Delete
return listStr;
[11569] Fix | Delete
}
[11570] Fix | Delete
[11571] Fix | Delete
function styleStartNumber (list, listType) {
[11572] Fix | Delete
// check if ol and starts by a number different than 1
[11573] Fix | Delete
if (listType === 'ol') {
[11574] Fix | Delete
var res = list.match(/^ *(\d+)\./);
[11575] Fix | Delete
if (res && res[1] !== '1') {
[11576] Fix | Delete
return ' start="' + res[1] + '"';
[11577] Fix | Delete
}
[11578] Fix | Delete
}
[11579] Fix | Delete
return '';
[11580] Fix | Delete
}
[11581] Fix | Delete
[11582] Fix | Delete
/**
[11583] Fix | Delete
* Check and parse consecutive lists (better fix for issue #142)
[11584] Fix | Delete
* @param {string} list
[11585] Fix | Delete
* @param {string} listType
[11586] Fix | Delete
* @param {boolean} trimTrailing
[11587] Fix | Delete
* @returns {string}
[11588] Fix | Delete
*/
[11589] Fix | Delete
function parseConsecutiveLists (list, listType, trimTrailing) {
[11590] Fix | Delete
// check if we caught 2 or more consecutive lists by mistake
[11591] Fix | Delete
// we use the counterRgx, meaning if listType is UL we look for OL and vice versa
[11592] Fix | Delete
var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm,
[11593] Fix | Delete
ulRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?[*+-][ \t]/gm : /^ {0,3}[*+-][ \t]/gm,
[11594] Fix | Delete
counterRxg = (listType === 'ul') ? olRgx : ulRgx,
[11595] Fix | Delete
result = '';
[11596] Fix | Delete
[11597] Fix | Delete
if (list.search(counterRxg) !== -1) {
[11598] Fix | Delete
(function parseCL (txt) {
[11599] Fix | Delete
var pos = txt.search(counterRxg),
[11600] Fix | Delete
style = styleStartNumber(list, listType);
[11601] Fix | Delete
if (pos !== -1) {
[11602] Fix | Delete
// slice
[11603] Fix | Delete
result += '\n\n<' + listType + style + '>\n' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n';
[11604] Fix | Delete
[11605] Fix | Delete
// invert counterType and listType
[11606] Fix | Delete
listType = (listType === 'ul') ? 'ol' : 'ul';
[11607] Fix | Delete
counterRxg = (listType === 'ul') ? olRgx : ulRgx;
[11608] Fix | Delete
[11609] Fix | Delete
//recurse
[11610] Fix | Delete
parseCL(txt.slice(pos));
[11611] Fix | Delete
} else {
[11612] Fix | Delete
result += '\n\n<' + listType + style + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
[11613] Fix | Delete
}
[11614] Fix | Delete
})(list);
[11615] Fix | Delete
} else {
[11616] Fix | Delete
var style = styleStartNumber(list, listType);
[11617] Fix | Delete
result = '\n\n<' + listType + style + '>\n' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n';
[11618] Fix | Delete
}
[11619] Fix | Delete
[11620] Fix | Delete
return result;
[11621] Fix | Delete
}
[11622] Fix | Delete
[11623] Fix | Delete
/** Start of list parsing **/
[11624] Fix | Delete
text = globals.converter._dispatch('lists.before', text, options, globals);
[11625] Fix | Delete
// add sentinel to hack around khtml/safari bug:
[11626] Fix | Delete
// http://bugs.webkit.org/show_bug.cgi?id=11231
[11627] Fix | Delete
text += '¨0';
[11628] Fix | Delete
[11629] Fix | Delete
if (globals.gListLevel) {
[11630] Fix | Delete
text = text.replace(/^(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
[11631] Fix | Delete
function (wholeMatch, list, m2) {
[11632] Fix | Delete
var listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
[11633] Fix | Delete
return parseConsecutiveLists(list, listType, true);
[11634] Fix | Delete
}
[11635] Fix | Delete
);
[11636] Fix | Delete
} else {
[11637] Fix | Delete
text = text.replace(/(\n\n|^\n?)(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
[11638] Fix | Delete
function (wholeMatch, m1, list, m3) {
[11639] Fix | Delete
var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
[11640] Fix | Delete
return parseConsecutiveLists(list, listType, false);
[11641] Fix | Delete
}
[11642] Fix | Delete
);
[11643] Fix | Delete
}
[11644] Fix | Delete
[11645] Fix | Delete
// strip sentinel
[11646] Fix | Delete
text = text.replace(/¨0/, '');
[11647] Fix | Delete
text = globals.converter._dispatch('lists.after', text, options, globals);
[11648] Fix | Delete
return text;
[11649] Fix | Delete
});
[11650] Fix | Delete
[11651] Fix | Delete
/**
[11652] Fix | Delete
* Parse metadata at the top of the document
[11653] Fix | Delete
*/
[11654] Fix | Delete
showdown.subParser('metadata', function (text, options, globals) {
[11655] Fix | Delete
'use strict';
[11656] Fix | Delete
[11657] Fix | Delete
if (!options.metadata) {
[11658] Fix | Delete
return text;
[11659] Fix | Delete
}
[11660] Fix | Delete
[11661] Fix | Delete
text = globals.converter._dispatch('metadata.before', text, options, globals);
[11662] Fix | Delete
[11663] Fix | Delete
function parseMetadataContents (content) {
[11664] Fix | Delete
// raw is raw so it's not changed in any way
[11665] Fix | Delete
globals.metadata.raw = content;
[11666] Fix | Delete
[11667] Fix | Delete
// escape chars forbidden in html attributes
[11668] Fix | Delete
// double quotes
[11669] Fix | Delete
content = content
[11670] Fix | Delete
// ampersand first
[11671] Fix | Delete
.replace(/&/g, '&amp;')
[11672] Fix | Delete
// double quotes
[11673] Fix | Delete
.replace(/"/g, '&quot;');
[11674] Fix | Delete
[11675] Fix | Delete
content = content.replace(/\n {4}/g, ' ');
[11676] Fix | Delete
content.replace(/^([\S ]+): +([\s\S]+?)$/gm, function (wm, key, value) {
[11677] Fix | Delete
globals.metadata.parsed[key] = value;
[11678] Fix | Delete
return '';
[11679] Fix | Delete
});
[11680] Fix | Delete
}
[11681] Fix | Delete
[11682] Fix | Delete
text = text.replace(/^\s*«««+(\S*?)\n([\s\S]+?)\n»»»+\n/, function (wholematch, format, content) {
[11683] Fix | Delete
parseMetadataContents(content);
[11684] Fix | Delete
return '¨M';
[11685] Fix | Delete
});
[11686] Fix | Delete
[11687] Fix | Delete
text = text.replace(/^\s*---+(\S*?)\n([\s\S]+?)\n---+\n/, function (wholematch, format, content) {
[11688] Fix | Delete
if (format) {
[11689] Fix | Delete
globals.metadata.format = format;
[11690] Fix | Delete
}
[11691] Fix | Delete
parseMetadataContents(content);
[11692] Fix | Delete
return '¨M';
[11693] Fix | Delete
});
[11694] Fix | Delete
[11695] Fix | Delete
text = text.replace(/¨M/g, '');
[11696] Fix | Delete
[11697] Fix | Delete
text = globals.converter._dispatch('metadata.after', text, options, globals);
[11698] Fix | Delete
return text;
[11699] Fix | Delete
});
[11700] Fix | Delete
[11701] Fix | Delete
/**
[11702] Fix | Delete
* Remove one level of line-leading tabs or spaces
[11703] Fix | Delete
*/
[11704] Fix | Delete
showdown.subParser('outdent', function (text, options, globals) {
[11705] Fix | Delete
'use strict';
[11706] Fix | Delete
text = globals.converter._dispatch('outdent.before', text, options, globals);
[11707] Fix | Delete
[11708] Fix | Delete
// attacklab: hack around Konqueror 3.5.4 bug:
[11709] Fix | Delete
// "----------bug".replace(/^-/g,"") == "bug"
[11710] Fix | Delete
text = text.replace(/^(\t|[ ]{1,4})/gm, '¨0'); // attacklab: g_tab_width
[11711] Fix | Delete
[11712] Fix | Delete
// attacklab: clean up hack
[11713] Fix | Delete
text = text.replace(/¨0/g, '');
[11714] Fix | Delete
[11715] Fix | Delete
text = globals.converter._dispatch('outdent.after', text, options, globals);
[11716] Fix | Delete
return text;
[11717] Fix | Delete
});
[11718] Fix | Delete
[11719] Fix | Delete
/**
[11720] Fix | Delete
*
[11721] Fix | Delete
*/
[11722] Fix | Delete
showdown.subParser('paragraphs', function (text, options, globals) {
[11723] Fix | Delete
'use strict';
[11724] Fix | Delete
[11725] Fix | Delete
text = globals.converter._dispatch('paragraphs.before', text, options, globals);
[11726] Fix | Delete
// Strip leading and trailing lines:
[11727] Fix | Delete
text = text.replace(/^\n+/g, '');
[11728] Fix | Delete
text = text.replace(/\n+$/g, '');
[11729] Fix | Delete
[11730] Fix | Delete
var grafs = text.split(/\n{2,}/g),
[11731] Fix | Delete
grafsOut = [],
[11732] Fix | Delete
end = grafs.length; // Wrap <p> tags
[11733] Fix | Delete
[11734] Fix | Delete
for (var i = 0; i < end; i++) {
[11735] Fix | Delete
var str = grafs[i];
[11736] Fix | Delete
// if this is an HTML marker, copy it
[11737] Fix | Delete
if (str.search(/¨(K|G)(\d+)\1/g) >= 0) {
[11738] Fix | Delete
grafsOut.push(str);
[11739] Fix | Delete
[11740] Fix | Delete
// test for presence of characters to prevent empty lines being parsed
[11741] Fix | Delete
// as paragraphs (resulting in undesired extra empty paragraphs)
[11742] Fix | Delete
} else if (str.search(/\S/) >= 0) {
[11743] Fix | Delete
str = showdown.subParser('spanGamut')(str, options, globals);
[11744] Fix | Delete
str = str.replace(/^([ \t]*)/g, '<p>');
[11745] Fix | Delete
str += '</p>';
[11746] Fix | Delete
grafsOut.push(str);
[11747] Fix | Delete
}
[11748] Fix | Delete
}
[11749] Fix | Delete
[11750] Fix | Delete
/** Unhashify HTML blocks */
[11751] Fix | Delete
end = grafsOut.length;
[11752] Fix | Delete
for (i = 0; i < end; i++) {
[11753] Fix | Delete
var blockText = '',
[11754] Fix | Delete
grafsOutIt = grafsOut[i],
[11755] Fix | Delete
codeFlag = false;
[11756] Fix | Delete
// if this is a marker for an html block...
[11757] Fix | Delete
// use RegExp.test instead of string.search because of QML bug
[11758] Fix | Delete
while (/¨(K|G)(\d+)\1/.test(grafsOutIt)) {
[11759] Fix | Delete
var delim = RegExp.$1,
[11760] Fix | Delete
num = RegExp.$2;
[11761] Fix | Delete
[11762] Fix | Delete
if (delim === 'K') {
[11763] Fix | Delete
blockText = globals.gHtmlBlocks[num];
[11764] Fix | Delete
} else {
[11765] Fix | Delete
// we need to check if ghBlock is a false positive
[11766] Fix | Delete
if (codeFlag) {
[11767] Fix | Delete
// use encoded version of all text
[11768] Fix | Delete
blockText = showdown.subParser('encodeCode')(globals.ghCodeBlocks[num].text, options, globals);
[11769] Fix | Delete
} else {
[11770] Fix | Delete
blockText = globals.ghCodeBlocks[num].codeblock;
[11771] Fix | Delete
}
[11772] Fix | Delete
}
[11773] Fix | Delete
blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs
[11774] Fix | Delete
[11775] Fix | Delete
grafsOutIt = grafsOutIt.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/, blockText);
[11776] Fix | Delete
// Check if grafsOutIt is a pre->code
[11777] Fix | Delete
if (/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(grafsOutIt)) {
[11778] Fix | Delete
codeFlag = true;
[11779] Fix | Delete
}
[11780] Fix | Delete
}
[11781] Fix | Delete
grafsOut[i] = grafsOutIt;
[11782] Fix | Delete
}
[11783] Fix | Delete
text = grafsOut.join('\n');
[11784] Fix | Delete
// Strip leading and trailing lines:
[11785] Fix | Delete
text = text.replace(/^\n+/g, '');
[11786] Fix | Delete
text = text.replace(/\n+$/g, '');
[11787] Fix | Delete
return globals.converter._dispatch('paragraphs.after', text, options, globals);
[11788] Fix | Delete
});
[11789] Fix | Delete
[11790] Fix | Delete
/**
[11791] Fix | Delete
* Run extension
[11792] Fix | Delete
*/
[11793] Fix | Delete
showdown.subParser('runExtension', function (ext, text, options, globals) {
[11794] Fix | Delete
'use strict';
[11795] Fix | Delete
[11796] Fix | Delete
if (ext.filter) {
[11797] Fix | Delete
text = ext.filter(text, globals.converter, options);
[11798] Fix | Delete
[11799] Fix | Delete
} else if (ext.regex) {
[11800] Fix | Delete
// TODO remove this when old extension loading mechanism is deprecated
[11801] Fix | Delete
var re = ext.regex;
[11802] Fix | Delete
if (!(re instanceof RegExp)) {
[11803] Fix | Delete
re = new RegExp(re, 'g');
[11804] Fix | Delete
}
[11805] Fix | Delete
text = text.replace(re, ext.replace);
[11806] Fix | Delete
}
[11807] Fix | Delete
[11808] Fix | Delete
return text;
[11809] Fix | Delete
});
[11810] Fix | Delete
[11811] Fix | Delete
/**
[11812] Fix | Delete
* These are all the transformations that occur *within* block-level
[11813] Fix | Delete
* tags like paragraphs, headers, and list items.
[11814] Fix | Delete
*/
[11815] Fix | Delete
showdown.subParser('spanGamut', function (text, options, globals) {
[11816] Fix | Delete
'use strict';
[11817] Fix | Delete
[11818] Fix | Delete
text = globals.converter._dispatch('spanGamut.before', text, options, globals);
[11819] Fix | Delete
text = showdown.subParser('codeSpans')(text, options, globals);
[11820] Fix | Delete
text = showdown.subParser('escapeSpecialCharsWithinTagAttributes')(text, options, globals);
[11821] Fix | Delete
text = showdown.subParser('encodeBackslashEscapes')(text, options, globals);
[11822] Fix | Delete
[11823] Fix | Delete
// Process anchor and image tags. Images must come first,
[11824] Fix | Delete
// because ![foo][f] looks like an anchor.
[11825] Fix | Delete
text = showdown.subParser('images')(text, options, globals);
[11826] Fix | Delete
text = showdown.subParser('anchors')(text, options, globals);
[11827] Fix | Delete
[11828] Fix | Delete
// Make links out of things like `<http://example.com/>`
[11829] Fix | Delete
// Must come after anchors, because you can use < and >
[11830] Fix | Delete
// delimiters in inline links like [this](<url>).
[11831] Fix | Delete
text = showdown.subParser('autoLinks')(text, options, globals);
[11832] Fix | Delete
text = showdown.subParser('simplifiedAutoLinks')(text, options, globals);
[11833] Fix | Delete
text = showdown.subParser('emoji')(text, options, globals);
[11834] Fix | Delete
text = showdown.subParser('underline')(text, options, globals);
[11835] Fix | Delete
text = showdown.subParser('italicsAndBold')(text, options, globals);
[11836] Fix | Delete
text = showdown.subParser('strikethrough')(text, options, globals);
[11837] Fix | Delete
text = showdown.subParser('ellipsis')(text, options, globals);
[11838] Fix | Delete
[11839] Fix | Delete
// we need to hash HTML tags inside spans
[11840] Fix | Delete
text = showdown.subParser('hashHTMLSpans')(text, options, globals);
[11841] Fix | Delete
[11842] Fix | Delete
// now we encode amps and angles
[11843] Fix | Delete
text = showdown.subParser('encodeAmpsAndAngles')(text, options, globals);
[11844] Fix | Delete
[11845] Fix | Delete
// Do hard breaks
[11846] Fix | Delete
if (options.simpleLineBreaks) {
[11847] Fix | Delete
// GFM style hard breaks
[11848] Fix | Delete
// only add line breaks if the text does not contain a block (special case for lists)
[11849] Fix | Delete
if (!/\n\n¨K/.test(text)) {
[11850] Fix | Delete
text = text.replace(/\n+/g, '<br />\n');
[11851] Fix | Delete
}
[11852] Fix | Delete
} else {
[11853] Fix | Delete
// Vanilla hard breaks
[11854] Fix | Delete
text = text.replace(/ +\n/g, '<br />\n');
[11855] Fix | Delete
}
[11856] Fix | Delete
[11857] Fix | Delete
text = globals.converter._dispatch('spanGamut.after', text, options, globals);
[11858] Fix | Delete
return text;
[11859] Fix | Delete
});
[11860] Fix | Delete
[11861] Fix | Delete
showdown.subParser('strikethrough', function (text, options, globals) {
[11862] Fix | Delete
'use strict';
[11863] Fix | Delete
[11864] Fix | Delete
function parseInside (txt) {
[11865] Fix | Delete
if (options.simplifiedAutoLink) {
[11866] Fix | Delete
txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
[11867] Fix | Delete
}
[11868] Fix | Delete
return '<del>' + txt + '</del>';
[11869] Fix | Delete
}
[11870] Fix | Delete
[11871] Fix | Delete
if (options.strikethrough) {
[11872] Fix | Delete
text = globals.converter._dispatch('strikethrough.before', text, options, globals);
[11873] Fix | Delete
text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return parseInside(txt); });
[11874] Fix | Delete
text = globals.converter._dispatch('strikethrough.after', text, options, globals);
[11875] Fix | Delete
}
[11876] Fix | Delete
[11877] Fix | Delete
return text;
[11878] Fix | Delete
});
[11879] Fix | Delete
[11880] Fix | Delete
/**
[11881] Fix | Delete
* Strips link definitions from text, stores the URLs and titles in
[11882] Fix | Delete
* hash references.
[11883] Fix | Delete
* Link defs are in the form: ^[id]: url "optional title"
[11884] Fix | Delete
*/
[11885] Fix | Delete
showdown.subParser('stripLinkDefinitions', function (text, options, globals) {
[11886] Fix | Delete
'use strict';
[11887] Fix | Delete
[11888] Fix | Delete
var regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm,
[11889] Fix | Delete
base64Regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm;
[11890] Fix | Delete
[11891] Fix | Delete
// attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
[11892] Fix | Delete
text += '¨0';
[11893] Fix | Delete
[11894] Fix | Delete
var replaceFunc = function (wholeMatch, linkId, url, width, height, blankLines, title) {
[11895] Fix | Delete
linkId = linkId.toLowerCase();
[11896] Fix | Delete
if (url.match(/^data:.+?\/.+?;base64,/)) {
[11897] Fix | Delete
// remove newlines
[11898] Fix | Delete
globals.gUrls[linkId] = url.replace(/\s/g, '');
[11899] Fix | Delete
} else {
[11900] Fix | Delete
globals.gUrls[linkId] = showdown.subParser('encodeAmpsAndAngles')(url, options, globals); // Link IDs are case-insensitive
[11901] Fix | Delete
}
[11902] Fix | Delete
[11903] Fix | Delete
if (blankLines) {
[11904] Fix | Delete
// Oops, found blank lines, so it's not a title.
[11905] Fix | Delete
// Put back the parenthetical statement we stole.
[11906] Fix | Delete
return blankLines + title;
[11907] Fix | Delete
[11908] Fix | Delete
} else {
[11909] Fix | Delete
if (title) {
[11910] Fix | Delete
globals.gTitles[linkId] = title.replace(/"|'/g, '&quot;');
[11911] Fix | Delete
}
[11912] Fix | Delete
if (options.parseImgDimensions && width && height) {
[11913] Fix | Delete
globals.gDimensions[linkId] = {
[11914] Fix | Delete
width: width,
[11915] Fix | Delete
height: height
[11916] Fix | Delete
};
[11917] Fix | Delete
}
[11918] Fix | Delete
}
[11919] Fix | Delete
// Completely remove the definition from the text
[11920] Fix | Delete
return '';
[11921] Fix | Delete
};
[11922] Fix | Delete
[11923] Fix | Delete
// first we try to find base64 link references
[11924] Fix | Delete
text = text.replace(base64Regex, replaceFunc);
[11925] Fix | Delete
[11926] Fix | Delete
text = text.replace(regex, replaceFunc);
[11927] Fix | Delete
[11928] Fix | Delete
// attacklab: strip sentinel
[11929] Fix | Delete
text = text.replace(/¨0/, '');
[11930] Fix | Delete
[11931] Fix | Delete
return text;
[11932] Fix | Delete
});
[11933] Fix | Delete
[11934] Fix | Delete
showdown.subParser('tables', function (text, options, globals) {
[11935] Fix | Delete
'use strict';
[11936] Fix | Delete
[11937] Fix | Delete
if (!options.tables) {
[11938] Fix | Delete
return text;
[11939] Fix | Delete
}
[11940] Fix | Delete
[11941] Fix | Delete
var tableRgx = /^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm,
[11942] Fix | Delete
//singeColTblRgx = /^ {0,3}\|.+\|\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n(?: {0,3}\|.+\|\n)+(?:\n\n|¨0)/gm;
[11943] Fix | Delete
singeColTblRgx = /^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm;
[11944] Fix | Delete
[11945] Fix | Delete
function parseStyles (sLine) {
[11946] Fix | Delete
if (/^:[ \t]*--*$/.test(sLine)) {
[11947] Fix | Delete
return ' style="text-align:left;"';
[11948] Fix | Delete
} else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
[11949] Fix | Delete
return ' style="text-align:right;"';
[11950] Fix | Delete
} else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) {
[11951] Fix | Delete
return ' style="text-align:center;"';
[11952] Fix | Delete
} else {
[11953] Fix | Delete
return '';
[11954] Fix | Delete
}
[11955] Fix | Delete
}
[11956] Fix | Delete
[11957] Fix | Delete
function parseHeaders (header, style) {
[11958] Fix | Delete
var id = '';
[11959] Fix | Delete
header = header.trim();
[11960] Fix | Delete
// support both tablesHeaderId and tableHeaderId due to error in documentation so we don't break backwards compatibility
[11961] Fix | Delete
if (options.tablesHeaderId || options.tableHeaderId) {
[11962] Fix | Delete
id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"';
[11963] Fix | Delete
}
[11964] Fix | Delete
header = showdown.subParser('spanGamut')(header, options, globals);
[11965] Fix | Delete
[11966] Fix | Delete
return '<th' + id + style + '>' + header + '</th>\n';
[11967] Fix | Delete
}
[11968] Fix | Delete
[11969] Fix | Delete
function parseCells (cell, style) {
[11970] Fix | Delete
var subText = showdown.subParser('spanGamut')(cell, options, globals);
[11971] Fix | Delete
return '<td' + style + '>' + subText + '</td>\n';
[11972] Fix | Delete
}
[11973] Fix | Delete
[11974] Fix | Delete
function buildTable (headers, cells) {
[11975] Fix | Delete
var tb = '<table>\n<thead>\n<tr>\n',
[11976] Fix | Delete
tblLgn = headers.length;
[11977] Fix | Delete
[11978] Fix | Delete
for (var i = 0; i < tblLgn; ++i) {
[11979] Fix | Delete
tb += headers[i];
[11980] Fix | Delete
}
[11981] Fix | Delete
tb += '</tr>\n</thead>\n<tbody>\n';
[11982] Fix | Delete
[11983] Fix | Delete
for (i = 0; i < cells.length; ++i) {
[11984] Fix | Delete
tb += '<tr>\n';
[11985] Fix | Delete
for (var ii = 0; ii < tblLgn; ++ii) {
[11986] Fix | Delete
tb += cells[i][ii];
[11987] Fix | Delete
}
[11988] Fix | Delete
tb += '</tr>\n';
[11989] Fix | Delete
}
[11990] Fix | Delete
tb += '</tbody>\n</table>\n';
[11991] Fix | Delete
return tb;
[11992] Fix | Delete
}
[11993] Fix | Delete
[11994] Fix | Delete
function parseTable (rawTable) {
[11995] Fix | Delete
var i, tableLines = rawTable.split('\n');
[11996] Fix | Delete
[11997] Fix | Delete
for (i = 0; i < tableLines.length; ++i) {
[11998] Fix | Delete
// strip wrong first and last column if wrapped tables are used
[11999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function