维基百科:AutoEd/headlines.js

//

 
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 "See also" section
str = str.replace(/(==[\t ]*)see also([\t ]*==)/gi, "$1See also$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 ]*)(?:related topics|related articles|internal links|also see)([\t ]*==)/gi, "$1See also$2");
}
// Common synonyms for "External links"
str = str.replace(/(==[\t ]*)(?:external links?|outside links?|web ?links?|exterior links?)([\t ]*==)/gi, "$1External links$2");
 
// Capitalization and/or plural of "References", "Sources", "Further reading"
str = str.replace(/(==[\t ]*)references([\t ]*==)/gi, "$1References$2");
str = str.replace(/(==[\t ]*)sources([\t ]*==)/gi, "$1Sources$2");
str = str.replace(/(==[\t ]*)further readings?([\t ]*==)/gi, "$1Further reading$2");
 
return str;
}
 
//