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

Content deleted Content added
add removeUnderscoresFromWikilinks() (publish.php)
fix edge cases in deleteDuplicateReferencesSection() (publish.php)
Line 195:
wikicode = this.deleteHeadingsWithTitle(wikicode, titleWithNamespaceAndSpaces);
wikicode = this.unlinkWikilinksToThisTitle(wikicode, titleWithNamespaceAndSpaces);
wikicode = this.boldArticleTitle(wikicode, titleWithNamespaceAndSpaces); // buggy
wikicode = this.capitalizeCOVID19(wikicode);
wikicode = this.removeBoldFromHeadings(wikicode);
Line 243 ⟶ 242:
// in wikilinks, underscores to spaces
// fix redundant wikilinks, e.g. [[Spotify|Spotify]]
wikicode = this.boldArticleTitle(wikicode, titleWithNamespaceAndSpaces); // buggy
wikicode = this.trimEmptyLines(wikicode);
wikicode = this.deleteMoreThanTwoEntersInARow(wikicode);
Line 653:
 
deleteDuplicateReferencesSection(wikicode) {
let matches = wikicode.match(/== ?References ?==/gi);
// TODO:
if ( matches.length > 1 ) {
// run regexes that are likely to delete the extra section
let attempt = wikicode.replace(
`== References ==
<!-- Inline citations added to your article will automatically display here. See en.wikipedia.org/wiki/WP:REFB for instructions on how to add citations. -->
{{reflist}}`
, '');
let matches2 = attempt.match(/== ?References ?==/gi);
if ( matches2.length === 1 ) {
wikicode = attempt.trim();
}
}
return wikicode;
}