User:Novem Linguae/Scripts/DraftCleaner.js: Difference between revisions

Content deleted Content added
add fixHeadingsInAllCaps() (publish.php)
fix bug involving extra spaces in heading (publish.php)
Line 553:
fixHeadingsInAllCaps(wikicode) {
// create a concatenated string with the text from every heading
let matches = wikicode.matchAll(/== ?{0,}(.+) ?{0,}==/g);
let headingString = '';
for ( let match of matches ) {
Line 562:
if ( this._isUpperCase(headingString) ) {
// convert all headings to sentence case
let matches = wikicode.matchAll(/== ?{0,}(.+) ?{0,}==/g);
for ( let match of matches ) {
let matchRegex = this._escapeRegEx(match[1].trim());
matchRegex = new RegExp('== ?{0,}' + matchRegex + ' ?{0,}==', 'g');
let sentenceCase = this._toSentenceCase(match[1].trim());
wikicode = wikicode.replace(matchRegex, '== ' + sentenceCase + ' ==');