User:Connel MacKenzie/reformat.js

/* */

function comment(cmntText) { if (txt != oldtext) { if ( document.editform.wpSummary.value.search(cmntText) == -1 ) { if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", "; document.editform.wpSummary.value += cmntText; } } }

function formOf { oldtext = txt;

txt = txt.replace(/\# plural form of \[\[(.*)\]\]\./gi, "# "); txt = txt.replace(/\# plural of \[\[(.*)\]\]\./gi, "# "); txt = txt.replace(/\#plural of \[\[(.*)\]\]\./gi, "# "); txt = txt.replace(/\# plural form of \[\[(.*)\]\]/gi, "# "); txt = txt.replace(/\# plural of \[\[(.*)\]\]/gi, "# "); txt = txt.replace(/\[\[Category\:English plurals\]\]/gi, ""); txt = txt.replace(/\# third person form of \'\'to \[\[(.*)\]\]\'\'\./gi, "# "); txt = txt.replace(/\# third person form of \'\'to \[\[(.*)\]\]\'\'/gi, "# "); txt = txt.replace(/\# third person singular form of \'\'\'to \[\[(.*)\]\]\'\'\'\./gi, "# "); txt = txt.replace(/\# third person singular form of \'\'\'to \[\[(.*)\]\]\'\'\'/gi, "# "); txt = txt.replace(/\# third person singular of \'\'to \[\[(.*)\]\]\'\'\./gi, "# "); txt = txt.replace(/\# third person singular of \'\'to \[\[(.*)\]\]\'\'/gi, "# "); txt = txt.replace(/\#third person singular of \[\[(.*)\]\]\./gi, "# "); txt = txt.replace(/\#third person singular of \[\[(.*)\]\]/gi, "# "); txt = txt.replace(/\#third-person singular of \[\[(.*)\]\]\./gi, "# "); txt = txt.replace(/\#third-person singular of \[\[(.*)\]\]/gi, "# ");

comment("{form of}"); }

//ligatures ǆ, ǉ, ǌ function specialCharacters { oldtext = txt; txt = txt.replace(/ǌ/g, "nj"); txt = txt.replace(/ǆ/g, "dz"); txt = txt.replace(/ǉ/g, "lj"); // txt = txt.replace(/’/g, "'"); // txt = txt.replace(/–/g, "-"); // txt = txt.replace(/—/g, "-"); // txt = txt.replace(//g, "");

if (txt != oldtext) { if (prompt("Special characters?")) { comment("sp.chr"); } else { txt = oldtext; } } }

// Work-around an artifact: when I started on Wiktionary, little needed UTF-8 encoding; the few // entries that did need it, I could either safely skip, or cut-n-paste across several heterogenous // environments using regular URI encoding. As a result, my /todo lists are pretty much all // imported now, as URI-encoded gobbledygook. This is to work-around that (with the age-old practice // of using a work-around to work-around a previous work-around.) function decodeSomeUtf8 { txt = " " + document.editform.wpTextbox1.value; txt = txt.substr (1, txt.length-1); myoldtxt = txt;

var line, l ; oldtext = txt ; var newtxt = ""; // Find all items that start with "[http://". If anything else, then probably not my // mistake, and therefore, probably should not be "fixed." l = txt.split("[http://"); newtxt = l[0]; for (var i=1; (i < l.length) ; i++) { var line = l[i]; var chrat = line.search(/]/) ; if ( chrat == -1 ) { newtxt += "[http://" + line; } else { var thisurl= "[http://" + line.substring(0, chrat); newtxt += decodeURIComponent( thisurl ); newtxt += line.substring(chrat) ; } }  if (newtxt != oldtext) { if (prompt("Decode URL-encoded characters?")) { document.editform.wpTextbox1.value=newtxt ; comment("decoded URLs"); } else { newtxt = oldtext; } } }

//Try to remember how this stuff works in Javascript. // Parse lines into array. Search for ""...process from that line // until the next heading (any line starting with "=".) // For each line, if in the *Langname: translation... // then change it to *: translation... // and strip out // from that section.

function parseLines { if ( window.location.href.indexOf("&nottbc=") != -1 ) return; var line, l ; oldtext = txt ; var newtxt = ""; txt = txt.replace(/\{\{ttbc-top\}\}/g, "");

if ( txt.search(/\{\{checktrans/gi) == -1 ) return ; if ( txt.search(/\{\{ttbc\|/g) != -1 ) return ; l = txt.split("\n");

var ok = true;

for (var i=0; (i < l.length) ; i++) { line = l[i] ; var line2 = line ;

if ( ! ok ) if ( line.search(/^=/) != -1 ) ok = true;

if (ok) if (line.search(/\{\{checktrans/gi) != -1) { ok = false; line2 += "\n"; }

if ( ! ok ) { line2 = line2.replace(/\{\{top\}\}/g, ""); line2 = line2.replace(/\{\{mid\}\}/g, ""); line2 = line2.replace(/\{\{bottom\}\}/g, ""); }

if ( line.search(/^\* /) != -1 ) { line = "*" + line.substring(2); }

if ( ! ok ) { if ( line.search(/\{\{ttbc/) == -1 ) { if ( line.search(/^\*(.*?): /) != -1 ) { var chrat = line.search(/: /) ; if ( line.substring(1, chrat).search(/\:/g) == -1 ) { line2 = "*:" + line.substring(chrat+1) ; }       }      }    }

newtxt = newtxt + line2 + "\n" ; }

if ( prompt("Apply TTBC changes?") ) { txt = newtxt ; comment("ttbc"); } }

function topmidbot { var lline, line, l ; oldtext = txt ; var newtxt = "";

if ( txt.search(/\{\{top\}\}/gi) == -1 ) return ; l = txt.split("\n");

var ok = true; lline = "";

for (var i=0; (i < l.length) ; i++) { line = l[i] ;

if (line.search(/\{\{top\}\}/gi) != -1) { if (l[i-1].search(/\=\=\=/gi) == -1) { line = ""; l[i-1] = ""; }   }

line = line.replace(/\{\{top\}\}/gi, ""); line = line.replace(/\{\{mid\}\}/gi, ""); line = line.replace(/\{\{bottom\}\}/gi, "");

l[i] = line; } for (var i=0; (i < l.length) ; i++) { newtxt = newtxt + l[i] + "\n" ; }

txt = newtxt ; comment("{top/mid/bot}->trans"); }

/* The variables "oldtxt" and "oldtext" determine which summary comments are added, AND whether or not to click the "Show changes" button. "oldtxt" is for clicking, while "oldtext" is used section-by-section. */

function minorFormat { oldtext = txt; //note the regexp ?(onething|notherthing|otherthing) syntax that doesn't work as I thought txt = txt.replace(/\/gi, ""); //italics is  in wiki syntax txt = txt.replace(/\<\/i\>/gi, ""); //italics is  in wiki syntax txt = txt.replace(/\/gi, ""); //bold is  in wiki syntax txt = txt.replace(/\<\/b\>/gi, ""); //bold is  in wiki syntax // txt = txt.replace(/\/gi, "\n\n"); //break is  in wiki syntax // txt = txt.replace(/\<\/br\>/gi, "\n\n"); //break is  in wiki syntax txt = txt.replace(/\=\= /g, "=="); txt = txt.replace(/ \=\=/g, "=="); txt = txt.replace(/\{\{-en-\}\}/g, "==English=="); txt = txt.replace(/==\{\{en\}\}==/g, "==English=="); txt = txt.replace(/Morobashi/gi, "Morohashi"); // txt = txt.replace(/\'\'\[\[comparative\]\]\'\'/gi, ""); // txt = txt.replace(/\'\'\[\[superlative\]\]\'\'/gi, ""); // txt = txt.replace(/\[\[comparative\]\]/gi, ""); // txt = txt.replace(/\[\[superlative\]\]/gi, ""); // txt = txt.replace(/\'\'comparative\'\'/gi, ""); // txt = txt.replace(/\'\'superlative\'\'/gi, ""); txt = txt.replace(/\{\{top\}\}\</gi, "\n<"); txt = txt.replace(/\{\{mid\}\}\</gi, "\n<"); txt = txt.replace(/\{\{msg:/gi, "{{"); txt = txt.replace(/===\n\'\'\'(.*)\'\'\'\n#/gi, "===\n$1\n\n#"); txt = txt.replace(/===\n\{\{(.*)\}\}\n#/gi, "===\n{{$1}}\n\n#"); txt = txt.replace(/\[\[category:/gi, "[[Category:"); if (txt != oldtext) {    if (document.editform.wpSummary.value.search(/User:/g) == -1) {      if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", ";      document.editform.wpSummary.value += "[[User:Connel MacKenzie/Format|mfmt]]";    }  }  oldtext = txt;    txt = txt.replace(/\[\[wikipedia:en:/gi, "format";    }  } }

function genderFmt { oldtext = txt; //txt = txt.replace(/plural/gi, "plural"); // NOTE: this only "/gi" case insensitive search in this section - all others must be just "/g". txt = txt.replace(/ m/g, " "); // test this m txt = txt.replace(/m /g, " "); // test this m txt = txt.replace(/ f/g, " "); txt = txt.replace(/f /g, " "); txt = txt.replace(/ n/g, " "); txt = txt.replace(/n /g, " "); txt = txt.replace(/ c/g, " "); txt = txt.replace(/c /g, " "); txt = txt.replace(/ pl/g, " "); txt = txt.replace(/pl /g, " "); txt = txt.replace(/ s/g, " "); txt = txt.replace(/s /g, " "); txt = txt.replace(/m, f/g, ", "); txt = txt.replace(/\{\{mf\}\}/g, ", "); txt = txt.replace(/m pl/g, " "); txt = txt.replace(/f pl/g, " "); txt = txt.replace(/m plural/g, " "); txt = txt.replace(/f plural/g, " "); txt = txt.replace(/\(plural \[/gi, "(plural: ["); txt = txt.replace(/\(plural /gi, "(plural: "); txt = txt.replace(/, plural '/gi, " (plural: '"); //note: this requires human help  comment(""); }

// get all the templates replaced function headLevel { // improper heading levels txt = txt.replace(/===English===\n/gi, "==English==\n"); //Insert a blank line after "==English==" txt = txt.replace(/==English==\n=/gi, "==English==\n\n="); txt = txt.replace(/==English==\n\{/gi, "==English==\n\n\{");

oldtext = txt;

//deprecated templates txt = txt.replace(/\{\{-noun-\}\}/g, "===Noun==="); txt = txt.replace(/\{\{-verb-\}\}/g, "===Verb==="); txt = txt.replace(/\{\{-etym-\}\}/g, "===Etymology==="); txt = txt.replace(/\{\{-adj-\}\}/g, "===Adjective==="); txt = txt.replace(/\{\{-syn-\}\}/g, "===Synonyms===");

txt = txt.replace(/\{\{trans\}\}/g, "Translations");

//really far-off entries txt = txt.replace(/\nadjective\n/gi, "\n===Adjective===\n"); txt = txt.replace(/\nadverb\n/gi, "\n===Adverb===\n"); txt = txt.replace(/\nnoun\n/gi, "\n===Noun===\n"); txt = txt.replace(/\nverb\n/gi, "\n===Verb===\n"); txt = txt.replace(/\ntranslation\n/gi, "\n===Translations===\n"); txt = txt.replace(/\ntranslations\n/gi, "\n===Translations===\n"); txt = txt.replace(/\n\#\:translations\n/gi, "\n\n====Translations====\n"); //de-bold language names, wikify (appropriate ones will get dewikified next step) //txt = txt.replace(/\n\#\:\*(.*?)/g, "\n*\"); // txt = txt.replace(/\n\*(.*?)\:/g, "\n*\(1):"); //this was perhaps a bad idea. (See deWikify, below.)

//Acid-trip induced formatting of most Volapük entries txt = txt.replace(/===\[\[Volapük\]\] \[\[verb\]\]===/gi, "==Volapük==\n\n===Verb==="); txt = txt.replace(/===\[\[Volapük\]\] \[\[noun\]\]===/gi, "==Volapük==\n\n===Noun==="); txt = txt.replace(/===\[\[Volapük\]\] \[\[adverb\]\]===/gi, "==Volapük==\n\n===Adverb==="); txt = txt.replace(/===\[\[Volapük\]\] \[\[conjunction\]\]===/gi, "==Volapük==\n\n===Conjunction==="); txt = txt.replace(/===\[\[Volapük\]\] \[\[adjective\]\]===/gi, "==Volapük==\n\n===Adjective===");

//older stub format txt = txt.replace(/\*\[\[IPA\]\]: \/\/\n\*\[\[SAMPA\]\]: \/\/\n/gi, "\n");

//first, correct case txt = txt.replace(/==adjective==/gi, "==Adjective=="); txt = txt.replace(/==adjective form==/gi, "==Adjective=="); txt = txt.replace(/==adjective phrase==/gi, "==Adjective=="); txt = txt.replace(/==adjectivial phrase==/gi, "==Adjective=="); txt = txt.replace(/==\[\[adjective\]\]==/gi, "==Adjective=="); txt = txt.replace(/==adverb==/gi, "==Adverb=="); txt = txt.replace(/==adverbs==/gi, "==Adverb=="); txt = txt.replace(/==adverb phrase==/gi, "==Adverb=="); txt = txt.replace(/==adverbal phrase==/gi, "==Adverb=="); txt = txt.replace(/==adverbial noun==/gi, "==Adverb=="); txt = txt.replace(/==adverbial phrase==/gi, "==Adverb=="); txt = txt.replace(/==adverbial participle==/gi, "==Adverb=="); txt = txt.replace(/==\[\[adverb\]\]==/gi, "==Adverb=="); txt = txt.replace(/==antonym==/gi, "==Antonyms=="); txt = txt.replace(/==antonyms==/gi, "==Antonyms=="); txt = txt.replace(/==\[\[antonyms\]\]==/gi, "==Antonyms=="); txt = txt.replace(/==article==/gi, "==Article=="); txt = txt.replace(/==definite article==/gi, "==Article=="); txt = txt.replace(/==cardinal number==/gi, "==Cardinal number=="); txt = txt.replace(/==citations==/gi, "==Quotations=="); txt = txt.replace(/==number==/gi, "==Cardinal number=="); txt = txt.replace(/==conjunction==/gi, "==Conjunction=="); txt = txt.replace(/==borrowings==/gi, "==Derived terms=="); // txt = txt.replace(/==Descendants==/gi, "==Derived terms=="); txt = txt.replace(/==derived expresson==/gi, "==Derived terms=="); txt = txt.replace(/==derived expression==/gi, "==Derived terms=="); txt = txt.replace(/==\[\[derived expression\]\]==/gi, "==Derived terms=="); txt = txt.replace(/==derived expressions==/gi, "==Derived terms=="); txt = txt.replace(/==\[\[derived expressions\]\]==/gi, "==Derived terms=="); txt = txt.replace(/==derived term==/gi, "==Derived terms=="); txt = txt.replace(/==\[\[derived term\]\]==/gi, "==Derived terms=="); txt = txt.replace(/==derived terms==/gi, "==Derived terms=="); txt = txt.replace(/==\[\[derived terms\]\]==/gi, "==Derived terms=="); txt = txt.replace(/==derived word==/gi, "==Derived terms=="); txt = txt.replace(/==\[\[derived word\]\]==/gi, "==Derived terms=="); txt = txt.replace(/==derived words==/gi, "==Derived terms=="); txt = txt.replace(/==\[\[derived words\]\]==/gi, "==Derived terms=="); txt = txt.replace(/==idioms==/gi, "==Derived terms=="); //only true ~80% of the time: be careful txt = txt.replace(/==derivation==/gi, "==Etymology=="); txt = txt.replace(/==etymology==/gi, "==Etymology=="); txt = txt.replace(/==\[\[etymology\]\]==/gi, "==Etymology=="); txt = txt.replace(/==External link==\n/gi, "==External links==\n"); txt = txt.replace(/==External links==\n/gi, "==External links==\n"); txt = txt.replace(/==letter==\n/gi, "===Letter===\n"); txt = txt.replace(/==numeral==/gi, "==Number=="); txt = txt.replace(/==\[\[numeral\]\]==/gi, "==Number=="); txt = txt.replace(/==number==/gi, "==Number=="); txt = txt.replace(/==\[\[number\]\]==/gi, "==Number=="); txt = txt.replace(/==noun==/gi, "==Noun=="); txt = txt.replace(/==compound noun==/gi, "==Noun=="); txt = txt.replace(/==\[\[noun\]\]==/gi, "==Noun=="); txt = txt.replace(/==noun form==/gi, "==Noun=="); txt = txt.replace(/==\[\[noun form\]\]==/gi, "==Noun=="); txt = txt.replace(/==noun phrase==/gi, "==Noun=="); txt = txt.replace(/==\[\[noun phrase\]\]==/gi, "==Noun=="); txt = txt.replace(/==(\[*)nominal phrase(\]*)==/gi, "==Noun=="); txt = txt.replace(/==phrase==/gi, "==Phrase=="); txt = txt.replace(/==\[\[phrase\]\]==/gi, "==Phrase=="); txt = txt.replace(/==verbal phrase==/gi, "==Phrase=="); txt = txt.replace(/==\[\[verbal phrase\]\]==/gi, "==Phrase=="); txt = txt.replace(/==pronunciation==/gi, "==Pronunciation=="); txt = txt.replace(/==\[\[pronunciation\]\]==/gi, "==Pronunciation=="); txt = txt.replace(/==proper name==/gi, "==Proper noun=="); txt = txt.replace(/==\[\[proper name\]\]==/gi, "==Proper noun=="); txt = txt.replace(/==proper noun==/gi, "==Proper noun=="); txt = txt.replace(/==\[\[proper noun\]\]==/gi, "==Proper noun=="); txt = txt.replace(/==pronoun==/gi, "==Pronoun=="); txt = txt.replace(/==\[\[pronoun\]\]==/gi, "==Pronoun=="); txt = txt.replace(/==quotation==/gi, "==Quotations=="); txt = txt.replace(/==\[\[quotation\]\]==/gi, "==Quotations=="); txt = txt.replace(/==quotations==/gi, "==Quotations=="); txt = txt.replace(/==\[\[quotations\]\]==/gi, "==Quotations=="); txt = txt.replace(/==citation==/gi, "==Quotations=="); txt = txt.replace(/==\[\[citation\]\]==/gi, "==Quotations=="); txt = txt.replace(/==citations==/gi, "==Quotations=="); txt = txt.replace(/==\[\[citations\]\]==/gi, "==Quotations=="); txt = txt.replace(/==related words==/gi, "==Related terms=="); txt = txt.replace(/==\[\[related words\]\]==/gi, "==Related terms=="); txt = txt.replace(/==related term==/gi, "==Related terms=="); txt = txt.replace(/==\[\[related term\]\]==/gi, "==Related terms=="); txt = txt.replace(/==related terms==/gi, "==Related terms=="); txt = txt.replace(/==\[\[related terms\]\]==/gi, "==Related terms=="); txt = txt.replace(/==compare with==/gi, "==See also=="); txt = txt.replace(/==other forms==/gi, "==See also=="); txt = txt.replace(/==see also==/gi, "==See also=="); txt = txt.replace(/==\[\[see also\]\]==/gi, "==See also=="); txt = txt.replace(/==symbol==/gi, "==Symbol=="); txt = txt.replace(/==\[\[symbol\]\]==/gi, "==Symbol=="); txt = txt.replace(/==symbols==/gi, "==Symbol=="); txt = txt.replace(/==\[\[symbols\]\]==/gi, "==Symbol=="); txt = txt.replace(/==synonyms==/gi, "==Synonyms=="); txt = txt.replace(/==\[\[synonyms\]\]==/gi, "==Synonyms=="); txt = txt.replace(/==synonym==/gi, "==Synonyms=="); txt = txt.replace(/==\[\[synonym\]\]==/gi, "==Synonyms=="); txt = txt.replace(/==translation==/gi, "==Translations=="); txt = txt.replace(/==\[\[translation\]\]==/gi, "==Translations=="); txt = txt.replace(/==translations==/gi, "==Translations=="); txt = txt.replace(/==\[\[translations\]\]==/gi, "==Translations=="); txt = txt.replace(/==\[\[Translation\]\]s==/gi, "==Translations=="); txt = txt.replace(/==note==/gi, "==Usage notes=="); txt = txt.replace(/==\[\[note\]\]==/gi, "==Usage notes=="); txt = txt.replace(/==phrase==/gi, "==Phrase=="); txt = txt.replace(/==expression==/gi, "==Phrase=="); txt = txt.replace(/==notes==/gi, "==Usage notes=="); txt = txt.replace(/==\[\[notes\]\]==/gi, "==Usage notes=="); txt = txt.replace(/==\[\[usage note\]\]==/gi, "==Usage notes=="); txt = txt.replace(/==usage==/gi, "==Usage notes=="); txt = txt.replace(/==\[\[usage\]\]==/gi, "==Usage notes=="); txt = txt.replace(/==\[\[usage notes\]\]==/gi, "==Usage notes=="); txt = txt.replace(/==usages==/gi, "==Usage notes=="); txt = txt.replace(/==\[\[usages\]\]==/gi, "==Usage notes=="); txt = txt.replace(/==usage note==/gi, "==Usage notes=="); txt = txt.replace(/==usage notes==/gi, "==Usage notes=="); txt = txt.replace(/==\[\[intransitive verb\]\]==/gi, "==Verb=="); txt = txt.replace(/==verb==/gi, "==Verb=="); txt = txt.replace(/==\[\[verb\]\]==/gi, "==Verb=="); txt = txt.replace(/==verb form==/gi, "==Verb=="); txt = txt.replace(/==\[\[verb form\]\]==/gi, "==Verb=="); //Ironically, all these spelling variations have been spotted in Wiktionary... txt = txt.replace(/==forms and variants==/gi, "==Alternative forms=="); txt = txt.replace(/==other form==/gi, "==Alternative forms=="); txt = txt.replace(/==other forms==/gi, "==Alternative forms=="); txt = txt.replace(/==variant form==/gi, "==Alternative forms=="); txt = txt.replace(/==variant forms==/gi, "==Alternative forms=="); txt = txt.replace(/==alternate form==/gi, "==Alternative forms=="); txt = txt.replace(/==alternate forms==/gi, "==Alternative forms=="); txt = txt.replace(/==alternative form==/gi, "==Alternative forms=="); txt = txt.replace(/==alternative forms==/gi, "==Alternative forms=="); //Ironically, all these spelling variations have been spotted in Wiktionary... txt = txt.replace(/==alternate spelling==/gi, "==Alternative spellings=="); txt = txt.replace(/==alternate spellings==/gi, "==Alternative spellings=="); txt = txt.replace(/==alternative spelling==/gi, "==Alternative spellings=="); txt = txt.replace(/==other spellings==/gi, "==Alternative spellings=="); txt = txt.replace(/==spelling variant==/gi, "==Alternative spellings=="); txt = txt.replace(/==spelling variants==/gi, "==Alternative spellings=="); txt = txt.replace(/==spelling variation==/gi, "==Alternative spellings=="); txt = txt.replace(/==spelling variations==/gi, "==Alternative spellings=="); txt = txt.replace(/==spellings==/gi, "==Alternative spellings=="); txt = txt.replace(/==variant==/gi, "==Alternative spellings=="); txt = txt.replace(/==\[\[variant\]\]==/gi, "==Alternative spellings=="); txt = txt.replace(/==variant spelling==/gi, "==Alternative spellings=="); txt = txt.replace(/==variant spellings==/gi, "==Alternative spellings=="); txt = txt.replace(/==variants==/gi, "==Alternative spellings=="); txt = txt.replace(/==variation==/gi, "==Alternative spellings=="); txt = txt.replace(/==variations==/gi, "==Alternative spellings=="); txt = txt.replace(/==varieties==/gi, "==Alternative spellings=="); txt = txt.replace(/==typographic variants==/gi, "==Alternative spellings=="); txt = txt.replace(/==variant spelling==/gi, "==Alternative spellings=="); txt = txt.replace(/==variant spellings==/gi, "==Alternative spellings=="); txt = txt.replace(/==\[\[attestation\]\]==/gi, "==References=="); txt = txt.replace(/==attestation==/gi, "==References=="); txt = txt.replace(/==attestations==/gi, "==References=="); txt = txt.replace(/==references==/gi, "==References=="); txt = txt.replace(/==reference==/gi, "==References=="); txt = txt.replace(/==refrences==/gi, "==References=="); txt = txt.replace(/==sources==/gi, "==References=="); txt = txt.replace(/==source==/gi, "==References=="); //then correct levels txt = txt.replace(/==Adjective==\n/gi, "===Adjective===\n"); txt = txt.replace(/==Adverb==\n/gi, "===Adverb===\n"); txt = txt.replace(/==Derived terms==\n/gi, "===Derived terms===\n"); txt = txt.replace(/==Etymology==\n/gi, "===Etymology===\n"); txt = txt.replace(/==External links==\n/gi, "===External links===\n"); txt = txt.replace(/==Noun==\n/gi, "===Noun===\n"); txt = txt.replace(/==phrase==\n/gi, "===Phrase===\n"); txt = txt.replace(/==Pronunciation==\n/gi, "===Pronunciation===\n"); txt = txt.replace(/==See also==\n/gi, "===See also===\n"); txt = txt.replace(/==Related terms==\n/gi, "===Related terms===\n"); txt = txt.replace(/==References==\n/gi, "===References===\n"); txt = txt.replace(/==Symbol==\n/gi, "===Symbol===\n"); txt = txt.replace(/==Symbols==\n/gi, "===Symbol===\n"); txt = txt.replace(/==Synonyms==\n/gi, "===Synonyms===\n"); txt = txt.replace(/==Translation==\n/gi, "====Translations====\n"); txt = txt.replace(/==Translations==\n/gi, "====Translations====\n"); txt = txt.replace(/==Usage notes==\n/gi, "===Usage notes===\n"); txt = txt.replace(/==Verb==\n/gi, "===Verb===\n"); txt = txt.replace(/\#\*\ \[\[Synonym\]\]s\n/gi, "===Synonyms===\n"); txt = txt.replace(/\#\*\ Synonyms\n/gi, "===Synonyms===\n"); //next line is controvercial? - Not. txt = txt.replace(/====Alternative spellings====\n/g, "===Alternative spellings===\n"); txt = txt.replace(/==Alternative spellings==\n/g, "===Alternative spellings===\n"); txt = txt.replace(/===Alternative spellings===\n\[/g, "===Alternative spellings===\n* ["); txt = txt.replace(/====Alternative forms====\n/g, "===Alternative forms===\n"); txt = txt.replace(/==Alternative forms==\n/g, "===Alternative forms===\n"); txt = txt.replace(/===Alternative forms===\n\[/g, "===Alternative forms===\n* ["); //todo: Ensure all headers are in Sentence case, not in Title Case. <-- BAH! Go after valid headers only. Leave all others on exception "todo2" list. comment("===Hdr==="); }

function langHdrs { oldtext = txt; txt = txt.replace(/===icelandic===\n/gi, "==Icelandic==\n"); txt = txt.replace(/===german===\n/gi, "==German==\n"); txt = txt.replace(/===french===\n/gi, "==French==\n"); txt = txt.replace(/===indonesian===\n/gi, "==Indonesian==\n"); txt = txt.replace(/===interlingua===\n/gi, "==Interlingua==\n"); txt = txt.replace(/===\[\[interlingua\]\]===\n/gi, "==Interlingua==\n"); txt = txt.replace(/===italian===\n/gi, "==Italian==\n"); txt = txt.replace(/===latin===\n/gi, "==Latin==\n"); txt = txt.replace(/===portuguese===\n/gi, "==Portuguese==\n"); txt = txt.replace(/===novial===\n/gi, "==Novial==\n"); txt = txt.replace(/===romanica===\n/gi, "==Romanica==\n"); txt = txt.replace(/===\[\[romanica\]\]===\n/gi, "==Romanica==\n"); txt = txt.replace(/===spanish===\n/gi, "==Spanish==\n"); txt = txt.replace(/===slovak===\n/gi, "==Slovak==\n"); txt = txt.replace(/==volapuk==/gi, "==Volapük=="); txt = txt.replace(/==\[\[volapuk\]\]==/gi, "==Volapük=="); txt = txt.replace(/==volapük==/gi, "==Volapük=="); txt = txt.replace(/==\[\[volapük\]\]==/gi, "==Volapük=="); txt = txt.replace(/==volapük word==/gi, "==Volapük=="); txt = txt.replace(/==\[\[volapük\]\] word==/gi, "==Volapük=="); txt = txt.replace(/===\[\[volapük\]\]===\n/gi, "==Volapük==\n"); txt = txt.replace(/===welsh===\n/gi, "==Welsh==\n"); txt = txt.replace(/===\[\[Chickasaw\]\]===\n/gi, "==Chickasaw==\n"); txt = txt.replace(/===Meanings===\n/gi, ""); comment("==Lang=="); }

// do not do generic code here! Only sway two letter templates that *are* language names for translations // TODO: A smarter person would have list="af,am,an,ar,az,be..." function langSubsts { oldtext = txt; txt = txt.replace(/\{\{en\}\}/g, ""); txt = txt.replace(/\{\{af\}\}/g, ""); txt = txt.replace(/\{\{am\}\}/g, ""); txt = txt.replace(/\{\{an\}\}/g, ""); txt = txt.replace(/\{\{ar\}\}/g, ""); txt = txt.replace(/\{\{az\}\}/g, ""); txt = txt.replace(/\{\{be\}\}/g, ""); txt = txt.replace(/\{\{bg\}\}/g, ""); txt = txt.replace(/\{\{bh\}\}/g, ""); txt = txt.replace(/\{\{br\}\}/g, ""); txt = txt.replace(/\{\{bs\}\}/g, ""); txt = txt.replace(/\{\{ca\}\}/g, ""); txt = txt.replace(/\{\{ch\}\}/g, ""); txt = txt.replace(/\{\{cn\}\}/g, ""); txt = txt.replace(/\{\{cr\}\}/g, ""); txt = txt.replace(/\{\{cs\}\}/g, ""); txt = txt.replace(/\{\{cy\}\}/g, ""); txt = txt.replace(/\{\{cz\}\}/g, ""); txt = txt.replace(/\{\{da\}\}/g, ""); txt = txt.replace(/\{\{de\}\}/g, ""); txt = txt.replace(/\{\{dk\}\}/g, ""); txt = txt.replace(/\{\{el\}\}/g, ""); txt = txt.replace(/\{\{eo\}\}/g, ""); txt = txt.replace(/\{\{es\}\}/g, ""); txt = txt.replace(/\{\{et\}\}/g, ""); txt = txt.replace(/\{\{eu\}\}/g, ""); txt = txt.replace(/\{\{fa\}\}/g, ""); txt = txt.replace(/\{\{fi\}\}/g, ""); txt = txt.replace(/\{\{fj\}\}/g, ""); txt = txt.replace(/\{\{fo\}\}/g, ""); txt = txt.replace(/\{\{fr\}\}/g, ""); txt = txt.replace(/\{\{fy\}\}/g, ""); txt = txt.replace(/\{\{ga\}\}/g, ""); txt = txt.replace(/\{\{gd\}\}/g, ""); txt = txt.replace(/\{\{gl\}\}/g, ""); txt = txt.replace(/\{\{gn\}\}/g, ""); txt = txt.replace(/\{\{gr\}\}/g, ""); txt = txt.replace(/\{\{gu\}\}/g, ""); txt = txt.replace(/\{\{gv\}\}/g, ""); txt = txt.replace(/\{\{he\}\}/g, ""); txt = txt.replace(/\{\{hi\}\}/g, ""); txt = txt.replace(/\{\{hr\}\}/g, ""); txt = txt.replace(/\{\{hu\}\}/g, ""); txt = txt.replace(/\{\{hy\}\}/g, ""); txt = txt.replace(/\{\{ia\}\}/g, ""); txt = txt.replace(/\{\{id\}\}/g, ""); txt = txt.replace(/\{\{io\}\}/g, ""); txt = txt.replace(/\{\{is\}\}/g, ""); txt = txt.replace(/\{\{it\}\}/g, ""); txt = txt.replace(/\{\{ja\}\}/g, ""); txt = txt.replace(/\{\{jp\}\}/g, ""); txt = txt.replace(/\{\{jv\}\}/g, ""); txt = txt.replace(/\{\{ka\}\}/g, ""); txt = txt.replace(/\{\{kk\}\}/g, ""); txt = txt.replace(/\{\{km\}\}/g, ""); txt = txt.replace(/\{\{kn\}\}/g, ""); txt = txt.replace(/\{\{ko\}\}/g, ""); txt = txt.replace(/\{\{kr\}\}/g, ""); txt = txt.replace(/\{\{ku\}\}/g, ""); txt = txt.replace(/\{\{kw\}\}/g, ""); txt = txt.replace(/\{\{la\}\}/g, ""); txt = txt.replace(/\{\{lb\}\}/g, ""); txt = txt.replace(/\{\{li\}\}/g, ""); txt = txt.replace(/\{\{lo\}\}/g, ""); txt = txt.replace(/\{\{lt\}\}/g, ""); txt = txt.replace(/\{\{lv\}\}/g, ""); txt = txt.replace(/\{\{ma\}\}/g, ""); txt = txt.replace(/\{\{mh\}\}/g, ""); txt = txt.replace(/\{\{mi\}\}/g, ""); txt = txt.replace(/\{\{mk\}\}/g, ""); txt = txt.replace(/\{\{ml\}\}/g, ""); txt = txt.replace(/\{\{mn\}\}/g, ""); txt = txt.replace(/\{\{mr\}\}/g, ""); txt = txt.replace(/\{\{ms\}\}/g, ""); txt = txt.replace(/\{\{mt\}\}/g, ""); txt = txt.replace(/\{\{my\}\}/g, ""); txt = txt.replace(/\{\{ne\}\}/g, ""); txt = txt.replace(/\{\{nl\}\}/g, ""); txt = txt.replace(/\{\{nn\}\}/g, ""); txt = txt.replace(/\{\{no\}\}/g, ""); txt = txt.replace(/\{\{oc\}\}/g, ""); txt = txt.replace(/\{\{pl\}\}/g, ""); txt = txt.replace(/\{\{pt\}\}/g, ""); txt = txt.replace(/\{\{ro\}\}/g, ""); txt = txt.replace(/\{\{ru\}\}/g, ""); txt = txt.replace(/\{\{sa\}\}/g, ""); txt = txt.replace(/\{\{si\}\}/g, ""); txt = txt.replace(/\{\{sk\}\}/g, ""); txt = txt.replace(/\{\{sl\}\}/g, ""); txt = txt.replace(/\{\{sm\}\}/g, ""); txt = txt.replace(/\{\{sq\}\}/g, ""); txt = txt.replace(/\{\{sr\}\}/g, ""); txt = txt.replace(/\{\{su\}\}/g, ""); txt = txt.replace(/\{\{sv\}\}/g, ""); txt = txt.replace(/\{\{Sv\}\}/g, ""); txt = txt.replace(/\{\{sw\}\}/g, ""); txt = txt.replace(/\{\{ta\}\}/g, ""); txt = txt.replace(/\{\{te\}\}/g, ""); txt = txt.replace(/\{\{th\}\}/g, ""); txt = txt.replace(/\{\{tl\}\}/g, ""); txt = txt.replace(/\{\{tm\}\}/g, ""); txt = txt.replace(/\{\{tr\}\}/g, ""); txt = txt.replace(/\{\{tt\}\}/g, ""); txt = txt.replace(/\{\{ua\}\}/g, ""); txt = txt.replace(/\{\{ug\}\}/g, ""); txt = txt.replace(/\{\{uk\}\}/g, ""); txt = txt.replace(/\{\{ur\}\}/g, ""); txt = txt.replace(/\{\{uz\}\}/g, ""); txt = txt.replace(/\{\{vi\}\}/g, ""); txt = txt.replace(/\{\{vo\}\}/g, ""); txt = txt.replace(/\{\{wa\}\}/g, ""); txt = txt.replace(/\{\{xh\}\}/g, ""); txt = txt.replace(/\{\{yi\}\}/g, ""); txt = txt.replace(/\{\{yo\}\}/g, ""); txt = txt.replace(/\{\{zh\}\}/g, ""); txt = txt.replace(/\{\{zu\}\}/g, ""); txt = txt.replace(/\{\{alb\}\}/g, ""); txt = txt.replace(/\{\{ang\}\}/g, ""); txt = txt.replace(/\{\{arm\}\}/g, ""); txt = txt.replace(/\{\{arn\}\}/g, ""); txt = txt.replace(/\{\{ast\}\}/g, ""); txt = txt.replace(/\{\{bns\}\}/g, ""); txt = txt.replace(/\{\{bos\}\}/g, ""); txt = txt.replace(/\{\{chr\}\}/g, ""); txt = txt.replace(/\{\{cic\}\}/g, ""); txt = txt.replace(/\{\{cmn\}\}/g, ""); txt = txt.replace(/\{\{fur\}\}/g, ""); txt = txt.replace(/\{\{gmh\}\}/g, ""); txt = txt.replace(/\{\{goh\}\}/g, ""); txt = txt.replace(/\{\{got\}\}/g, ""); txt = txt.replace(/\{\{grc\}\}/g, ""); txt = txt.replace(/\{\{haw\}\}/g, ""); txt = txt.replace(/\{\{kky\}\}/g, ""); txt = txt.replace(/\{\{kld\}\}/g, ""); txt = txt.replace(/\{\{mdf\}\}/g, ""); txt = txt.replace(/\{\{nap\}\}/g, ""); txt = txt.replace(/\{\{nan\}\}/g, ""); txt = txt.replace(/\{\{non\}\}/g, ""); txt = txt.replace(/\{\{pap\}\}/g, ""); txt = txt.replace(/\{\{pms\}\}/g, ""); txt = txt.replace(/\{\{rap\}\}/g, ""); txt = txt.replace(/\{\{scn\}\}/g, ""); txt = txt.replace(/\{\{sco\}\}/g, ""); txt = txt.replace(/\{\{tlh\}\}/g, ""); txt = txt.replace(/\{\{tyv\}\}/g, ""); txt = txt.replace(/\{\{vec\}\}/g, ""); txt = txt.replace(/\{\{wen\}\}/g, ""); // to me, these next few need to be reviewed quite closely! Obviously, not ISO 639-3. txt = txt.replace(/\{\{it-bo\}\}/g, ""); txt = txt.replace(/\{\{it-br\}\}/g, ""); txt = txt.replace(/\{\{it-ge\}\}/g, ""); txt = txt.replace(/\{\{it-mn\}\}/g, ""); txt = txt.replace(/\{\{it-mo\}\}/g, ""); txt = txt.replace(/\{\{it-pr\}\}/g, ""); txt = txt.replace(/\{\{el-it\}\}/g, ""); txt = txt.replace(/\{\{pt-br\}\}/g, ""); txt = txt.replace(/\{\{pt-pt\}\}/g, ""); txt = txt.replace(/\{\{zh-tc\}\}/g, ""); txt = txt.replace(/\{\{nl-vla\}\}/g, ""); txt = txt.replace(/\{\{nap-cal\}\}/g, ""); txt = txt.replace(/\{\{eml-rom\}\}/g, ""); txt = txt.replace(/\{\{gstr/g, "{{subst"+":gstr"); comment("{{subst"+":lang}}"); }

// Get all the wikified common languages French, Dutch, German etc. de-wikified. //From a list of langs, search for translation style and heading style and correct both //italian,french,german,spanish,japanese,serbian,latin,swedish,dutch,finnish,russian,norwegian,bosnian, //esperanto,chinese,portuguese,irish,polish,slovak,czech,danish,greek,hebrew,turkish,welsh, //hungarian,korean,arabic,romanian,indonesian,croatian,vietnamese,bulgarian,hindi, //filipino,icelandic,albanian,sanskrit,slovene,thai,yiddish,  **TOP40** //,tamil,urdu,balinese,afrikaans,kurdish,hawaiian,swahili,scots,fijian,zulu,cantonese, function deWikify { //Improperly formatted citations, with ":" instead of "," after bolded year txt = txt.replace(/\*([0-9]*)\:/g, "*$1,"); txt = txt.replace(/\*([0-9]*)\:/g, "*$1,"); oldtext = txt; //de-bold language names txt = txt.replace(/\*(.*)\:/g, "*$1:"); txt = txt.replace(/\*(.*)\:/g, "*$1:"); txt = txt.replace(/\*\[\[Italian\]\]:/gi, "*Italian:"); txt = txt.replace(/\*\[\[French\]\]:/gi, "*French:"); txt = txt.replace(/\*\[\[German\]\]:/gi, "*German:"); txt = txt.replace(/\*\[\[Spanish\]\]:/gi, "*Spanish:"); txt = txt.replace(/\*\[\[Japanese\]\]:/gi, "*Japanese:"); txt = txt.replace(/\*\[\[Serbian\]\]:/gi, "*Serbian:"); txt = txt.replace(/\*\[\[Latin\]\]:/gi, "*Latin:"); txt = txt.replace(/\*\[\[Swedish\]\]:/gi, "*Swedish:"); txt = txt.replace(/\*\[\[Dutch\]\]:/gi, "*Dutch:"); txt = txt.replace(/\*\[\[Finnish\]\]:/gi, "*Finnish:"); txt = txt.replace(/\*\[\[Russian\]\]:/gi, "*Russian:"); txt = txt.replace(/\*\[\[Norwegian\]\]:/gi, "*Norwegian:"); txt = txt.replace(/\*\[\[Bosnian\]\]:/gi, "*Bosnian:"); // txt = txt.replace(/\*\[\[Esperanto\]\]:/gi, "*Esperanto:"); txt = txt.replace(/\*\[\[Chinese\]\]:/gi, "*Chinese:"); txt = txt.replace(/\*\[\[Portuguese\]\]:/gi, "*Portuguese:"); // txt = txt.replace(/\*\[\[Irish\]\]:/gi, "*Irish:"); txt = txt.replace(/\*\[\[Polish\]\]:/gi, "*Polish:"); txt = txt.replace(/\*\[\[Slovak\]\]:/gi, "*Slovak:"); txt = txt.replace(/\*\[\[Czech\]\]:/gi, "*Czech:"); txt = txt.replace(/\*\[\[Danish\]\]:/gi, "*Danish:"); txt = txt.replace(/\*\[\[Greek\]\]:/gi, "*Greek:"); txt = txt.replace(/\*\[\[Hebrew\]\]:/gi, "*Hebrew:"); txt = txt.replace(/\*\[\[Turkish\]\]:/gi, "*Turkish:"); txt = txt.replace(/\*\[\[Welsh\]\]:/gi, "*Welsh:"); txt = txt.replace(/\*\[\[Hungarian\]\]:/gi, "*Hungarian:"); txt = txt.replace(/\*\[\[Korean\]\]:/gi, "*Korean:"); txt = txt.replace(/\*\[\[Arabic\]\]:/gi, "*Arabic:"); txt = txt.replace(/\*\[\[Romanian\]\]:/gi, "*Romanian:"); txt = txt.replace(/\*\[\[Indonesian\]\]:/gi, "*Indonesian:"); txt = txt.replace(/\*\[\[Croatian\]\]:/gi, "*Croatian:"); txt = txt.replace(/\*\[\[Vietnamese\]\]:/gi, "*Vietnamese:"); txt = txt.replace(/\*\[\[Bulgarian\]\]:/gi, "*Bulgarian:"); // txt = txt.replace(/\*\[\[Hindi\]\]:/gi, "*Hindi:"); txt = txt.replace(/\*\[\[Filipino\]\]:/gi, "*Filipino:"); txt = txt.replace(/\*\[\[Icelandic\]\]:/gi, "*Icelandic:"); txt = txt.replace(/\*\[\[Albanian\]\]:/gi, "*Albanian:"); txt = txt.replace(/\*\[\[Sanskrit\]\]:/gi, "*Sanskrit:"); txt = txt.replace(/\*\[\[Slovene\]\]:/gi, "*Slovene:"); // txt = txt.replace(/\*\[\[Thai\]\]:/gi, "*Thai:"); // txt = txt.replace(/\*\[\[Yiddish\]\]:/gi, "*Yiddish:"); //txt = txt.replace(/\*\[\[Tamil\]\]:/gi, "*Tamil:"); //txt = txt.replace(/\*\[\[Urdu\]\]:/gi, "*Urdu:"); //txt = txt.replace(/\*\[\[Balinese\]\]:/gi, "*Balinese:"); //txt = txt.replace(/\*\[\[Afrikaans\]\]:/gi, "*Afrikaans:"); //txt = txt.replace(/\*\[\[Kurdish\]\]:/gi, "*Kurdish:"); //txt = txt.replace(/\*\[\[Hawaiian\]\]:/gi, "*Hawaiian:"); //txt = txt.replace(/\*\[\[Swahili\]\]:/gi, "*Swahili:"); //txt = txt.replace(/\*\[\[Scots\]\]:/gi, "*Scots:"); //txt = txt.replace(/\*\[\[Fijian\]\]:/gi, "*Fijian:"); //txt = txt.replace(/\*\[\[Zulu\]\]:/gi, "*Zulu:"); //txt = txt.replace(/\*\[\[Cantonese\]\]:/gi, "*Cantonese:"); txt = txt.replace(/\*\[\[w:Breton language\|Breton\]\]:/gi, "*Breton:"); txt = txt.replace(/\*\[\[w:Catalan language\|Catalan\]\]:/gi, "*Catalan:"); txt = txt.replace(/\*\[\[w:Danish language\|Danish\]\]:/gi, "*Danish:"); txt = txt.replace(/\*\[\[w:Dutch language\|Dutch\]\]:/gi, "*Dutch:"); txt = txt.replace(/\*\[\[w:French language\|French\]\]:/gi, "*French:"); txt = txt.replace(/\*\[\[w:German language\|German\]\]:/gi, "*German:"); txt = txt.replace(/\*\[\[w:Indonesian language\|Indonesian\]\]:/gi, "*Indonesian:"); txt = txt.replace(/\*\[\[w:Italian language\|Italian\]\]:/gi, "*Italian:"); txt = txt.replace(/\*\[\[w:Japanese language\|Japanese\]\]:/gi, "*Japanese:"); txt = txt.replace(/\*\[\[w:Romanian language\|Romanian\]\]:/gi, "*Romanian:"); txt = txt.replace(/\*\[\[w:Russian language\|Russian\]\]:/gi, "*Russian:"); txt = txt.replace(/\*\[\[w:Spanish language\|Spanish\]\]:/gi, "*Spanish:"); txt = txt.replace(/\*\[\[w:Swedish language\|Swedish\]\]:/gi, "*Swedish:"); txt = txt.replace(/==\[\[Italian\]\]==/gi, "==Italian=="); txt = txt.replace(/==\[\[French\]\]==/gi, "==French=="); txt = txt.replace(/==\[\[German\]\]==/gi, "==German=="); txt = txt.replace(/==\[\[Spanish\]\]==/gi, "==Spanish=="); txt = txt.replace(/==\[\[Japanese\]\]==/gi, "==Japanese=="); txt = txt.replace(/==\[\[Serbian\]\]==/gi, "==Serbian=="); txt = txt.replace(/==\[\[Latin\]\]==/gi, "==Latin=="); txt = txt.replace(/==\[\[Swedish\]\]==/gi, "==Swedish=="); txt = txt.replace(/==\[\[Dutch\]\]==/gi, "==Dutch=="); txt = txt.replace(/==\[\[Finnish\]\]==/gi, "==Finnish=="); txt = txt.replace(/==\[\[Russian\]\]==/gi, "==Russian=="); txt = txt.replace(/==\[\[Norwegian\]\]==/gi, "==Norwegian=="); txt = txt.replace(/==\[\[Bosnian\]\]==/gi, "==Bosnian=="); // txt = txt.replace(/==\[\[Esperanto\]\]==/gi, "==Esperanto=="); txt = txt.replace(/==\[\[Chinese\]\]==/gi, "==Chinese=="); txt = txt.replace(/==\[\[Portuguese\]\]==/gi, "==Portuguese=="); // txt = txt.replace(/==\[\[Irish\]\]==/gi, "==Irish=="); txt = txt.replace(/==\[\[Polish\]\]==/gi, "==Polish=="); txt = txt.replace(/==\[\[Slovak\]\]==/gi, "==Slovak=="); txt = txt.replace(/==\[\[Czech\]\]==/gi, "==Czech=="); txt = txt.replace(/==\[\[Danish\]\]==/gi, "==Danish=="); txt = txt.replace(/==\[\[Greek\]\]==/gi, "==Greek=="); txt = txt.replace(/==\[\[Hebrew\]\]==/gi, "==Hebrew=="); txt = txt.replace(/==\[\[Turkish\]\]==/gi, "==Turkish=="); txt = txt.replace(/==\[\[Welsh\]\]==/gi, "==Welsh=="); txt = txt.replace(/==\[\[Hungarian\]\]==/gi, "==Hungarian=="); txt = txt.replace(/==\[\[Korean\]\]==/gi, "==Korean=="); txt = txt.replace(/==\[\[Arabic\]\]==/gi, "==Arabic=="); txt = txt.replace(/==\[\[Romanian\]\]==/gi, "==Romanian=="); txt = txt.replace(/==\[\[Indonesian\]\]==/gi, "==Indonesian=="); txt = txt.replace(/==\[\[Croatian\]\]==/gi, "==Croatian=="); txt = txt.replace(/==\[\[Vietnamese\]\]==/gi, "==Vietnamese=="); txt = txt.replace(/==\[\[Bulgarian\]\]==/gi, "==Bulgarian=="); // txt = txt.replace(/==\[\[Hindi\]\]==/gi, "==Hindi=="); txt = txt.replace(/==\[\[Filipino\]\]==/gi, "==Filipino=="); txt = txt.replace(/==\[\[Icelandic\]\]==/gi, "==Icelandic=="); txt = txt.replace(/==\[\[Albanian\]\]==/gi, "==Albanian=="); txt = txt.replace(/==\[\[Sanskrit\]\]==/gi, "==Sanskrit=="); txt = txt.replace(/==\[\[Slovene\]\]==/gi, "==Slovene=="); // txt = txt.replace(/==\[\[Thai\]\]==/gi, "==Thai=="); // txt = txt.replace(/==\[\[Yiddish\]\]==/gi, "==Yiddish=="); //txt = txt.replace(/==\[\[Tamil\]\]==/gi, "==Tamil=="); //txt = txt.replace(/==\[\[Urdu\]\]==/gi, "==Urdu=="); //txt = txt.replace(/==\[\[Balinese\]\]==/gi, "==Balinese=="); //txt = txt.replace(/==\[\[Afrikaans\]\]==/gi, "==Afrikaans=="); //txt = txt.replace(/==\[\[Kurdish\]\]==/gi, "==Kurdish=="); //txt = txt.replace(/==\[\[Hawaiian\]\]==/gi, "==Hawaiian=="); //txt = txt.replace(/==\[\[Swahili\]\]==/gi, "==Swahili=="); //txt = txt.replace(/==\[\[Scots\]\]==/gi, "==Scots=="); //txt = txt.replace(/==\[\[Fijian\]\]==/gi, "==Fijian=="); //txt = txt.replace(/==\[\[Zulu\]\]==/gi, "==Zulu=="); //txt = txt.replace(/==\[\[Cantonese\]\]==/gi, "==Cantonese=="); txt = txt.replace(/==\[\[w\:Koine Greek\|Koine Greek\]\]==/gi, "==Ancient Greek=="); txt = txt.replace(/==\[\[w:Koine Greek\|Koine Greek\]\]==/gi, "==Ancient Greek=="); txt = txt.replace(/==\[\[w\:Koine Greek|Koine Greek\]\]==/gi, "==Ancient Greek=="); txt = txt.replace(/==\[\[w:Koine Greek|Koine Greek\]\]==/gi, "==Ancient Greek=="); comment("dewikify common langs"); }

function notEnglishInflection { oldtext = txt;

//On lines following heading lines (===Noun===) that start with "#", ensure stem plus [c] // or [u] or plural form are present, wikified properly. If not, add "s" to end of //stem-word, pop up a warning saying that this may be pluralizing it wrong, and go.

//for now, quick and dirty replacement if missing entirely. (Should the 'often' incorrect plural just be skipped?) txt = txt.replace(/===Noun==[=]+\n\#/g, "===Noun===\n\n\n\#"); txt = txt.replace(/===Proper noun==[=]+\n\#/g, "===Proper noun===\n\n\n\#");

//On lines following "===Adjective===" that start with a "#", ensure and  are there (even if they say "none".)  <--bogus. txt = txt.replace(/===Adjective==[=]+\n\#/g, "===Adjective===\n\n\n\#");

//On lines following "===Adverb===" that start with a "#", ensure and  are there (even if they say "none".) <-- bogus txt = txt.replace(/===Adverb==[=]+\n\#/g, "===Adverb===\n\n\n\#");

txt = txt.replace(/===Phrase==[=]+\n\#/g, "===Phrase===\n\n\n\#");

//todo: rework this section once Polyglot has the template politics sorted out //on lines following "===Verb===" that start with "'", ensure that past, participle and third person forms are mentioned, otherwise add a {{en-infl... template txt = txt.replace(/===Verb==[=]+\n\#/g, "===Verb===\n\n\n\#");

comment(""); }

function englishInflection { var oldtext = txt;

//On lines following heading lines (===Noun===) that start with "#", ensure stem plus [c] // or [u] or plural form are present, wikified properly. If not, add "s" to end of //stem-word, pop up a warning saying that this may be pluralizing it wrong, and go.

//for now, quick and dirty replacement if missing entirely. (Should the 'often' incorrect plural just be skipped?) //TODO: if wgPageName ending = y...put that logic right here? txt = txt.replace(/===Noun==[=]+\n\#/g, "===Noun===\n\n\n\n\n\#");

txt = txt.replace(/===Proper noun==[=]+\n\#/g, "===Proper noun===\n\n\n\#");

txt = txt.replace(/===Adjective==[=]+\n\#/g, "===Adjective===\n\n\n\n#");

txt = txt.replace(/===Adverb==[=]+\n\#/g, "===Adverb===\n\n\n\#");

txt = txt.replace(/===Phrase==[=]+\n\#/g, "===Phrase===\n\n\n\#");

//TODO: rework this section txt = txt.replace(/Verb==[=]+\n\#/gi, "Verb===\n\n\n\n\#");

comment(" (en)"); }

//Inflection lines: TODO separate code for entries that have ==English==. //this gets about 80% right. Perfectly acceptable to have many languages, but for //horribly formatted entries, there is usually only one language. Entries with //multiple languages tend to be pretty clean, comparatively. This code needs to be //rewritten when I figure out the Russian technique of selecting text-sections. (Or //rather, how to implement that here.) function inflLine {

//momentarily remove extra blank lines txt = txt.replace(/verb===\n\n/gi, "Verb===\n"); txt = txt.replace(/===noun===\n\n/gi, "===Noun===\n"); txt = txt.replace(/===proper noun===\n\n/gi, "===Proper noun===\n"); txt = txt.replace(/===adjective===\n\n/gi, "===Adjective===\n"); txt = txt.replace(/===adverb===\n\n/gi, "===Adverb===\n"); txt = txt.replace(/verb====\n\n/gi, "Verb====\n"); txt = txt.replace(/===noun====\n\n/gi, "===Noun====\n"); txt = txt.replace(/===proper noun====\n\n/gi, "===Proper noun====\n"); txt = txt.replace(/===adjective====\n\n/gi, "===Adjective====\n"); txt = txt.replace(/===adverb====\n\n/gi, "===Adverb====\n"); txt = txt.replace(/==further reading==/gi, "==See also=="); txt = txt.replace(/===phrase===\n\n/gi, "===Phrase===\n");

if (txt.search(/==English==\n/) == -1) { notEnglishInflection; } else { englishInflection; }

txt = txt.replace(/==transitive verb==/gi, "==Transitive verb=="); txt = txt.replace(/==intransitive verb==/gi, "==Intransitive verb==");

//todo then do the ones that are common to both...Proper noun...Phrase...etc. }

//Next, on lines that start with "#" (therefore definitions) skip the, (qualifiers) and // punctuation: then capitalize first letter of first sentence, pipe-syntax-wikified if needed. Ensure // period is at end of line (except quotes and parens, of course.)

//todo: make sure templates that are not in all upper-case start with a lower case character

//todo: flag or just replace "===Transitive verb===" with "===Verb===" <-- WS:BP first

//todo: count heading level. If heading level is four, and last heading level was 2, warn or fix or something. (Note: if level is 2, and last level was 2, 3, 4, or 5, it is still ok)

//todo: If English not first heading, and there is no 2nd level header, add "==English=="

//todo: If English appears elsewhere, and another language is in front, swap sections (Separate w/ "".)

//todo: Remove "" except once between English and all other language.

//todo: move all category links to bottom

//todo: move all interwiki links even more bottomer.

//todo: "subst:" all etymology Webster templates ending in a period. Discuss on WS:BP first.

//todo: Alphabetize Part Of Speech sections

//prep tables for balancing... function transTable { oldtext = txt; txt = txt.replace(/\<\!--left column--\>\n/gi, ""); txt = txt.replace(/\<\!--right column--\>\n/gi, ""); txt = txt.replace(/\<\!--languages from A to [H-N] go here--\>\n/gi, ""); txt = txt.replace(/\<\!--Put translations for languages from A to [H-N] here--\>\n/gi, ""); txt = txt.replace(/\<\!--languages from [I-O] to Z go here--\>\n/gi, ""); txt = txt.replace(/\<\!--Put translations for languages from [I-O] to Z here--\>\n/gi, ""); txt = txt.replace(/\{\| border=0 width=100\%\n\|-\n\|bgcolor=\"\#FFFFE0\" valign=top width=48\%\|\n\{\|/gi, ""); txt = txt.replace(/\{\| border=0 width=100\%\n\|-\n\|bgcolor=\"\#FFFFE0\" valign=top width=48\%\|\n\{\|/gi, ""); txt = txt.replace(/\{\| border=0 width=100\%\n\|-\n\|valign=top width=33\%\|\n\{\|/gi, ""); txt = txt.replace(/\|\}\n\| width=1\% \|\n\|bgcolor=\"\#FFFFE0\" valign=top width=48\%\|\n\{\|/gi, ""); txt = txt.replace(/\|\}\n\| width=1\% \|\n\|valign=top width=33\%\|\n\{\|/gi, ""); txt = txt.replace(/\|\}\n\|\}/gi, "");

//rewrite the tables auto-balancing code here... //Note that it will need the Russian's area-selection logic applied to it // Refactor then reuse code from above that adds "{{ttbc|", section by section, // subdivide by informal "translation" section? Nah, subdivide by any / // pair inside a =[=]translation[=]= section. // /* pg	;balance columns for a "Names" page (all in 4 columns) w !,"Paste text of entire page with sections to be balanced:",! k x,y r y(1) f k=2:1 r !,y(k):5 q:'$t w #,!!!,y(1) f m=2:1:k d	.i y(m)'?1"==".e w !,y(m) q	.w !,y(m) s x(1)=y(m) .f l=2:0 q:'$d(y(m+1)) q:y(m+1)?1"==".e  q:y(m+1)?1"{{".e1"index-".e  d	..s m=m+1 ..s x(l)=y(m) ..s l=l+1 .s i=l-1 d mid4 w ! q top4	;balance columns w !,"Paste text of section to be balanced:",! r x(1) f i=2:1 r !,x(i):5 q:'$t w #,!!!,x(1) mid4	s cnt=0,i=i-1,c=0 f j=2:1:i i x(j)?1"{".e k x(j) f j=2:1:i i $g(x(j))?1"|".e k x(j) f j=2:1:i i $tr($g(x(j))," ","")="" k x(j) f j=2:1:i i $g(x(j))?1"''Section".e w !,x(j) k x(j) f j=2:1:i i $d(x(j)) s cnt=cnt+1 i x(1)["Translation" d q	.w !,"" .f j=2:1:i i $d(x(j)) s c=c+1 w:c=cnt\2 !,"" w !,x(j) .w !,"{{bottom}}" q:cnt<1 w !,"{{top4}}" s tcnt=cnt,cnt=$s(cnt#4:1,1:0)+(cnt\4),md=0 f j=2:1:i i $d(x(j)) s c=c+1 d:c>cnt w !,x(j) .w !,"{{mid4}}" s c=1 s md=md+1 .i j=4,tcnt=5 s cnt=cnt-1 .i j=4,tcnt=6 s cnt=cnt-1 .i j=7,tcnt=9 s cnt=cnt-1 i md<3 w:md<1 !,"{{mid4}}" w:md<2 !,"{{mid4}}" w !,"{{mid4}}" w !,"{{bottom}}" q comment("{{top/mid/bot}}"); }

function anonIPfmt { if ( pagetitle.search(/User talk:/gi) == -1 ) return; txt = document.editform.wpTextbox1.value ; oldtext = txt ; //txt = txt.replace(/\{\{old-utp/gi, "{{subst:old-utp"); txt = txt.replace(/\{\{welcome/gi, "{{subst:welcome"); if ( ( txt != oldtext ) || ( txt.search(/\{\{subst:welcome/g) != -1) ) { document.editform.wpTextbox1.value = txt; comment("Welcome!"); document.editform.wpSave.click; //wpDiff? } }

var wiktZwindow;

function wiktCloseMark(z) { wiktZwindow.close; }

function markCleanedUp { //send "mark" tag to server to remove from "Cleanup a random entry" list. If on that list and removed, change edit summary to Random cleanup.

// Note carefully that 'user=Connel' is not testing code. I don't want to compose a lengthy // "white-list" thing here, nor do I want to pull the whole 'patrolled' white-list. Hmmm. // Maybe I should do something like that. Nah...privacy issues. For now, just me. if ( wgUserName == "Connel MacKenzie" ) { wiktZwindow = window.open("http://connelm.homelinux.com/cgi-bin/mark?mark=" + wgPageName); //wiktZwindow.onload = function { wiktZwindow.close; } ; //z.onload = "wiktCloseMark(wiktZwindow);" ; setTimeout( "wiktCloseMark(wiktZwindow);", 1000 ); // As long as the request is sent, it will get handled properly on my server...so I'm not too worried about mistakes, but I do want to prevent duplicates better. } }

function wiktClickMyDiff { window.status = "[Show changes] has now been clicked."; document.editform.wpDiff.click; }

function superAutoFormat { oldtext=""; // get page title pagetitle = document.getElementById('content').getElementsByTagName('h1').item(0).firstChild.nodeValue; if (pagetitle.search(/Editing /) == -1) return; pagetitle = pagetitle.replace(/Editing /g, ""); pageexternal = pagetitle.replace(/\ /g, "_");

// is this in the main namespace? If not, stop. if (pagetitle.search(/\:/) != -1) { decodeSomeUtf8; //spastic residual UTF-8 encoding anonIPfmt; return; }

// If editing a section, skip all of everything. if (pagetitle.search(/\(section\)/) != -1) return;

if (/&wikiredr=clean/.test(window.location.href)) { document.editform.wpSummary.value = "Random cleanup"; }

txt = " " + document.editform.wpTextbox1.value; txt = txt.substr (1, txt.length-1); myoldtxt = txt; oldtxt = txt; if (txt.length < 2) txt = " " + txt; oldtext = txt;

//safety valves if (txt.search(/^#redirect \[/i) != -1) return;

// change me, if not exiting properly {{PAGENAME}} / {{PAGENAMEE}}

txt = txt.replace(/\{\{PAGENAMEE\}\}/g, pageexternal); txt = txt.replace(/\{\{PAGENAME\}\}/g, pagetitle); txt = txt.replace(/\{\{subst:PAGENAME\}\}/g, pagetitle);

minorFormat; //minor format problems that must be dealt with first genderFmt;  //format gender from italics to template langHdrs;   //spap out {{-en-}} and such headLevel;  //correct known 3rd level heading level problems langHdrs;   //correct known language heading level problems langSubsts; //subst: all the language templates deWikify;   //de-wikify all "common" languages //todo: limit formatting of inflections and such to ==English== section only? inflLine;   //add an "inflection" line if missing formOf;     // stuff in some "form of" common replacements transTable; //reformat translations tables, balance columns (todo) parseLines; //TTBC topmidbot;  //{top/mid/bot} -> {trans-top/mid/bot} specialCharacters; //Special characters entered when they shouldn't be or vice versa

txt = txt.replace(/\{\{PAGENAMEE\}\}/g, pageexternal); txt = txt.replace(/\{\{PAGENAME\}\}/g, pagetitle); txt = txt.replace(/\{\{subst:PAGENAME\}\}/g, pagetitle);

//2/22/2006: Running through the /todo4 cleanup list; TEMPORARY CODE //Add "==English==\n\n" by default. //txt.multiline = true; if (txt.length > 1) if ( txt.search(/==[A-Z\[\]\{\}|: (ü)\-a-z]+==\n/) == -1 ) { if ( txt.search(/^\*[ ]common misspelling of/gi) == -1 ) { if ( txt.search(/^#redirect /gi) == -1 ) { txt = "==English==\n\n" + txt; document.editform.wpSummary.value += " +==Lang=="; }   }  }

if (txt == " ") txt = "";

document.editform.wpTextbox1.value = txt;

//document.editform.wpSummary.value = document.forms.length;

oldtxt = myoldtxt; if (txt != oldtxt) { //markCleanedUp; //comments now added for specific sections only. if (document.editform.wpSummary.value.search(/User:/g) == -1) { if (document.editform.wpSummary.value != "") document.editform.wpSummary.value += ", "; document.editform.wpSummary.value += "fmt"; }   //document.editform.wpSummary.value += "+format"; window.status = "...clicking the [Show changes] button..."; setTimeout( "wiktClickMyDiff;", 2000 ); } }

$( superAutoFormat );

/* */