Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: blocks.js
text = globals.converter._dispatch('italicsAndBold.before', text, options, globals);
[4500] Fix | Delete
[4501] Fix | Delete
// it's faster to have 3 separate regexes for each case than have just one
[4502] Fix | Delete
// because of backtracing, in some cases, it could lead to an exponential effect
[4503] Fix | Delete
// called "catastrophic backtrace". Ominous!
[4504] Fix | Delete
[4505] Fix | Delete
function parseInside (txt, left, right) {
[4506] Fix | Delete
/*
[4507] Fix | Delete
if (options.simplifiedAutoLink) {
[4508] Fix | Delete
txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
[4509] Fix | Delete
}
[4510] Fix | Delete
*/
[4511] Fix | Delete
return left + txt + right;
[4512] Fix | Delete
}
[4513] Fix | Delete
[4514] Fix | Delete
// Parse underscores
[4515] Fix | Delete
if (options.literalMidWordUnderscores) {
[4516] Fix | Delete
text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
[4517] Fix | Delete
return parseInside (txt, '<strong><em>', '</em></strong>');
[4518] Fix | Delete
});
[4519] Fix | Delete
text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
[4520] Fix | Delete
return parseInside (txt, '<strong>', '</strong>');
[4521] Fix | Delete
});
[4522] Fix | Delete
text = text.replace(/\b_(\S[\s\S]*?)_\b/g, function (wm, txt) {
[4523] Fix | Delete
return parseInside (txt, '<em>', '</em>');
[4524] Fix | Delete
});
[4525] Fix | Delete
} else {
[4526] Fix | Delete
text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
[4527] Fix | Delete
return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
[4528] Fix | Delete
});
[4529] Fix | Delete
text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
[4530] Fix | Delete
return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
[4531] Fix | Delete
});
[4532] Fix | Delete
text = text.replace(/_([^\s_][\s\S]*?)_/g, function (wm, m) {
[4533] Fix | Delete
// !/^_[^_]/.test(m) - test if it doesn't start with __ (since it seems redundant, we removed it)
[4534] Fix | Delete
return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
[4535] Fix | Delete
});
[4536] Fix | Delete
}
[4537] Fix | Delete
[4538] Fix | Delete
// Now parse asterisks
[4539] Fix | Delete
if (options.literalMidWordAsterisks) {
[4540] Fix | Delete
text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]*?)\*\*\*\B(?!\*)/g, function (wm, lead, txt) {
[4541] Fix | Delete
return parseInside (txt, lead + '<strong><em>', '</em></strong>');
[4542] Fix | Delete
});
[4543] Fix | Delete
text = text.replace(/([^*]|^)\B\*\*(\S[\s\S]*?)\*\*\B(?!\*)/g, function (wm, lead, txt) {
[4544] Fix | Delete
return parseInside (txt, lead + '<strong>', '</strong>');
[4545] Fix | Delete
});
[4546] Fix | Delete
text = text.replace(/([^*]|^)\B\*(\S[\s\S]*?)\*\B(?!\*)/g, function (wm, lead, txt) {
[4547] Fix | Delete
return parseInside (txt, lead + '<em>', '</em>');
[4548] Fix | Delete
});
[4549] Fix | Delete
} else {
[4550] Fix | Delete
text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
[4551] Fix | Delete
return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
[4552] Fix | Delete
});
[4553] Fix | Delete
text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
[4554] Fix | Delete
return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
[4555] Fix | Delete
});
[4556] Fix | Delete
text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function (wm, m) {
[4557] Fix | Delete
// !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it)
[4558] Fix | Delete
return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
[4559] Fix | Delete
});
[4560] Fix | Delete
}
[4561] Fix | Delete
[4562] Fix | Delete
[4563] Fix | Delete
text = globals.converter._dispatch('italicsAndBold.after', text, options, globals);
[4564] Fix | Delete
return text;
[4565] Fix | Delete
});
[4566] Fix | Delete
[4567] Fix | Delete
/**
[4568] Fix | Delete
* Form HTML ordered (numbered) and unordered (bulleted) lists.
[4569] Fix | Delete
*/
[4570] Fix | Delete
showdown.subParser('lists', function (text, options, globals) {
[4571] Fix | Delete
'use strict';
[4572] Fix | Delete
[4573] Fix | Delete
/**
[4574] Fix | Delete
* Process the contents of a single ordered or unordered list, splitting it
[4575] Fix | Delete
* into individual list items.
[4576] Fix | Delete
* @param {string} listStr
[4577] Fix | Delete
* @param {boolean} trimTrailing
[4578] Fix | Delete
* @returns {string}
[4579] Fix | Delete
*/
[4580] Fix | Delete
function processListItems (listStr, trimTrailing) {
[4581] Fix | Delete
// The $g_list_level global keeps track of when we're inside a list.
[4582] Fix | Delete
// Each time we enter a list, we increment it; when we leave a list,
[4583] Fix | Delete
// we decrement. If it's zero, we're not in a list anymore.
[4584] Fix | Delete
//
[4585] Fix | Delete
// We do this because when we're not inside a list, we want to treat
[4586] Fix | Delete
// something like this:
[4587] Fix | Delete
//
[4588] Fix | Delete
// I recommend upgrading to version
[4589] Fix | Delete
// 8. Oops, now this line is treated
[4590] Fix | Delete
// as a sub-list.
[4591] Fix | Delete
//
[4592] Fix | Delete
// As a single paragraph, despite the fact that the second line starts
[4593] Fix | Delete
// with a digit-period-space sequence.
[4594] Fix | Delete
//
[4595] Fix | Delete
// Whereas when we're inside a list (or sub-list), that line will be
[4596] Fix | Delete
// treated as the start of a sub-list. What a kludge, huh? This is
[4597] Fix | Delete
// an aspect of Markdown's syntax that's hard to parse perfectly
[4598] Fix | Delete
// without resorting to mind-reading. Perhaps the solution is to
[4599] Fix | Delete
// change the syntax rules such that sub-lists must start with a
[4600] Fix | Delete
// starting cardinal number; e.g. "1." or "a.".
[4601] Fix | Delete
globals.gListLevel++;
[4602] Fix | Delete
[4603] Fix | Delete
// trim trailing blank lines:
[4604] Fix | Delete
listStr = listStr.replace(/\n{2,}$/, '\n');
[4605] Fix | Delete
[4606] Fix | Delete
// attacklab: add sentinel to emulate \z
[4607] Fix | Delete
listStr += '¨0';
[4608] Fix | Delete
[4609] Fix | Delete
var rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm,
[4610] Fix | Delete
isParagraphed = (/\n[ \t]*\n(?!¨0)/.test(listStr));
[4611] Fix | Delete
[4612] Fix | Delete
// Since version 1.5, nesting sublists requires 4 spaces (or 1 tab) indentation,
[4613] Fix | Delete
// which is a syntax breaking change
[4614] Fix | Delete
// activating this option reverts to old behavior
[4615] Fix | Delete
if (options.disableForced4SpacesIndentedSublists) {
[4616] Fix | Delete
rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm;
[4617] Fix | Delete
}
[4618] Fix | Delete
[4619] Fix | Delete
listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
[4620] Fix | Delete
checked = (checked && checked.trim() !== '');
[4621] Fix | Delete
[4622] Fix | Delete
var item = showdown.subParser('outdent')(m4, options, globals),
[4623] Fix | Delete
bulletStyle = '';
[4624] Fix | Delete
[4625] Fix | Delete
// Support for github tasklists
[4626] Fix | Delete
if (taskbtn && options.tasklists) {
[4627] Fix | Delete
bulletStyle = ' class="task-list-item" style="list-style-type: none;"';
[4628] Fix | Delete
item = item.replace(/^[ \t]*\[(x|X| )?]/m, function () {
[4629] Fix | Delete
var otp = '<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';
[4630] Fix | Delete
if (checked) {
[4631] Fix | Delete
otp += ' checked';
[4632] Fix | Delete
}
[4633] Fix | Delete
otp += '>';
[4634] Fix | Delete
return otp;
[4635] Fix | Delete
});
[4636] Fix | Delete
}
[4637] Fix | Delete
[4638] Fix | Delete
// ISSUE #312
[4639] Fix | Delete
// This input: - - - a
[4640] Fix | Delete
// causes trouble to the parser, since it interprets it as:
[4641] Fix | Delete
// <ul><li><li><li>a</li></li></li></ul>
[4642] Fix | Delete
// instead of:
[4643] Fix | Delete
// <ul><li>- - a</li></ul>
[4644] Fix | Delete
// So, to prevent it, we will put a marker (¨A)in the beginning of the line
[4645] Fix | Delete
// Kind of hackish/monkey patching, but seems more effective than overcomplicating the list parser
[4646] Fix | Delete
item = item.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g, function (wm2) {
[4647] Fix | Delete
return '¨A' + wm2;
[4648] Fix | Delete
});
[4649] Fix | Delete
[4650] Fix | Delete
// m1 - Leading line or
[4651] Fix | Delete
// Has a double return (multi paragraph) or
[4652] Fix | Delete
// Has sublist
[4653] Fix | Delete
if (m1 || (item.search(/\n{2,}/) > -1)) {
[4654] Fix | Delete
item = showdown.subParser('githubCodeBlocks')(item, options, globals);
[4655] Fix | Delete
item = showdown.subParser('blockGamut')(item, options, globals);
[4656] Fix | Delete
} else {
[4657] Fix | Delete
// Recursion for sub-lists:
[4658] Fix | Delete
item = showdown.subParser('lists')(item, options, globals);
[4659] Fix | Delete
item = item.replace(/\n$/, ''); // chomp(item)
[4660] Fix | Delete
item = showdown.subParser('hashHTMLBlocks')(item, options, globals);
[4661] Fix | Delete
[4662] Fix | Delete
// Colapse double linebreaks
[4663] Fix | Delete
item = item.replace(/\n\n+/g, '\n\n');
[4664] Fix | Delete
if (isParagraphed) {
[4665] Fix | Delete
item = showdown.subParser('paragraphs')(item, options, globals);
[4666] Fix | Delete
} else {
[4667] Fix | Delete
item = showdown.subParser('spanGamut')(item, options, globals);
[4668] Fix | Delete
}
[4669] Fix | Delete
}
[4670] Fix | Delete
[4671] Fix | Delete
// now we need to remove the marker (¨A)
[4672] Fix | Delete
item = item.replace('¨A', '');
[4673] Fix | Delete
// we can finally wrap the line in list item tags
[4674] Fix | Delete
item = '<li' + bulletStyle + '>' + item + '</li>\n';
[4675] Fix | Delete
[4676] Fix | Delete
return item;
[4677] Fix | Delete
});
[4678] Fix | Delete
[4679] Fix | Delete
// attacklab: strip sentinel
[4680] Fix | Delete
listStr = listStr.replace(/¨0/g, '');
[4681] Fix | Delete
[4682] Fix | Delete
globals.gListLevel--;
[4683] Fix | Delete
[4684] Fix | Delete
if (trimTrailing) {
[4685] Fix | Delete
listStr = listStr.replace(/\s+$/, '');
[4686] Fix | Delete
}
[4687] Fix | Delete
[4688] Fix | Delete
return listStr;
[4689] Fix | Delete
}
[4690] Fix | Delete
[4691] Fix | Delete
function styleStartNumber (list, listType) {
[4692] Fix | Delete
// check if ol and starts by a number different than 1
[4693] Fix | Delete
if (listType === 'ol') {
[4694] Fix | Delete
var res = list.match(/^ *(\d+)\./);
[4695] Fix | Delete
if (res && res[1] !== '1') {
[4696] Fix | Delete
return ' start="' + res[1] + '"';
[4697] Fix | Delete
}
[4698] Fix | Delete
}
[4699] Fix | Delete
return '';
[4700] Fix | Delete
}
[4701] Fix | Delete
[4702] Fix | Delete
/**
[4703] Fix | Delete
* Check and parse consecutive lists (better fix for issue #142)
[4704] Fix | Delete
* @param {string} list
[4705] Fix | Delete
* @param {string} listType
[4706] Fix | Delete
* @param {boolean} trimTrailing
[4707] Fix | Delete
* @returns {string}
[4708] Fix | Delete
*/
[4709] Fix | Delete
function parseConsecutiveLists (list, listType, trimTrailing) {
[4710] Fix | Delete
// check if we caught 2 or more consecutive lists by mistake
[4711] Fix | Delete
// we use the counterRgx, meaning if listType is UL we look for OL and vice versa
[4712] Fix | Delete
var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm,
[4713] Fix | Delete
ulRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?[*+-][ \t]/gm : /^ {0,3}[*+-][ \t]/gm,
[4714] Fix | Delete
counterRxg = (listType === 'ul') ? olRgx : ulRgx,
[4715] Fix | Delete
result = '';
[4716] Fix | Delete
[4717] Fix | Delete
if (list.search(counterRxg) !== -1) {
[4718] Fix | Delete
(function parseCL (txt) {
[4719] Fix | Delete
var pos = txt.search(counterRxg),
[4720] Fix | Delete
style = styleStartNumber(list, listType);
[4721] Fix | Delete
if (pos !== -1) {
[4722] Fix | Delete
// slice
[4723] Fix | Delete
result += '\n\n<' + listType + style + '>\n' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n';
[4724] Fix | Delete
[4725] Fix | Delete
// invert counterType and listType
[4726] Fix | Delete
listType = (listType === 'ul') ? 'ol' : 'ul';
[4727] Fix | Delete
counterRxg = (listType === 'ul') ? olRgx : ulRgx;
[4728] Fix | Delete
[4729] Fix | Delete
//recurse
[4730] Fix | Delete
parseCL(txt.slice(pos));
[4731] Fix | Delete
} else {
[4732] Fix | Delete
result += '\n\n<' + listType + style + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
[4733] Fix | Delete
}
[4734] Fix | Delete
})(list);
[4735] Fix | Delete
} else {
[4736] Fix | Delete
var style = styleStartNumber(list, listType);
[4737] Fix | Delete
result = '\n\n<' + listType + style + '>\n' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n';
[4738] Fix | Delete
}
[4739] Fix | Delete
[4740] Fix | Delete
return result;
[4741] Fix | Delete
}
[4742] Fix | Delete
[4743] Fix | Delete
/** Start of list parsing **/
[4744] Fix | Delete
text = globals.converter._dispatch('lists.before', text, options, globals);
[4745] Fix | Delete
// add sentinel to hack around khtml/safari bug:
[4746] Fix | Delete
// http://bugs.webkit.org/show_bug.cgi?id=11231
[4747] Fix | Delete
text += '¨0';
[4748] Fix | Delete
[4749] Fix | Delete
if (globals.gListLevel) {
[4750] Fix | Delete
text = text.replace(/^(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
[4751] Fix | Delete
function (wholeMatch, list, m2) {
[4752] Fix | Delete
var listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
[4753] Fix | Delete
return parseConsecutiveLists(list, listType, true);
[4754] Fix | Delete
}
[4755] Fix | Delete
);
[4756] Fix | Delete
} else {
[4757] Fix | Delete
text = text.replace(/(\n\n|^\n?)(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
[4758] Fix | Delete
function (wholeMatch, m1, list, m3) {
[4759] Fix | Delete
var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
[4760] Fix | Delete
return parseConsecutiveLists(list, listType, false);
[4761] Fix | Delete
}
[4762] Fix | Delete
);
[4763] Fix | Delete
}
[4764] Fix | Delete
[4765] Fix | Delete
// strip sentinel
[4766] Fix | Delete
text = text.replace(/¨0/, '');
[4767] Fix | Delete
text = globals.converter._dispatch('lists.after', text, options, globals);
[4768] Fix | Delete
return text;
[4769] Fix | Delete
});
[4770] Fix | Delete
[4771] Fix | Delete
/**
[4772] Fix | Delete
* Parse metadata at the top of the document
[4773] Fix | Delete
*/
[4774] Fix | Delete
showdown.subParser('metadata', function (text, options, globals) {
[4775] Fix | Delete
'use strict';
[4776] Fix | Delete
[4777] Fix | Delete
if (!options.metadata) {
[4778] Fix | Delete
return text;
[4779] Fix | Delete
}
[4780] Fix | Delete
[4781] Fix | Delete
text = globals.converter._dispatch('metadata.before', text, options, globals);
[4782] Fix | Delete
[4783] Fix | Delete
function parseMetadataContents (content) {
[4784] Fix | Delete
// raw is raw so it's not changed in any way
[4785] Fix | Delete
globals.metadata.raw = content;
[4786] Fix | Delete
[4787] Fix | Delete
// escape chars forbidden in html attributes
[4788] Fix | Delete
// double quotes
[4789] Fix | Delete
content = content
[4790] Fix | Delete
// ampersand first
[4791] Fix | Delete
.replace(/&/g, '&amp;')
[4792] Fix | Delete
// double quotes
[4793] Fix | Delete
.replace(/"/g, '&quot;');
[4794] Fix | Delete
[4795] Fix | Delete
content = content.replace(/\n {4}/g, ' ');
[4796] Fix | Delete
content.replace(/^([\S ]+): +([\s\S]+?)$/gm, function (wm, key, value) {
[4797] Fix | Delete
globals.metadata.parsed[key] = value;
[4798] Fix | Delete
return '';
[4799] Fix | Delete
});
[4800] Fix | Delete
}
[4801] Fix | Delete
[4802] Fix | Delete
text = text.replace(/^\s*«««+(\S*?)\n([\s\S]+?)\n»»»+\n/, function (wholematch, format, content) {
[4803] Fix | Delete
parseMetadataContents(content);
[4804] Fix | Delete
return '¨M';
[4805] Fix | Delete
});
[4806] Fix | Delete
[4807] Fix | Delete
text = text.replace(/^\s*---+(\S*?)\n([\s\S]+?)\n---+\n/, function (wholematch, format, content) {
[4808] Fix | Delete
if (format) {
[4809] Fix | Delete
globals.metadata.format = format;
[4810] Fix | Delete
}
[4811] Fix | Delete
parseMetadataContents(content);
[4812] Fix | Delete
return '¨M';
[4813] Fix | Delete
});
[4814] Fix | Delete
[4815] Fix | Delete
text = text.replace(/¨M/g, '');
[4816] Fix | Delete
[4817] Fix | Delete
text = globals.converter._dispatch('metadata.after', text, options, globals);
[4818] Fix | Delete
return text;
[4819] Fix | Delete
});
[4820] Fix | Delete
[4821] Fix | Delete
/**
[4822] Fix | Delete
* Remove one level of line-leading tabs or spaces
[4823] Fix | Delete
*/
[4824] Fix | Delete
showdown.subParser('outdent', function (text, options, globals) {
[4825] Fix | Delete
'use strict';
[4826] Fix | Delete
text = globals.converter._dispatch('outdent.before', text, options, globals);
[4827] Fix | Delete
[4828] Fix | Delete
// attacklab: hack around Konqueror 3.5.4 bug:
[4829] Fix | Delete
// "----------bug".replace(/^-/g,"") == "bug"
[4830] Fix | Delete
text = text.replace(/^(\t|[ ]{1,4})/gm, '¨0'); // attacklab: g_tab_width
[4831] Fix | Delete
[4832] Fix | Delete
// attacklab: clean up hack
[4833] Fix | Delete
text = text.replace(/¨0/g, '');
[4834] Fix | Delete
[4835] Fix | Delete
text = globals.converter._dispatch('outdent.after', text, options, globals);
[4836] Fix | Delete
return text;
[4837] Fix | Delete
});
[4838] Fix | Delete
[4839] Fix | Delete
/**
[4840] Fix | Delete
*
[4841] Fix | Delete
*/
[4842] Fix | Delete
showdown.subParser('paragraphs', function (text, options, globals) {
[4843] Fix | Delete
'use strict';
[4844] Fix | Delete
[4845] Fix | Delete
text = globals.converter._dispatch('paragraphs.before', text, options, globals);
[4846] Fix | Delete
// Strip leading and trailing lines:
[4847] Fix | Delete
text = text.replace(/^\n+/g, '');
[4848] Fix | Delete
text = text.replace(/\n+$/g, '');
[4849] Fix | Delete
[4850] Fix | Delete
var grafs = text.split(/\n{2,}/g),
[4851] Fix | Delete
grafsOut = [],
[4852] Fix | Delete
end = grafs.length; // Wrap <p> tags
[4853] Fix | Delete
[4854] Fix | Delete
for (var i = 0; i < end; i++) {
[4855] Fix | Delete
var str = grafs[i];
[4856] Fix | Delete
// if this is an HTML marker, copy it
[4857] Fix | Delete
if (str.search(/¨(K|G)(\d+)\1/g) >= 0) {
[4858] Fix | Delete
grafsOut.push(str);
[4859] Fix | Delete
[4860] Fix | Delete
// test for presence of characters to prevent empty lines being parsed
[4861] Fix | Delete
// as paragraphs (resulting in undesired extra empty paragraphs)
[4862] Fix | Delete
} else if (str.search(/\S/) >= 0) {
[4863] Fix | Delete
str = showdown.subParser('spanGamut')(str, options, globals);
[4864] Fix | Delete
str = str.replace(/^([ \t]*)/g, '<p>');
[4865] Fix | Delete
str += '</p>';
[4866] Fix | Delete
grafsOut.push(str);
[4867] Fix | Delete
}
[4868] Fix | Delete
}
[4869] Fix | Delete
[4870] Fix | Delete
/** Unhashify HTML blocks */
[4871] Fix | Delete
end = grafsOut.length;
[4872] Fix | Delete
for (i = 0; i < end; i++) {
[4873] Fix | Delete
var blockText = '',
[4874] Fix | Delete
grafsOutIt = grafsOut[i],
[4875] Fix | Delete
codeFlag = false;
[4876] Fix | Delete
// if this is a marker for an html block...
[4877] Fix | Delete
// use RegExp.test instead of string.search because of QML bug
[4878] Fix | Delete
while (/¨(K|G)(\d+)\1/.test(grafsOutIt)) {
[4879] Fix | Delete
var delim = RegExp.$1,
[4880] Fix | Delete
num = RegExp.$2;
[4881] Fix | Delete
[4882] Fix | Delete
if (delim === 'K') {
[4883] Fix | Delete
blockText = globals.gHtmlBlocks[num];
[4884] Fix | Delete
} else {
[4885] Fix | Delete
// we need to check if ghBlock is a false positive
[4886] Fix | Delete
if (codeFlag) {
[4887] Fix | Delete
// use encoded version of all text
[4888] Fix | Delete
blockText = showdown.subParser('encodeCode')(globals.ghCodeBlocks[num].text, options, globals);
[4889] Fix | Delete
} else {
[4890] Fix | Delete
blockText = globals.ghCodeBlocks[num].codeblock;
[4891] Fix | Delete
}
[4892] Fix | Delete
}
[4893] Fix | Delete
blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs
[4894] Fix | Delete
[4895] Fix | Delete
grafsOutIt = grafsOutIt.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/, blockText);
[4896] Fix | Delete
// Check if grafsOutIt is a pre->code
[4897] Fix | Delete
if (/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(grafsOutIt)) {
[4898] Fix | Delete
codeFlag = true;
[4899] Fix | Delete
}
[4900] Fix | Delete
}
[4901] Fix | Delete
grafsOut[i] = grafsOutIt;
[4902] Fix | Delete
}
[4903] Fix | Delete
text = grafsOut.join('\n');
[4904] Fix | Delete
// Strip leading and trailing lines:
[4905] Fix | Delete
text = text.replace(/^\n+/g, '');
[4906] Fix | Delete
text = text.replace(/\n+$/g, '');
[4907] Fix | Delete
return globals.converter._dispatch('paragraphs.after', text, options, globals);
[4908] Fix | Delete
});
[4909] Fix | Delete
[4910] Fix | Delete
/**
[4911] Fix | Delete
* Run extension
[4912] Fix | Delete
*/
[4913] Fix | Delete
showdown.subParser('runExtension', function (ext, text, options, globals) {
[4914] Fix | Delete
'use strict';
[4915] Fix | Delete
[4916] Fix | Delete
if (ext.filter) {
[4917] Fix | Delete
text = ext.filter(text, globals.converter, options);
[4918] Fix | Delete
[4919] Fix | Delete
} else if (ext.regex) {
[4920] Fix | Delete
// TODO remove this when old extension loading mechanism is deprecated
[4921] Fix | Delete
var re = ext.regex;
[4922] Fix | Delete
if (!(re instanceof RegExp)) {
[4923] Fix | Delete
re = new RegExp(re, 'g');
[4924] Fix | Delete
}
[4925] Fix | Delete
text = text.replace(re, ext.replace);
[4926] Fix | Delete
}
[4927] Fix | Delete
[4928] Fix | Delete
return text;
[4929] Fix | Delete
});
[4930] Fix | Delete
[4931] Fix | Delete
/**
[4932] Fix | Delete
* These are all the transformations that occur *within* block-level
[4933] Fix | Delete
* tags like paragraphs, headers, and list items.
[4934] Fix | Delete
*/
[4935] Fix | Delete
showdown.subParser('spanGamut', function (text, options, globals) {
[4936] Fix | Delete
'use strict';
[4937] Fix | Delete
[4938] Fix | Delete
text = globals.converter._dispatch('spanGamut.before', text, options, globals);
[4939] Fix | Delete
text = showdown.subParser('codeSpans')(text, options, globals);
[4940] Fix | Delete
text = showdown.subParser('escapeSpecialCharsWithinTagAttributes')(text, options, globals);
[4941] Fix | Delete
text = showdown.subParser('encodeBackslashEscapes')(text, options, globals);
[4942] Fix | Delete
[4943] Fix | Delete
// Process anchor and image tags. Images must come first,
[4944] Fix | Delete
// because ![foo][f] looks like an anchor.
[4945] Fix | Delete
text = showdown.subParser('images')(text, options, globals);
[4946] Fix | Delete
text = showdown.subParser('anchors')(text, options, globals);
[4947] Fix | Delete
[4948] Fix | Delete
// Make links out of things like `<http://example.com/>`
[4949] Fix | Delete
// Must come after anchors, because you can use < and >
[4950] Fix | Delete
// delimiters in inline links like [this](<url>).
[4951] Fix | Delete
text = showdown.subParser('autoLinks')(text, options, globals);
[4952] Fix | Delete
text = showdown.subParser('simplifiedAutoLinks')(text, options, globals);
[4953] Fix | Delete
text = showdown.subParser('emoji')(text, options, globals);
[4954] Fix | Delete
text = showdown.subParser('underline')(text, options, globals);
[4955] Fix | Delete
text = showdown.subParser('italicsAndBold')(text, options, globals);
[4956] Fix | Delete
text = showdown.subParser('strikethrough')(text, options, globals);
[4957] Fix | Delete
text = showdown.subParser('ellipsis')(text, options, globals);
[4958] Fix | Delete
[4959] Fix | Delete
// we need to hash HTML tags inside spans
[4960] Fix | Delete
text = showdown.subParser('hashHTMLSpans')(text, options, globals);
[4961] Fix | Delete
[4962] Fix | Delete
// now we encode amps and angles
[4963] Fix | Delete
text = showdown.subParser('encodeAmpsAndAngles')(text, options, globals);
[4964] Fix | Delete
[4965] Fix | Delete
// Do hard breaks
[4966] Fix | Delete
if (options.simpleLineBreaks) {
[4967] Fix | Delete
// GFM style hard breaks
[4968] Fix | Delete
// only add line breaks if the text does not contain a block (special case for lists)
[4969] Fix | Delete
if (!/\n\n¨K/.test(text)) {
[4970] Fix | Delete
text = text.replace(/\n+/g, '<br />\n');
[4971] Fix | Delete
}
[4972] Fix | Delete
} else {
[4973] Fix | Delete
// Vanilla hard breaks
[4974] Fix | Delete
text = text.replace(/ +\n/g, '<br />\n');
[4975] Fix | Delete
}
[4976] Fix | Delete
[4977] Fix | Delete
text = globals.converter._dispatch('spanGamut.after', text, options, globals);
[4978] Fix | Delete
return text;
[4979] Fix | Delete
});
[4980] Fix | Delete
[4981] Fix | Delete
showdown.subParser('strikethrough', function (text, options, globals) {
[4982] Fix | Delete
'use strict';
[4983] Fix | Delete
[4984] Fix | Delete
function parseInside (txt) {
[4985] Fix | Delete
if (options.simplifiedAutoLink) {
[4986] Fix | Delete
txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
[4987] Fix | Delete
}
[4988] Fix | Delete
return '<del>' + txt + '</del>';
[4989] Fix | Delete
}
[4990] Fix | Delete
[4991] Fix | Delete
if (options.strikethrough) {
[4992] Fix | Delete
text = globals.converter._dispatch('strikethrough.before', text, options, globals);
[4993] Fix | Delete
text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return parseInside(txt); });
[4994] Fix | Delete
text = globals.converter._dispatch('strikethrough.after', text, options, globals);
[4995] Fix | Delete
}
[4996] Fix | Delete
[4997] Fix | Delete
return text;
[4998] Fix | Delete
});
[4999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function