User:Connel MacKenzie/reformat.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

/* <pre><noinclude> */

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, "# {{plural of|[[$1]]}}");
  txt = txt.replace(/\# plural of \[\[(.*)\]\]\./gi, "# {{plural of|[[$1]]}}");
  txt = txt.replace(/\#plural of \[\[(.*)\]\]\./gi, "# {{plural of|[[$1]]}}");
  txt = txt.replace(/\# plural form of \[\[(.*)\]\]/gi, "# {{plural of|[[$1]]}}");
  txt = txt.replace(/\# plural of \[\[(.*)\]\]/gi, "# {{plural of|[[$1]]}}");
  txt = txt.replace(/\[\[Category\:English plurals\]\]/gi, "");
  txt = txt.replace(/\# third person form of \'\'to \[\[(.*)\]\]\'\'\./gi, "# {{third-person singular of|[[$1]]}}");
  txt = txt.replace(/\# third person form of \'\'to \[\[(.*)\]\]\'\'/gi, "# {{third-person singular of|[[$1]]}}");
  txt = txt.replace(/\# third person singular form of \'\'\'to \[\[(.*)\]\]\'\'\'\./gi, "# {{third-person singular of|[[$1]]}}");
  txt = txt.replace(/\# third person singular form of \'\'\'to \[\[(.*)\]\]\'\'\'/gi, "# {{third-person singular of|[[$1]]}}");
  txt = txt.replace(/\# third person singular of \'\'to \[\[(.*)\]\]\'\'\./gi, "# {{third-person singular of|[[$1]]}}");
  txt = txt.replace(/\# third person singular of \'\'to \[\[(.*)\]\]\'\'/gi, "# {{third-person singular of|[[$1]]}}");
  txt = txt.replace(/\#third person singular of \[\[(.*)\]\]\./gi, "# {{third-person singular of|[[$1]]}}");
  txt = txt.replace(/\#third person singular of \[\[(.*)\]\]/gi, "# {{third-person singular of|[[$1]]}}");
  txt = txt.replace(/\#third-person singular of \[\[(.*)\]\]\./gi, "# {{third-person singular of|[[$1]]}}");
  txt = txt.replace(/\#third-person singular of \[\[(.*)\]\]/gi, "# {{third-person singular of|[[$1]]}}");

  comment("{form of}");
}


//ligatures dž, lj, nj
function specialCharacters() {
  oldtext = txt;
  txt = txt.replace(/nj/g, "nj");
  txt = txt.replace(/dž/g, "dz");
  txt = txt.replace(/lj/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 "{{checktrans}}"...process from that line
// until the next heading (any line starting with "=".)
//  For each line, if in the *Langname: [[translation]]...
//  then change it to *{{ttbc|Langname}}: [[translation]]...
//  and strip out {{top}}/{{mid}}/{{bot}} 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, "{{checktrans"+"-top}}");

  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<!--added {{ttbc|}}s here.-->";
      }

    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 = "*{{ttbc|" + 
              line.substring(1,chrat).replace(/\[|\]|\*/g, "") + "}}:" + 
              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 = "{{trans-top|" + l[i-1] + "}}";
        l[i-1] = "";
      }
    }

    line = line.replace(/\{\{top\}\}/gi, "{{trans-top|fixme=Translation table header lacks gloss}}");
    line = line.replace(/\{\{mid\}\}/gi, "{{trans-mid}}");
    line = line.replace(/\{\{bottom\}\}/gi, "{{trans-bottom}}");

    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(/\<i\>/gi, "''");  //italics is '' in wiki syntax
  txt = txt.replace(/\<\/i\>/gi, "''");  //italics is '' in wiki syntax
  txt = txt.replace(/\<b\>/gi, "'''");  //bold is ''' in wiki syntax
  txt = txt.replace(/\<\/b\>/gi, "'''");  //bold is ''' in wiki syntax
 // txt = txt.replace(/\<br\>/gi, "\n\n");  //break is <LF><LF> in wiki syntax
 // txt = txt.replace(/\<\/br\>/gi, "\n\n");  //break is <LF><LF> 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, "{{compar}}"); 
//  txt = txt.replace(/\'\'\[\[superlative\]\]\'\'/gi, "{{superl}}"); 
//  txt = txt.replace(/\[\[comparative\]\]/gi, "{{compar}}"); 
//  txt = txt.replace(/\[\[superlative\]\]/gi, "{{superl}}"); 
//  txt = txt.replace(/\'\'comparative\'\'/gi, "{{compar}}");
//  txt = txt.replace(/\'\'superlative\'\'/gi, "{{superl}}");
  txt = txt.replace(/\{\{top\}\}\</gi, "{{top}}\n<");
  txt = txt.replace(/\{\{mid\}\}\</gi, "{{mid}}\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, "[[w:"); //ancient syntax
    txt = txt.replace(/\[\[en:/gi, "[[w:"); //ancient syntax
    txt = txt.replace(/\(\'\'mass noun\'\'\)/gi, "{{uncountable}}");
    txt = txt.replace(/\<\!--This is a comment.  Please remove comments before saving. --\>\n\n\<\!-- Change Part-Of-Speech on next line \(inside the======\'s\) to be correct.--\>\n/gi, "");
    txt = txt.replace(/\<\!--\{\{wikipedia\}\} uncomment if you know there is a Wikipedia article--\>\n/gi, "");
  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|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, " {{m}}");  // test this ''m'' {{m}}
  txt = txt.replace(/''m'' /g, "{{m}} ");  // test this ''m'' {{m}}
  txt = txt.replace(/ ''f''/g, " {{f}}");
  txt = txt.replace(/''f'' /g, "{{f}} ");
  txt = txt.replace(/ ''n''/g, " {{n}}");
  txt = txt.replace(/''n'' /g, "{{n}} ");
  txt = txt.replace(/ ''c''/g, " {{c}}");
  txt = txt.replace(/''c'' /g, "{{c}} ");
  txt = txt.replace(/ ''pl''/g, " {{p}}");
  txt = txt.replace(/''pl'' /g, "{{p}} ");
  txt = txt.replace(/ ''s''/g, " {{s}}");
  txt = txt.replace(/''s'' /g, "{{s}} ");
  txt = txt.replace(/''m, f''/g, "{{m}}, {{f}}");
  txt = txt.replace(/\{\{mf\}\}/g, "{{m}}, {{f}}");
  txt = txt.replace(/''m pl''/g, "{{m}} {{p}}");
  txt = txt.replace(/''f pl''/g, "{{f}} {{p}}");
  txt = txt.replace(/''m plural''/g, "{{m}} {{p}}");
  txt = txt.replace(/''f plural''/g, "{{f}} {{p}}");
  txt = txt.replace(/\(plural \[/gi, "(''plural:'' [");
  txt = txt.replace(/\(''plural'' /gi, "(''plural:'' ");
  txt = txt.replace(/, plural '/gi, "  (''plural:'' '"); //note: this requires human help
  comment("{{gender}}");
}


// get all the {{-header-}} 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(/\n'''adjective'''\n/gi, "\n===Adjective===\n");
  txt = txt.replace(/\n'''adverb'''\n/gi, "\n===Adverb===\n");
  txt = txt.replace(/\n'''noun'''\n/gi, "\n===Noun===\n");
  txt = txt.replace(/\n'''verb'''\n/gi, "\n===Verb===\n");
  txt = txt.replace(/\n'''translation'''\n/gi, "\n===Translations===\n");
  txt = txt.replace(/\n'''translations'''\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, "{{rfap}}\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, "{{subst"+":en}}");
  txt = txt.replace(/\{\{af\}\}/g, "{{subst"+":af}}");
  txt = txt.replace(/\{\{am\}\}/g, "{{subst"+":am}}");
  txt = txt.replace(/\{\{an\}\}/g, "{{subst"+":an}}");
  txt = txt.replace(/\{\{ar\}\}/g, "{{subst"+":ar}}");
  txt = txt.replace(/\{\{az\}\}/g, "{{subst"+":az}}");
  txt = txt.replace(/\{\{be\}\}/g, "{{subst"+":be}}");
  txt = txt.replace(/\{\{bg\}\}/g, "{{subst"+":bg}}");
  txt = txt.replace(/\{\{bh\}\}/g, "{{subst"+":bh}}");
  txt = txt.replace(/\{\{br\}\}/g, "{{subst"+":br}}");
  txt = txt.replace(/\{\{bs\}\}/g, "{{subst"+":bs}}");
  txt = txt.replace(/\{\{ca\}\}/g, "{{subst"+":ca}}");
  txt = txt.replace(/\{\{ch\}\}/g, "{{subst"+":ch}}");
  txt = txt.replace(/\{\{cn\}\}/g, "{{subst"+":cn}}");
  txt = txt.replace(/\{\{cr\}\}/g, "{{subst"+":cr}}");
  txt = txt.replace(/\{\{cs\}\}/g, "{{subst"+":cs}}");
  txt = txt.replace(/\{\{cy\}\}/g, "{{subst"+":cy}}");
  txt = txt.replace(/\{\{cz\}\}/g, "{{subst"+":cz}}");
  txt = txt.replace(/\{\{da\}\}/g, "{{subst"+":da}}");
  txt = txt.replace(/\{\{de\}\}/g, "{{subst"+":de}}");
  txt = txt.replace(/\{\{dk\}\}/g, "{{subst"+":dk}}");
  txt = txt.replace(/\{\{el\}\}/g, "{{subst"+":el}}");
  txt = txt.replace(/\{\{eo\}\}/g, "{{subst"+":eo}}");
  txt = txt.replace(/\{\{es\}\}/g, "{{subst"+":es}}");
  txt = txt.replace(/\{\{et\}\}/g, "{{subst"+":et}}");
  txt = txt.replace(/\{\{eu\}\}/g, "{{subst"+":eu}}");
  txt = txt.replace(/\{\{fa\}\}/g, "{{subst"+":fa}}");
  txt = txt.replace(/\{\{fi\}\}/g, "{{subst"+":fi}}");
  txt = txt.replace(/\{\{fj\}\}/g, "{{subst"+":fj}}");
  txt = txt.replace(/\{\{fo\}\}/g, "{{subst"+":fo}}");
  txt = txt.replace(/\{\{fr\}\}/g, "{{subst"+":fr}}");
  txt = txt.replace(/\{\{fy\}\}/g, "{{subst"+":fy}}");
  txt = txt.replace(/\{\{ga\}\}/g, "{{subst"+":ga}}");
  txt = txt.replace(/\{\{gd\}\}/g, "{{subst"+":gd}}");
  txt = txt.replace(/\{\{gl\}\}/g, "{{subst"+":gl}}");
  txt = txt.replace(/\{\{gn\}\}/g, "{{subst"+":gn}}");
  txt = txt.replace(/\{\{gr\}\}/g, "{{subst"+":gr}}");
  txt = txt.replace(/\{\{gu\}\}/g, "{{subst"+":gu}}");
  txt = txt.replace(/\{\{gv\}\}/g, "{{subst"+":gv}}");
  txt = txt.replace(/\{\{he\}\}/g, "{{subst"+":he}}");
  txt = txt.replace(/\{\{hi\}\}/g, "{{subst"+":hi}}");
  txt = txt.replace(/\{\{hr\}\}/g, "{{subst"+":hr}}");
  txt = txt.replace(/\{\{hu\}\}/g, "{{subst"+":hu}}");
  txt = txt.replace(/\{\{hy\}\}/g, "{{subst"+":hy}}");
  txt = txt.replace(/\{\{ia\}\}/g, "{{subst"+":ia}}");
  txt = txt.replace(/\{\{id\}\}/g, "{{subst"+":id}}");
  txt = txt.replace(/\{\{io\}\}/g, "{{subst"+":io}}");
  txt = txt.replace(/\{\{is\}\}/g, "{{subst"+":is}}");
  txt = txt.replace(/\{\{it\}\}/g, "{{subst"+":it}}");
  txt = txt.replace(/\{\{ja\}\}/g, "{{subst"+":ja}}");
  txt = txt.replace(/\{\{jp\}\}/g, "{{subst"+":jp}}");
  txt = txt.replace(/\{\{jv\}\}/g, "{{subst"+":jv}}");
  txt = txt.replace(/\{\{ka\}\}/g, "{{subst"+":ka}}");
  txt = txt.replace(/\{\{kk\}\}/g, "{{subst"+":kk}}");
  txt = txt.replace(/\{\{km\}\}/g, "{{subst"+":km}}");
  txt = txt.replace(/\{\{kn\}\}/g, "{{subst"+":kn}}");
  txt = txt.replace(/\{\{ko\}\}/g, "{{subst"+":ko}}");
  txt = txt.replace(/\{\{kr\}\}/g, "{{subst"+":kr}}");
  txt = txt.replace(/\{\{ku\}\}/g, "{{subst"+":ku}}");
  txt = txt.replace(/\{\{kw\}\}/g, "{{subst"+":kw}}");
  txt = txt.replace(/\{\{la\}\}/g, "{{subst"+":la}}");
  txt = txt.replace(/\{\{lb\}\}/g, "{{subst"+":lb}}");
  txt = txt.replace(/\{\{li\}\}/g, "{{subst"+":li}}");
  txt = txt.replace(/\{\{lo\}\}/g, "{{subst"+":lo}}");
  txt = txt.replace(/\{\{lt\}\}/g, "{{subst"+":lt}}");
  txt = txt.replace(/\{\{lv\}\}/g, "{{subst"+":lv}}");
  txt = txt.replace(/\{\{ma\}\}/g, "{{subst"+":ma}}");
  txt = txt.replace(/\{\{mh\}\}/g, "{{subst"+":mh}}");
  txt = txt.replace(/\{\{mi\}\}/g, "{{subst"+":mi}}");
  txt = txt.replace(/\{\{mk\}\}/g, "{{subst"+":mk}}");
  txt = txt.replace(/\{\{ml\}\}/g, "{{subst"+":ml}}");
  txt = txt.replace(/\{\{mn\}\}/g, "{{subst"+":mn}}");
  txt = txt.replace(/\{\{mr\}\}/g, "{{subst"+":mr}}");
  txt = txt.replace(/\{\{ms\}\}/g, "{{subst"+":ms}}");
  txt = txt.replace(/\{\{mt\}\}/g, "{{subst"+":mt}}");
  txt = txt.replace(/\{\{my\}\}/g, "{{subst"+":my}}");
  txt = txt.replace(/\{\{ne\}\}/g, "{{subst"+":ne}}");
  txt = txt.replace(/\{\{nl\}\}/g, "{{subst"+":nl}}");
  txt = txt.replace(/\{\{nn\}\}/g, "{{subst"+":nn}}");
  txt = txt.replace(/\{\{no\}\}/g, "{{subst"+":no}}");
  txt = txt.replace(/\{\{oc\}\}/g, "{{subst"+":oc}}");
  txt = txt.replace(/\{\{pl\}\}/g, "{{subst"+":pl}}");
  txt = txt.replace(/\{\{pt\}\}/g, "{{subst"+":pt}}");
  txt = txt.replace(/\{\{ro\}\}/g, "{{subst"+":ro}}");
  txt = txt.replace(/\{\{ru\}\}/g, "{{subst"+":ru}}");
  txt = txt.replace(/\{\{sa\}\}/g, "{{subst"+":sa}}");
  txt = txt.replace(/\{\{si\}\}/g, "{{subst"+":si}}");
  txt = txt.replace(/\{\{sk\}\}/g, "{{subst"+":sk}}");
  txt = txt.replace(/\{\{sl\}\}/g, "{{subst"+":sl}}");
  txt = txt.replace(/\{\{sm\}\}/g, "{{subst"+":sm}}");
  txt = txt.replace(/\{\{sq\}\}/g, "{{subst"+":sq}}");
  txt = txt.replace(/\{\{sr\}\}/g, "{{subst"+":sr}}");
  txt = txt.replace(/\{\{su\}\}/g, "{{subst"+":su}}");
  txt = txt.replace(/\{\{sv\}\}/g, "{{subst"+":sv}}");
  txt = txt.replace(/\{\{Sv\}\}/g, "{{subst"+":sv}}");
  txt = txt.replace(/\{\{sw\}\}/g, "{{subst"+":sw}}");
  txt = txt.replace(/\{\{ta\}\}/g, "{{subst"+":ta}}");
  txt = txt.replace(/\{\{te\}\}/g, "{{subst"+":te}}");
  txt = txt.replace(/\{\{th\}\}/g, "{{subst"+":th}}");
  txt = txt.replace(/\{\{tl\}\}/g, "{{subst"+":tl}}");
  txt = txt.replace(/\{\{tm\}\}/g, "{{subst"+":tm}}");
  txt = txt.replace(/\{\{tr\}\}/g, "{{subst"+":tr}}");
  txt = txt.replace(/\{\{tt\}\}/g, "{{subst"+":tt}}");
  txt = txt.replace(/\{\{ua\}\}/g, "{{subst"+":ua}}");
  txt = txt.replace(/\{\{ug\}\}/g, "{{subst"+":ug}}");
  txt = txt.replace(/\{\{uk\}\}/g, "{{subst"+":uk}}");
  txt = txt.replace(/\{\{ur\}\}/g, "{{subst"+":ur}}");
  txt = txt.replace(/\{\{uz\}\}/g, "{{subst"+":uz}}");
  txt = txt.replace(/\{\{vi\}\}/g, "{{subst"+":vi}}");
  txt = txt.replace(/\{\{vo\}\}/g, "{{subst"+":vo}}");
  txt = txt.replace(/\{\{wa\}\}/g, "{{subst"+":wa}}");
  txt = txt.replace(/\{\{xh\}\}/g, "{{subst"+":xh}}");
  txt = txt.replace(/\{\{yi\}\}/g, "{{subst"+":yi}}");
  txt = txt.replace(/\{\{yo\}\}/g, "{{subst"+":yo}}");
  txt = txt.replace(/\{\{zh\}\}/g, "{{subst"+":zh}}");
  txt = txt.replace(/\{\{zu\}\}/g, "{{subst"+":zu}}");
  txt = txt.replace(/\{\{alb\}\}/g, "{{subst"+":alb}}");
  txt = txt.replace(/\{\{ang\}\}/g, "{{subst"+":ang}}");
  txt = txt.replace(/\{\{arm\}\}/g, "{{subst"+":arm}}");
  txt = txt.replace(/\{\{arn\}\}/g, "{{subst"+":arn}}");
  txt = txt.replace(/\{\{ast\}\}/g, "{{subst"+":ast}}");
  txt = txt.replace(/\{\{bns\}\}/g, "{{subst"+":bns}}");
  txt = txt.replace(/\{\{bos\}\}/g, "{{subst"+":bos}}");
  txt = txt.replace(/\{\{chr\}\}/g, "{{subst"+":chr}}");
  txt = txt.replace(/\{\{cic\}\}/g, "{{subst"+":cic}}");
  txt = txt.replace(/\{\{cmn\}\}/g, "{{subst"+":cmn}}");
  txt = txt.replace(/\{\{fur\}\}/g, "{{subst"+":fur}}");
  txt = txt.replace(/\{\{gmh\}\}/g, "{{subst"+":gmh}}");
  txt = txt.replace(/\{\{goh\}\}/g, "{{subst"+":goh}}");
  txt = txt.replace(/\{\{got\}\}/g, "{{subst"+":got}}");
  txt = txt.replace(/\{\{grc\}\}/g, "{{subst"+":grc}}");
  txt = txt.replace(/\{\{haw\}\}/g, "{{subst"+":haw}}");
  txt = txt.replace(/\{\{kky\}\}/g, "{{subst"+":kky}}");
  txt = txt.replace(/\{\{kld\}\}/g, "{{subst"+":kld}}");
  txt = txt.replace(/\{\{mdf\}\}/g, "{{subst"+":mdf}}");
  txt = txt.replace(/\{\{nap\}\}/g, "{{subst"+":nap}}");
  txt = txt.replace(/\{\{nan\}\}/g, "{{subst"+":nan}}");
  txt = txt.replace(/\{\{non\}\}/g, "{{subst"+":non}}");
  txt = txt.replace(/\{\{pap\}\}/g, "{{subst"+":pap}}");
  txt = txt.replace(/\{\{pms\}\}/g, "{{subst"+":pms}}");
  txt = txt.replace(/\{\{rap\}\}/g, "{{subst"+":rap}}");
  txt = txt.replace(/\{\{scn\}\}/g, "{{subst"+":scn}}");
  txt = txt.replace(/\{\{sco\}\}/g, "{{subst"+":sco}}");
  txt = txt.replace(/\{\{tlh\}\}/g, "{{subst"+":tlh}}");
  txt = txt.replace(/\{\{tyv\}\}/g, "{{subst"+":tyv}}");
  txt = txt.replace(/\{\{vec\}\}/g, "{{subst"+":vec}}");
  txt = txt.replace(/\{\{wen\}\}/g, "{{subst"+":wen}}");
// to me, these next few need to be reviewed quite closely!  Obviously, not ISO 639-3.
       txt = txt.replace(/\{\{it-bo\}\}/g, "{{subst"+":it-bo}}");
       txt = txt.replace(/\{\{it-br\}\}/g, "{{subst"+":it-br}}");
       txt = txt.replace(/\{\{it-ge\}\}/g, "{{subst"+":it-ge}}");
       txt = txt.replace(/\{\{it-mn\}\}/g, "{{subst"+":it-mn}}");
       txt = txt.replace(/\{\{it-mo\}\}/g, "{{subst"+":it-mo}}");
       txt = txt.replace(/\{\{it-pr\}\}/g, "{{subst"+":it-pr}}");
       txt = txt.replace(/\{\{el-it\}\}/g, "{{subst"+":el-it}}");
       txt = txt.replace(/\{\{pt-br\}\}/g, "{{subst"+":pt-br}}");
       txt = txt.replace(/\{\{pt-pt\}\}/g, "{{subst"+":pt-pt}}");
       txt = txt.replace(/\{\{zh-tc\}\}/g, "{{subst"+":zh-tc}}");
     txt = txt.replace(/\{\{nl-vla\}\}/g, "{{subst"+":nl-vla}}");
   txt = txt.replace(/\{\{nap-cal\}\}/g, "{{subst"+":nap-cal}}");
   txt = txt.replace(/\{\{eml-rom\}\}/g, "{{subst"+":eml-rom}}");
   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'''{{subst" + ":PAGENAME}}'''\n\n\#");
  txt = txt.replace(/===Proper noun==[=]+\n\#/g, "===Proper noun===\n'''{{subst" + ":PAGENAME}}'''\n\n\#");

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

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

  txt = txt.replace(/===Phrase==[=]+\n\#/g, "===Phrase===\n{{infl|???|Phrasebook|head=[[{{subst" + ":PAGENAME}}]]}}\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'''{{subst" + ":PAGENAME}}'''\n\n\#");

  comment("{{infl}}");
}

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'''{{subst" + ":PAGENAME}}'''\n{{en-noun}}\n{{en-noun|sg=[[{{subst" + ":PAGENAME}}]]}}\n\n\#");

  txt = txt.replace(/===Proper noun==[=]+\n\#/g, "===Proper noun===\n{{en-proper noun}}\n\n\#");

  txt = txt.replace(/===Adjective==[=]+\n\#/g, "===Adjective===\n'''{{subst" + ":PAGENAME}}'''\n{{en-adj}}\n\n#");

  txt = txt.replace(/===Adverb==[=]+\n\#/g, "===Adverb===\n'''{{subst" + ":PAGENAME}}'''\n\n\#");

  txt = txt.replace(/===Phrase==[=]+\n\#/g, "===Phrase===\n{{infl|en|Phrasebook|head=[[{{subst" + ":PAGENAME}}]]}}\n\n\#");

//TODO: rework this section
  txt = txt.replace(/Verb==[=]+\n\#/gi, "Verb===\n'''{{subst" + ":PAGENAME}}'''\n{{en-verb|{{subst" + ":PAGENAME}}s|{{subst" + ":PAGENAME}}ing|{{subst" + ":PAGENAME}}ed}}\n\n\#");

  comment("{{infl}} (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}}, (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, "{{top}}");
  txt = txt.replace(/\{\| border=0 width=100\%\n\|-\n\|bgcolor=\"\#FFFFE0\" valign=top width=48\%\|\n\{\|/gi, "{{top}}");
  txt = txt.replace(/\{\| border=0  width=100\%\n\|-\n\|valign=top width=33\%\|\n\{\|/gi, "{{top3}}");
  txt = txt.replace(/\|\}\n\| width=1\% \|\n\|bgcolor=\"\#FFFFE0\" valign=top width=48\%\|\n\{\|/gi, "{{mid}}");
  txt = txt.replace(/\|\}\n\| width=1\% \|\n\|valign=top width=33\%\|\n\{\|/gi, "{{mid3}}");
  txt = txt.replace(/\|\}\n\|\}/gi, "{{bottom}}");

//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 {{top}}/{{bottom}}
//  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 !,"{{top}}"
	.f j=2:1:i i $d(x(j)) s c=c+1 w:c=cnt\2 !,"{{mid}}" 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 [[User:Connel MacKenzie/clean|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 = "[[User:Connel MacKenzie/clean|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 += "[[User:Connel MacKenzie/Format|fmt]]";
    }
    //document.editform.wpSummary.value += "+format";
    window.status = "...clicking the [Show changes] button...";
    setTimeout( "wiktClickMyDiff();", 2000 );
  }
}

$( superAutoFormat );

/* </noinclude></pre> */