Content deleted Content added
Waldyrious (talk | contribs) allow dashes and underscores in the parameter names |
m 1997kB moved page User:Waldir/formatcitations.js to User:Waldyrious/formatcitations.js: Automatically moved page while renaming the user "Waldir" to "Waldyrious" |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 3:
// Fill an array with one entry per each recognized citation template
// Note: the regex should be changed to allow parameter values that are themselves templates,
var originalTemplates = txt.value.match(/\{\{[Cc]it(ation|(ar|e) [a-z ]+) *\n? *\|[^}]+\}\}/g);▼
// e.g. {{cite book | author = John Doe | title = The Book | year = 1234 | ref = {{sfnRef|Doe (1234)}} | isbn = 0-12345-678-9 }}
// I got as far as this: /(\{\{[Cc]it(?:ation|(?:ar|e) [a-z ]+)\s*)(\|\s*[^=]+=\s*(?:\{\{)?.+(?:\}\})?\s*)+(\}\})/g
▲ var originalTemplates = txt.value.match(/\{\{[Cc]it(ation|(ar|e) [a-z ]+) *\n? *\|[^{}]+\}\}/g);
// Duplicate the array, for editing. We need to keep the original strings for the replacement step
var tweakedTemplates = originalTemplates.slice();
Line 62 ⟶ 65:
$(function () {
if(document.forms.editform) {
mw.loader.using( ['mediawiki.util'], function() {
mw.util.addPortletLink('p-cactions', 'javascript:formatCitations(false)', '{{}}', 'ca-formatcitations', 'Format citations: add whitespace', '-', ''); mw.util.addPortletLink('p-cactions', 'javascript:formatCitations(true)', '{{}}+', 'ca-formatcitations-vertical', 'Formats citations vertically', '-', '');
});
}
});
|