Male user:RiazACU/headlines.js

From Wikipedia

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
//<syntaxhighlight lang=javascript>
 
function autoEdHeadlines(str) { //MAIN FUNCTION describes list of fixes
 
// Remove bold from section headings
var loopcount = 0;
while( str.search(/^[=]{1,5}[^=\r\n]*'''[^=\r\n]*[=]{1,5}/gim) >= 0 && loopcount <= 10 ) { //'
str = str.replace(/(^[=]{1,5}[^=\r\n]*)'''([^=\r\n]*[=]{1,5})[\t ]*/gim, '$1$2'); //'
loopcount++;
}
 
// Remove trailing colon from section headings
str = str.replace(/(^[=]{1,5}[^=\r\n]*)[:]([\t ]*[=]{1,5})[\t ]*/gim, '$1$2');
 
// Correct caps in "আরও দেখুন" section
str = str.replace(/(==[\t ]*)আরো দেখুন([\t ]*==)/gi, "$1আরও দেখুন$2");
 
// Change common synonyms for "See also" to "See also", but only if "See also" doesn't exist
if( !str.match(/=[\t ]*See also[\t ]*=/gi) ) {
str = str.replace(/(==[\t ]*)(?:সম্পর্কিত বিষয়|সম্পর্কিত নিবন্ধ|অভ্যন্তরীণ সংযোগ|আরো দেখুন)([\t ]*==)/gi, "$1আরও দেখুন$2");
}
// Common synonyms for "বহিঃসংযোগ"
str = str.replace(/(==[\t ]*)(?:বহিসংযোগ?|বাহ্যিক লিঙ্কগুলি?|ওয়েব ?সংযোগ?|আভ্যন্তরীণ সংযোগ?)([\t ]*==)/gi, "$1বহিঃসংযোগ$2");
 
// Capitalization and/or plural of "References", "Sources", "Further reading"
str = str.replace(/(==[\t ]*)references([\t ]*==)/gi, "$সূত্র তালিকা$2");
str = str.replace(/(==[\t ]*)sources([\t ]*==)/gi, "$1সূত্র উন্নতি$2");
str = str.replace(/(==[\t ]*)further readings?([\t ]*==)/gi, "$1Further reading$2");
 
return str;
}
 
//</syntaxhighlight>