Content deleted Content added
No edit summary |
No edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 45:
// Compress more whitespace
mytxt = mytxt.replace(/\|[\s]+/g, '|');
// Remove wikilinks to make patterns less complicated
mytxt = mytxt.replace(/\[\[[^\[\]\{\}]*\]\]/g, '');
// Add a leading and trailing newline to make pattern matches less complicated
mytxt = '\n' + mytxt + '\n';
Line 53 ⟶ 56:
// Now start extracting the parameters
var plist = []; var klist = {}; var loopcount = 0;
while( (mytxt.search(/[^{}]/gm) >= 0) && (loopcount <
var p = mytxt.match(/(\{\{\{[^{}\|]*\|?[^\{\}\|=]*\}\}\})/g);
if( p ) {
Line 70 ⟶ 73:
}
// Remove templates, parserfunctions, and other double brace expressions
mytxt = mytxt.replace(/([^\{])\{\{
mytxt = mytxt.replace(/\{\{
mytxt = mytxt.replace(/([^\{])\{\{(?:[\r\n]|[^{}]|\{\{[^{}]*\}\})*\}\}/gm, '$1');
mytxt = mytxt.replace(/\{\{(?:[\r\n]|[^{}]|\{\{[^{}]*\}\})*\}\}([^\}])/gm, '$1');
}
loopcount++;
}
if( mytxt.search(/[\{\}]/gm) >= 0 ) {
▲ mytxt = mytxt.replace(/([\{\}])/gm, '\n<!-- UNPROCESSED HERE -->$1');
alert('Did not finish processing: ' + mytxt);
} else {
Line 83 ⟶ 87:
var alphasort = confirm('Sort parameters alphabetically?');
// Sort
if(alphasort === true) {
plist.sort(function (a, b) {
aa = a.replace(/([^0-9])([0-9][^0-9]*)$/, '$10$2');
bb = b.replace(/([^0-9])([0-9][^0-9]*)$/, '$10$2');
return aa.toLowerCase().localeCompare(bb.toLowerCase()) });
} else {
plist = plist.sort(function(a,b) { return klist[a] - klist[b] } );
|