User:Vildricianus/replace.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><nowiki>

// confer [[User:Vildricianus/Format]] for an explanation
// included in main file [[User:Vildricianus/monobook.js]]

// ================================================================
// furious text replacement script -- be friendly, it may bite
// partly nicked from [[User:Connel MacKenzie/monobook.js]]
// firefox with QuickJava extension may be useful,
// as it allows one-click javascript switch off
// ================================================================

function textReplace() {
  var oldtext = txt;
  // very first position
  txt = txt.replace(/  /g, " ");
  txt = txt.replace(/ \n/g, "\n");

  // comments
  txt = txt.replace(/\n\<\!--languages from J to Z go here--\>/g, "");
  txt = txt.replace(/\n\<\!--languages from A to I go here--\>/g, "");
  txt = txt.replace(/\<\!--languages from J to Z go here--\>/g, "");
  txt = txt.replace(/\<\!--languages from A to I go here--\>/g, "");

  // parentheses & colons
  //txt = txt.replace(/\'\'\(/g, "(''");
  //txt = txt.replace(/\)\'\'/g, "'')");
  //txt = txt.replace(/\):\'\'/g, "''):"); //remove colon later on
  // txt = txt.replace(/\}:/g, "}"); //conflict: {{ttbc|French}}:
  // txt = txt.replace(/\):/g, ")"); //conflict: (Cantonese):

  // removing/adding spaces
  txt = txt.replace(/ : /g, ": ");
  txt = txt.replace(/:\[/g, ": [");
  txt = txt.replace(/\* \[/g, "*[");
  txt = txt.replace(/\* \{/g, "*{");
  txt = txt.replace(/\=\= /g, "==");
  txt = txt.replace(/ \=\=/g, "==");

  // undo bad change
  //txt = txt.replace(/\'\'\)\'/g, ")'''");
  //txt = txt.replace(/\'\(\'\'/g, "'''(");

  // # + space
  txt = txt.replace(/\n#a/gi, "\n# A");
  txt = txt.replace(/\n#b/gi, "\n# B");
  txt = txt.replace(/\n#c/gi, "\n# C");
  txt = txt.replace(/\n#d/gi, "\n# D");
  txt = txt.replace(/\n#e/gi, "\n# E");
  txt = txt.replace(/\n#f/gi, "\n# F");
  txt = txt.replace(/\n#g/gi, "\n# G");
  txt = txt.replace(/\n#h/gi, "\n# H");
  txt = txt.replace(/\n#i/gi, "\n# I");
  txt = txt.replace(/\n#j/gi, "\n# J");
  txt = txt.replace(/\n#k/gi, "\n# K");
  txt = txt.replace(/\n#l/gi, "\n# L");
  txt = txt.replace(/\n#m/gi, "\n# M");
  txt = txt.replace(/\n#n/gi, "\n# N");
  txt = txt.replace(/\n#o/gi, "\n# O");
  txt = txt.replace(/\n#p/gi, "\n# P");
  txt = txt.replace(/\n#q/gi, "\n# Q");
  txt = txt.replace(/\n#r/gi, "\n# R");
  txt = txt.replace(/\n#s/gi, "\n# S");
  txt = txt.replace(/\n#t/gi, "\n# T");
  txt = txt.replace(/\n#u/gi, "\n# U");
  txt = txt.replace(/\n#v/gi, "\n# V");
  txt = txt.replace(/\n#w/gi, "\n# W");
  txt = txt.replace(/\n#x/gi, "\n# X");
  txt = txt.replace(/\n#y/gi, "\n# Y");
  txt = txt.replace(/\n#z/gi, "\n# Z");
  txt = txt.replace(/\n# a/gi, "\n# A");
  txt = txt.replace(/\n# b/gi, "\n# B");
  txt = txt.replace(/\n# c/gi, "\n# C");
  txt = txt.replace(/\n# d/gi, "\n# D");
  txt = txt.replace(/\n# e/gi, "\n# E");
  txt = txt.replace(/\n# f/gi, "\n# F");
  txt = txt.replace(/\n# g/gi, "\n# G");
  txt = txt.replace(/\n# h/gi, "\n# H");
  txt = txt.replace(/\n# i/gi, "\n# I");
  txt = txt.replace(/\n# j/gi, "\n# J");
  txt = txt.replace(/\n# k/gi, "\n# K");
  txt = txt.replace(/\n# l/gi, "\n# L");
  txt = txt.replace(/\n# m/gi, "\n# M");
  txt = txt.replace(/\n# n/gi, "\n# N");
  txt = txt.replace(/\n# o/gi, "\n# O");
  txt = txt.replace(/\n# p/gi, "\n# P");
  txt = txt.replace(/\n# q/gi, "\n# Q");
  txt = txt.replace(/\n# r/gi, "\n# R");
  txt = txt.replace(/\n# s/gi, "\n# S");
  txt = txt.replace(/\n# t/gi, "\n# T");
  txt = txt.replace(/\n# u/gi, "\n# U");
  txt = txt.replace(/\n# v/gi, "\n# V");
  txt = txt.replace(/\n# w/gi, "\n# W");
  txt = txt.replace(/\n# x/gi, "\n# X");
  txt = txt.replace(/\n# y/gi, "\n# Y");
  txt = txt.replace(/\n# z/gi, "\n# Z");

  txt = txt.replace(/\n#:\'\'\'Quotations\'\'\'/gi, "");

  txt = txt.replace(/\n#\[/g, "\n# [");
  txt = txt.replace(/\n#\{/g, "\n# {");
  txt = txt.replace(/\n#\(/g, "\n# (");
  txt = txt.replace(/\n#\'/g, "\n# '");
  txt = txt.replace(/\n#:\'\'/g, "\n#: ''");
  txt = txt.replace(/\n#:\*/g, "\n#*");

  // changing to templates, removing colons
      // scan for colons first position
      // parentheses weirdness gets fixed in first section
  txt = txt.replace(/\(\'\'intransitive\'\'\):/gi, "{{intransitive}}");
  txt = txt.replace(/\(\'\'intransitive\'\'\)/gi, "{{intransitive}}");
  txt = txt.replace(/\(\'\'transitive\'\'\):/gi, "{{transitive}}");
  txt = txt.replace(/\(\'\'transitive\'\'\)/gi, "{{transitive}}");
  txt = txt.replace(/\(\'\'transitive and intransitive\'\'\):/gi, "{{transitive}} & {{intransitive}}");
  txt = txt.replace(/\(\'\'transitive and intransitive\'\'\)/gi, "{{transitive}} & {{intransitive}}");
  txt = txt.replace(/\(\'\'intransitive and transitive\'\'\):/gi, "{{transitive}} & {{intransitive}}");
  txt = txt.replace(/\(\'\'intransitive and transitive\'\'\)/gi, "{{transitive}} & {{intransitive}}");
  txt = txt.replace(/\(\'\'reflexive\'\'\):/gi, "{{reflexive}}");
  txt = txt.replace(/\(\'\'reflexive\'\'\)/gi, "{{reflexive}}");

  txt = txt.replace(/\[\[countable\]\]:/gi, "{{countable}}");
  txt = txt.replace(/\[\[uncountable\]\]:/gi, "{{uncountable}}");
  txt = txt.replace(/\(\'\'countable\'\'\):/gi, "{{countable}}");
  txt = txt.replace(/\(\'\'countable\'\'\)/gi, "{{countable}}");
  txt = txt.replace(/\(\'\'uncountable\'\'\):/gi, "{{uncountable}}");
  txt = txt.replace(/\(\'\'uncountable\'\'\)/gi, "{{uncountable}}");
  txt = txt.replace(/\(\'\'\[\[uncountable\]\]\'\'\)/gi, "{{uncountable}}");
  txt = txt.replace(/\(\'\'\[\[uncountable noun\]\]\'\'\)/gi, "{{uncountable}}");
  txt = txt.replace(/\(\[\[uncountable\]\]\)/gi, "{{uncountable}}");
  txt = txt.replace(/\(\[\[uncountable noun\]\]\)/gi, "{{uncountable}}");
  txt = txt.replace(/\(\'\'\[\[countable\]\]\'\'\)/gi, "{{countable}}");
  txt = txt.replace(/\(\'\'\[\[countable noun\]\]\'\'\)/gi, "{{countable}}");
  txt = txt.replace(/\(\[\[countable\]\]\)/gi, "{{countable}}");
  txt = txt.replace(/\(\[\[countable noun\]\]\)/gi, "{{countable}}");

  txt = txt.replace(/# \(\'\'archaic\'\'\):/gi, "# {{archaic}}");
  txt = txt.replace(/# \(\'\'archaic\'\'\)/gi, "# {{archaic}}");
  txt = txt.replace(/# \(\'\'dated\'\'\):/gi, "# {{dated}}");
  txt = txt.replace(/# \(\'\'dated\'\'\)/gi, "# {{dated}}");
  txt = txt.replace(/# \(\'\'obsolete\'\'\):/gi, "# {{obsolete}}");
  txt = txt.replace(/# \(\'\'obsolete\'\'\)/gi, "# {{obsolete}}");
  txt = txt.replace(/# \(\'\'vulgar\'\'\):/gi, "# {{vulgar}}");
  txt = txt.replace(/# \(\'\'vulgar\'\'\)/gi, "# {{vulgar}}");
  txt = txt.replace(/# \(\'\'rare\'\'\):/gi, "# {{rare}}");
  txt = txt.replace(/# \(\'\'rare\'\'\)/gi, "# {{rare}}");
  txt = txt.replace(/# \(\'\'slang\'\'\):/gi, "# {{slang}}");
  txt = txt.replace(/# \(\'\'slang\'\'\)/gi, "# {{slang}}");
  txt = txt.replace(/# \(\'\'formal\'\'\):/gi, "# {{formal}}");
  txt = txt.replace(/# \(\'\'formal\'\'\)/gi, "# {{formal}}");
  txt = txt.replace(/# \(formal\)/gi, "# {{formal}}");
  txt = txt.replace(/# \(\'\'informal\'\'\):/gi, "# {{informal}}");
  txt = txt.replace(/# \(\'\'informal\'\'\)/gi, "# {{informal}}");
  txt = txt.replace(/# \(informal\)/gi, "# {{informal}}");
  txt = txt.replace(/# \(\'\'US\'\'\):/gi, "# {{US}}");
  txt = txt.replace(/# \(\'\'US\'\'\)/gi, "# {{US}}");
  txt = txt.replace(/# \(\'\'UK\'\'\):/gi, "# {{UK}}");
  txt = txt.replace(/# \(\'\'UK\'\'\)/gi, "# {{UK}}");
  txt = txt.replace(/# \(\'\'colloquial\'\'\):/gi, "# {{colloquial}}");
  txt = txt.replace(/# \(\'\'colloquial\'\'\)/gi, "# {{colloquial}}");
  txt = txt.replace(/# \(\'\'euphemism\'\'\):/gi, "# {{euphemism}}");
  txt = txt.replace(/# \(\'\'euphemism\'\'\)/gi, "# {{euphemism}}");
  txt = txt.replace(/# \(\'\'figurative\'\'\):/gi, "# {{figurative}}");
  txt = txt.replace(/# \(\'\'figurative\'\'\)/gi, "# {{figurative}}");
  txt = txt.replace(/# \(\'\'figuratively\'\'\):/gi, "# {{figurative}}");
  txt = txt.replace(/# \(\'\'figuratively\'\'\)/gi, "# {{figurative}}");
  txt = txt.replace(/# \(\'\'fig\'\'\):/gi, "# {{figurative}}");
  txt = txt.replace(/# \(\'\'fig\'\'\)/gi, "# {{figurative}}");

  // topics, listed alphabetically()
  txt = txt.replace(/\(\'\'advertising\'\'\):/gi, "{{advertising}}");
  txt = txt.replace(/\(\'\'advertising\'\'\)/gi, "{{advertising}}");
  txt = txt.replace(/\(\'\'algebra\'\'\):/gi, "{{algebra}}");
  txt = txt.replace(/\(\'\'algebra\'\'\)/gi, "{{algebra}}");
  txt = txt.replace(/\(\'\'archaeology\'\'\):/gi, "{{archaeology}}");
  txt = txt.replace(/\(\'\'archaeology\'\'\)/gi, "{{archaeology}}");
  txt = txt.replace(/\(\'\'architecture\'\'\):/gi, "{{architecture}}");
  txt = txt.replace(/\(\'\'architecture\'\'\)/gi, "{{architecture}}");
  txt = txt.replace(/\(\'\'arithmetic\'\'\):/gi, "{{arithmetic}}");
  txt = txt.replace(/\(\'\'arithmetic\'\'\)/gi, "{{arithmetic}}");
  txt = txt.replace(/\(\'\'art\'\'\):/gi, "{{art}}");
  txt = txt.replace(/\(\'\'art\'\'\)/gi, "{{art}}");
  txt = txt.replace(/\(\'\'astrology\'\'\):/gi, "{{astrology}}");
  txt = txt.replace(/\(\'\'astrology\'\'\)/gi, "{{astrology}}");
  txt = txt.replace(/\(\'\'biology\'\'\):/gi, "{{biology}}");
  txt = txt.replace(/\(\'\'biology\'\'\)/gi, "{{biology}}");
  txt = txt.replace(/\(\'\'botany\'\'\):/gi, "{{botany}}");
  txt = txt.replace(/\(\'\'botany\'\'\)/gi, "{{botany}}");
  txt = txt.replace(/\(\'\'chemistry\'\'\):/gi, "{{chemistry}}");
  txt = txt.replace(/\(\'\'chemistry\'\'\)/gi, "{{chemistry}}");
  txt = txt.replace(/\(\'\'computing\'\'\):/gi, "{{computing}}");
  txt = txt.replace(/\(\'\'computing\'\'\)/gi, "{{computing}}");

  // of course, don't forget cricket 
  txt = txt.replace(/\(\'\'cricket\'\'\):/gi, "{{cricket}}");
  txt = txt.replace(/\(\'\'cricket\'\'\)/gi, "{{cricket}}");

  txt = txt.replace(/\(\'\'curling\'\'\):/gi, "{{curling}}");
  txt = txt.replace(/\(\'\'curling\'\'\)/gi, "{{curling}}");
  txt = txt.replace(/\(\'\'geology\'\'\):/gi, "{{geology}}");
  txt = txt.replace(/\(\'\'geology\'\'\)/gi, "{{geology}}");
  txt = txt.replace(/\(\'\'geography\'\'\):/gi, "{{geography}}");
  txt = txt.replace(/\(\'\'geography\'\'\)/gi, "{{geography}}");
  txt = txt.replace(/\(\'\'geometry\'\'\):/gi, "{{geometry}}");
  txt = txt.replace(/\(\'\'geometry\'\'\)/gi, "{{geometry}}");
  txt = txt.replace(/\(\'\'grammar\'\'\):/gi, "{{grammar}}");
  txt = txt.replace(/\(\'\'grammar\'\'\)/gi, "{{grammar}}");
  txt = txt.replace(/\(\'\'heraldry\'\'\):/gi, "{{heraldry}}");
  txt = txt.replace(/\(\'\'heraldry\'\'\)/gi, "{{heraldry}}");
  txt = txt.replace(/\(\'\'internet\'\'\):/gi, "{{internet}}");
  txt = txt.replace(/\(\'\'internet\'\'\)/gi, "{{internet}}");
  txt = txt.replace(/\(\'\'law\'\'\):/gi, "{{law}}");
  txt = txt.replace(/\(\'\'law\'\'\)/gi, "{{law}}");
  txt = txt.replace(/\(\'\'lexicography\'\'\):/gi, "{{lexicography}}");
  txt = txt.replace(/\(\'\'lexicography\'\'\)/gi, "{{lexicography}}");
  txt = txt.replace(/\(\'\'linguistics\'\'\):/gi, "{{linguistics}}");
  txt = txt.replace(/\(\'\'linguistics\'\'\)/gi, "{{linguistics}}");
  txt = txt.replace(/\(\'\'logic\'\'\):/gi, "{{logic}}");
  txt = txt.replace(/\(\'\'logic\'\'\)/gi, "{{logic}}");
  txt = txt.replace(/\(\'\'mathematics\'\'\):/gi, "{{mathematics}}");
  txt = txt.replace(/\(\'\'mathematics\'\'\)/gi, "{{mathematics}}");
  txt = txt.replace(/\(\'\'math\'\'\):/gi, "{{mathematics}}");
  txt = txt.replace(/\(\'\'math\'\'\)/gi, "{{mathematics}}");
  txt = txt.replace(/\(\'\'maths\'\'\):/gi, "{{mathematics}}");
  txt = txt.replace(/\(\'\'maths\'\'\)/gi, "{{mathematics}}");
  txt = txt.replace(/\(\'\'mechanics\'\'\):/gi, "{{mechanics}}");
  txt = txt.replace(/\(\'\'mechanics\'\'\)/gi, "{{mechanics}}");
  txt = txt.replace(/\(\'\'medicine\'\'\):/gi, "{{medicine}}");
  txt = txt.replace(/\(\'\'medicine\'\'\)/gi, "{{medicine}}");
  txt = txt.replace(/\(\'\'military\'\'\):/gi, "{{military}}");
  txt = txt.replace(/\(\'\'military\'\'\)/gi, "{{military}}");
  txt = txt.replace(/\(\'\'mineralogy\'\'\):/gi, "{{mineralogy}}");
  txt = txt.replace(/\(\'\'mineralogy\'\'\)/gi, "{{mineralogy}}");
  txt = txt.replace(/\(\'\'music\'\'\):/gi, "{{music}}");
  txt = txt.replace(/\(\'\'music\'\'\)/gi, "{{music}}");
  txt = txt.replace(/\(\'\'mythology\'\'\):/gi, "{{mythology}}");
  txt = txt.replace(/\(\'\'mythology\'\'\)/gi, "{{mythology}}");
  txt = txt.replace(/\(\'\'nautical\'\'\):/gi, "{{nautical}}");
  txt = txt.replace(/\(\'\'nautical\'\'\)/gi, "{{nautical}}");
  txt = txt.replace(/\(\'\'physics\'\'\):/gi, "{{physics}}");
  txt = txt.replace(/\(\'\'physics\'\'\)/gi, "{{physics}}");
  txt = txt.replace(/\(\'\'physiology\'\'\):/gi, "{{physiology}}");
  txt = txt.replace(/\(\'\'physiology\'\'\)/gi, "{{physiology}}");
  txt = txt.replace(/\(\'\'sports\'\'\):/gi, "{{sports}}");
  txt = txt.replace(/\(\'\'sports\'\'\)/gi, "{{sports}}");
  txt = txt.replace(/\(\'\'theology\'\'\):/gi, "{{theology}}");
  txt = txt.replace(/\(\'\'theology\'\'\)/gi, "{{theology}}");
  txt = txt.replace(/\(\'\'zoology\'\'\):/gi, "{{zoology}}");
  txt = txt.replace(/\(\'\'zoology\'\'\)/gi, "{{zoology}}");

  //txt = txt.replace(/\(\'\'colour\'\'\):/gi, "{{colour}}");
  //txt = txt.replace(/\(\'\'colour\'\'\)/gi, "{{colour}}");
  //txt = txt.replace(/\(colour\):/gi, "{{colour}}");
  //txt = txt.replace(/\(colour\)/gi, "{{colour}}");

  txt = txt.replace(/\(\'\'historic\'\'\):/gi, "{{historical}}");
  txt = txt.replace(/\(\'\'historic\'\'\)/gi, "{{historical}}");
  txt = txt.replace(/\{\{historic\}\}:/gi, "{{historical}}");
  txt = txt.replace(/\{\{historic\}\}/gi, "{{historical}}");
  txt = txt.replace(/\(\'\'historical\'\'\):/gi, "{{historical}}");
  txt = txt.replace(/\(\'\'historical\'\'\)/gi, "{{historical}}");
  txt = txt.replace(/\(\'\'historically\'\'\):/gi, "{{historical}}");
  txt = txt.replace(/\(\'\'historically\'\'\)/gi, "{{historical}}");

  // gender and number templates
  txt = txt.replace(/''m''/g, "{{m}}");
  txt = txt.replace(/''f''/g, "{{f}}");
  txt = txt.replace(/''n''/g, "{{n}}");
  txt = txt.replace(/''c''/g, "{{c}}");
  txt = txt.replace(/''p''/g, "{{p}}");
  txt = txt.replace(/''pl''/g, "{{p}}");
  txt = txt.replace(/''s''/g, "{{s}}");
  txt = txt.replace(/''m, f''/g, "{{m}}, {{f}}");
  txt = txt.replace(/''m,f''/g, "{{m}}, {{f}}");
  txt = txt.replace(/''m, n''/g, "{{m}}, {{n}}");
  txt = txt.replace(/''m,n''/g, "{{m}}, {{n}}");
  txt = txt.replace(/''f, n''/g, "{{f}}, {{n}}");
  txt = txt.replace(/''f,n''/g, "{{f}}, {{n}}");
  txt = txt.replace(/''m\/f''/g, "{{m}}, {{f}}");
  txt = txt.replace(/''m\/n''/g, "{{m}}, {{n}}");
  txt = txt.replace(/''f\/n''/g, "{{f}}, {{n}}");
  txt = txt.replace(/''m s''/g, "{{m}} {{s}}");
  txt = txt.replace(/''f s''/g, "{{f}} {{s}}");
  txt = txt.replace(/''n s''/g, "{{f}} {{s}}");
  txt = txt.replace(/''m pl''/g, "{{m}} {{p}}");
  txt = txt.replace(/''f pl''/g, "{{f}} {{p}}");
  txt = txt.replace(/''n pl''/g, "{{n}} {{p}}");
  txt = txt.replace(/''m plural''/g, "{{m}} {{p}}");
  txt = txt.replace(/''f plural''/g, "{{f}} {{p}}");
  //txt = txt.replace(/''singular''/g, "{{s}}");

  // no en:POS categories
      // before blank lines
  txt = txt.replace(/\[\[category:/gi, "[[Category:");
  txt = txt.replace(/\[\[category: /gi, "[[Category:");

  txt = txt.replace(/\[\[Category:English language\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:English nouns\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:English verbs\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:English adjectives\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:English adverbs\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:English transitive verbs\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:English intransitive verbs\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:English countable nouns\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:English abstract nouns\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:English concrete nouns\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:English collective nouns\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:Countable\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:Uncountable\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:English proper nouns\]\]\n/gi, "");
  txt = txt.replace(/\[\[Category:English slang\]\]\n/gi, "");

  txt = txt.replace(/\}\n\[\[category:/gi, "}\n\n[[Category:");

  // blank lines 
     // always blank after inflection line
     txt = txt.replace(/\'\'\'\n#/g, "'''\n\n#");
     txt = txt.replace(/\}\}\n#/g, "\}\}\n\n#");
     // txt = txt.replace(/\'\'\'\)\n#/g, "'''\)\n\n#");

     // undo bad change
     txt = txt.replace(/\'\'\'\n\n#:/g, "'''\n#:");
     txt = txt.replace(/\}\}\n\n#:/g, "}}\n#:");

     // always a blank immediately before level 3 or higher
     txt = txt.replace(/\n\=\=\=/g, "\n\n===");
     txt = txt.replace(/\n\n\n\=\=\=/g, "\n\n===");

     // no blank immediately after level 3 or higher
     txt = txt.replace(/\=\=\=\n\n/g, "===\n");

     // multiple etyms
     txt = txt.replace(/\=\=\=\n\=\=\=\=/g, "===\n\n====");

     // txt = txt.replace(/\=\n\n\'\'\'/g, "=\n'''");

  // headers
  txt = txt.replace(/==quotations==/gi, "==Quotations==");
  txt = txt.replace(/==quotation==/gi, "==Quotations==");
  txt = txt.replace(/==quotes==/gi, "==Quotations==");
  txt = txt.replace(/==quote==/gi, "==Quotations==");
  txt = txt.replace(/==citations==/gi, "==Quotations==");
  txt = txt.replace(/==citation==/gi, "==Quotations==");
  txt = txt.replace(/==adjective==/gi, "==Adjective==");
  txt = txt.replace(/==\[\[adjective\]\]==/gi, "==Adjective==");
  txt = txt.replace(/==adverb==/gi, "==Adverb==");
  txt = txt.replace(/==\[\[adverb\]\]==/gi, "==Adverb==");
  txt = txt.replace(/==antonym==/gi, "==Antonyms==");
  txt = txt.replace(/==\[\[antonym\]\]==/gi, "==Antonyms==");
  txt = txt.replace(/==antonyms==/gi, "==Antonyms==");
  txt = txt.replace(/==\[\[antonyms\]\]==/gi, "==Antonyms==");
  txt = txt.replace(/==cardinal number==/gi, "==Cardinal number==");
  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(/==etymology==/gi, "==Etymology==");
  txt = txt.replace(/==\[\[etymology\]\]==/gi, "==Etymology==");
  txt = txt.replace(/==letter==\n/gi, "===Letter===\n");
  txt = txt.replace(/==noun==/gi, "==Noun==");
  txt = txt.replace(/==\[\[noun\]\]==/gi, "==Noun==");
  txt = txt.replace(/==noun phrase==/gi, "==Noun==");
  txt = txt.replace(/==\[\[noun phrase\]\]==/gi, "==Noun==");
  txt = txt.replace(/==pronunciation==/gi, "==Pronunciation==");
  txt = txt.replace(/==\[\[pronunciation\]\]==/gi, "==Pronunciation==");
  txt = txt.replace(/==pronounciation==/gi, "==Pronunciation==");
  txt = txt.replace(/==\[\[pronounciation\]\]==/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(/==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(/==related word==/gi, "==Related terms==");
  txt = txt.replace(/==\[\[related word\]\]==/gi, "==Related terms==");
  txt = txt.replace(/==related words==/gi, "==Related terms==");
  txt = txt.replace(/==\[\[related words\]\]==/gi, "==Related terms==");
  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(/==synonym==/gi, "==Synonyms==");
  txt = txt.replace(/==\[\[synonym\]\]==/gi, "==Synonyms==");
  txt = txt.replace(/==synonyms==/gi, "==Synonyms==");
  txt = txt.replace(/==\[\[synonyms\]\]==/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(/==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(/==verb==/gi, "==Verb==");
  txt = txt.replace(/==\[\[verb\]\]==/gi, "==Verb==");
  txt = txt.replace(/==forms and variants==/gi, "==Alternative spellings==");
  txt = txt.replace(/==variant form==/gi, "==Alternative spellings==");
  txt = txt.replace(/==variant forms==/gi, "==Alternative spellings==");
  txt = txt.replace(/==alternate form==/gi, "==Alternative spellings==");
  txt = txt.replace(/==alternate forms==/gi, "==Alternative spellings==");
  txt = txt.replace(/==alternative form==/gi, "==Alternative spellings==");
  txt = txt.replace(/==alternative forms==/gi, "==Alternative spellings==");
  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(/==Quotations==\n/gi, "====Quotations====\n");
  txt = txt.replace(/===Quotations===\n/gi, "====Quotations====\n");
  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(/===Derived terms===\n/gi, "====Derived terms====\n");
  txt = txt.replace(/==Etymology==\n/gi, "===Etymology===\n");
  txt = txt.replace(/==Noun==\n/gi, "===Noun===\n");
  txt = txt.replace(/==Pronunciation==\n/gi, "===Pronunciation===\n");
  txt = txt.replace(/==See also==\n/gi, "===See also===\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(/==Antonyms==\n/gi, "====Antonyms====\n");
  txt = txt.replace(/===Antonyms===\n/gi, "====Antonyms====\n");
  txt = txt.replace(/==Synonyms==\n/gi, "====Synonyms====\n");
  txt = txt.replace(/===Synonyms===\n/gi, "====Synonyms====\n");
  txt = txt.replace(/==Translations==\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(/===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");

  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(/===transitive verb===\n/gi, "===Verb===\n{{transitive}} ");
  txt = txt.replace(/====transitive verb====\n/gi, "====Verb====\n{{transitive}} ");
  txt = txt.replace(/===intransitive verb===\n/gi, "===Verb===\n{{intransitive}} ");
  txt = txt.replace(/====intransitive verb====\n/gi, "====Verb====\n{{intransitive}} ");

  txt = txt.replace(/====translations to be checked====\n/gi, "=====Translations to be checked=====\n");
  txt = txt.replace(/====translations to be categorized====\n/gi, "=====Translations to be checked=====\n");
  txt = txt.replace(/=====translations to be categorized=====\n/gi, "=====Translations to be checked=====\n");
  txt = txt.replace(/======translations to be categorized======\n/gi, "======Translations to be checked======\n");

  // automatic translation table
  txt = txt.replace(/Translations====\n\*/g, "Translations====\n{{top}}\n{{mid}}\n{{bottom}}\n\*");
  txt = txt.replace(/Translations=====\n\*/g, "Translations=====\n{{top}}\n{{mid}}\n{{bottom}}\n\*");

  // dewikification major languages
  txt = txt.replace(/\*\[\[Albanian\]\]:/gi, "*Albanian:");
  txt = txt.replace(/\*\[\[Arabic\]\]:/gi, "*Arabic:");
  txt = txt.replace(/\*\[\[Armenian\]\]:/gi, "*Armenian:");
  txt = txt.replace(/\*\[\[Belarusian\]\]:/gi, "*Belarusian:");
  txt = txt.replace(/\*\[\[Bosnian\]\]:/gi, "*Bosnian:");
  txt = txt.replace(/\*\[\[Bulgarian\]\]:/gi, "*Bulgarian:");
  txt = txt.replace(/\*\[\[Chinese\]\]:/gi, "*Chinese:");
  txt = txt.replace(/\*\[\[Croatian\]\]:/gi, "*Croatian:");
  txt = txt.replace(/\*\[\[Czech\]\]:/gi, "*Czech:");
  txt = txt.replace(/\*\[\[Danish\]\]:/gi, "*Danish:");
  txt = txt.replace(/\*\[\[Dutch\]\]:/gi, "*Dutch:");
  txt = txt.replace(/\*\[\[Estonian\]\]:/gi, "*Estonian:");
  txt = txt.replace(/\*\[\[Hungarian\]\]:/gi, "*Hungarian:");
  txt = txt.replace(/\*Farsi:/gi, "*Persian:");
  txt = txt.replace(/\*\[\[Farsi\]\]:/gi, "*Persian:");
  txt = txt.replace(/\*\[\[Finnish\]\]:/gi, "*Finnish:");
  txt = txt.replace(/\*\[\[French\]\]:/gi, "*French:");
  txt = txt.replace(/\*\[\[German\]\]:/gi, "*German:");
  txt = txt.replace(/\*\[\[Georgian\]\]:/gi, "*Georgian:");
  txt = txt.replace(/\*\[\[Greek\]\]:/gi, "*Greek:");
  txt = txt.replace(/\*\[\[Hebrew\]\]:/gi, "*Hebrew:");
  txt = txt.replace(/\*\[\[Hungarian\]\]:/gi, "*Hungarian:");
  txt = txt.replace(/\*\[\[Icelandic\]\]:/gi, "*Icelandic:");
  txt = txt.replace(/\*\[\[Indonesian\]\]:/gi, "*Indonesian:");
  txt = txt.replace(/\*\[\[Italian\]\]:/gi, "*Italian:");
  txt = txt.replace(/\*\[\[Japanese\]\]:/gi, "*Japanese:");
  txt = txt.replace(/\*\[\[Korean\]\]:/gi, "*Korean:");
  txt = txt.replace(/\*\[\[Latin\]\]:/gi, "*Latin:");
  txt = txt.replace(/\*\[\[Latvian\]\]:/gi, "*Latvian:");
  txt = txt.replace(/\*\[\[Lithuanian\]\]:/gi, "*Lithuanian:");
  txt = txt.replace(/\*\[\[Norwegian\]\]:/gi, "*Norwegian:");
  txt = txt.replace(/\*\[\[Persian\]\]:/gi, "*Persian:");
  txt = txt.replace(/\*\[\[Polish\]\]:/gi, "*Polish:");
  txt = txt.replace(/\*\[\[Portuguese\]\]:/gi, "*Portuguese:");
  txt = txt.replace(/\*\[\[Romanian\]\]:/gi, "*Romanian:");
  txt = txt.replace(/\*\[\[Russian\]\]:/gi, "*Russian:");
  txt = txt.replace(/\*\[\[Serbian\]\]:/gi, "*Serbian:");
  txt = txt.replace(/\*\[\[Slovak\]\]:/gi, "*Slovak:");

          // don't be a POV pusher for once
  txt = txt.replace(/\*\[\[Slovene\]\]:/gi, "*Slovene:");
  txt = txt.replace(/\*\[\[Slovenian\]\]:/gi, "*Slovenian:");

  txt = txt.replace(/\*\[\[Spanish\]\]:/gi, "*Spanish:");
  txt = txt.replace(/\*\[\[Swedish\]\]:/gi, "*Swedish:");
  txt = txt.replace(/\*\[\[Translingual\]\]:/gi, "*Translingual:");
  txt = txt.replace(/\*\[\[Turkish\]\]:/gi, "*Turkish:");
  txt = txt.replace(/\*\[\[Vietnamese\]\]:/gi, "*Vietnamese:");

  //
  txt = txt.replace(/\# third-person/gi, "# third person");
  txt = txt.replace(/\# plural of/gi, "# {{plural of|}}");
  txt = txt.replace(/\# third person of/gi, "# {{third-person singular of|}}");
  txt = txt.replace(/\# third person singular of/gi, "# {{third-person singular of|}}");
  txt = txt.replace(/\# third person singular present of/gi, "# {{third-person singular of|}}");
  txt = txt.replace(/\# third person singular simple present of/gi, "# {{third-person singular of|}}");
  txt = txt.replace(/\# present participle of/gi, "# {{present participle of|}}");
  txt = txt.replace(/\# past tense of/gi, "# {{past of|}}");
  txt = txt.replace(/\# past and past participle of/gi, "# {{past of|}}");
  txt = txt.replace(/\# past tense and past participle of/gi, "# {{past of|}}");
  txt = txt.replace(/\# simple past and past participle of/gi, "# {{past of|}}");
  txt = txt.replace(/\# simple past tense and past participle of/gi, "# {{past of|}}");
  txt = txt.replace(/\# simple past of/gi, "# {{simple past of|}}");
  txt = txt.replace(/\# past participle of/gi, "# {{past participle of|}}");


  // lowercasing
  txt = txt.replace(/\{\{Wikipedia\}\}/g, "{{wikipedia}}");

  // infl line between header and defs
      // keep below see also's
  txt = txt.replace(/\=\n#/gi, "=\n'''{{subst:PAGENAME}}'''\n\n#");

  // language templates
  txt = txt.replace(/\{\{af\}\}/g, "{{subst"+":af}}");
  txt = txt.replace(/\{\{alb\}\}/g, "{{subst"+":alb}}");
  txt = txt.replace(/\{\{am\}\}/g, "{{subst"+":am}}");
  txt = txt.replace(/\{\{an\}\}/g, "{{subst"+":an}}");
  txt = txt.replace(/\{\{ang\}\}/g, "{{subst"+":ang}}");
  txt = txt.replace(/\{\{ar\}\}/g, "{{subst"+":ar}}");
  txt = txt.replace(/\{\{arm\}\}/g, "{{subst"+":arm}}");
  txt = txt.replace(/\{\{arn\}\}/g, "{{subst"+":arn}}");
  txt = txt.replace(/\{\{ast\}\}/g, "{{subst"+":ast}}");
  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(/\{\{bns\}\}/g, "{{subst"+":bns}}");
  txt = txt.replace(/\{\{bos\}\}/g, "{{subst"+":bos}}");
  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(/\{\{chr\}\}/g, "{{subst"+":chr}}");
  txt = txt.replace(/\{\{cic\}\}/g, "{{subst"+":cic}}");
  txt = txt.replace(/\{\{cr\}\}/g, "{{subst"+":cr}}");
  txt = txt.replace(/\{\{cs\}\}/g, "{{subst"+":cs}}");
  txt = txt.replace(/\{\{cy\}\}/g, "{{subst"+":cy}}");
  txt = txt.replace(/\{\{da\}\}/g, "{{subst"+":da}}");
  txt = txt.replace(/\{\{de\}\}/g, "{{subst"+":de}}");
  txt = txt.replace(/\{\{el\}\}/g, "{{subst"+":el}}");
  txt = txt.replace(/\{\{en\}\}/g, "{{subst"+":en}}");
  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(/\{\{fe\}\}/g, "{{subst"+":fe}}");
  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(/\{\{fur\}\}/g, "{{subst"+":fur}}");
  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(/\{\{gmh\}\}/g, "{{subst"+":gmh}}");
  txt = txt.replace(/\{\{gn\}\}/g, "{{subst"+":gn}}");
  txt = txt.replace(/\{\{goh\}\}/g, "{{subst"+":goh}}");
  txt = txt.replace(/\{\{got\}\}/g, "{{subst"+":got}}");
  txt = txt.replace(/\{\{gr\}\}/g, "{{subst"+":gr}}");
  txt = txt.replace(/\{\{grc\}\}/g, "{{subst"+":grc}}");
  txt = txt.replace(/\{\{gu\}\}/g, "{{subst"+":gu}}");
  txt = txt.replace(/\{\{gv\}\}/g, "{{subst"+":gv}}");
  txt = txt.replace(/\{\{haw\}\}/g, "{{subst"+":haw}}");
  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(/\{\{kky\}\}/g, "{{subst"+":kky}}");
  txt = txt.replace(/\{\{kld\}\}/g, "{{subst"+":kld}}");
  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(/\{\{mdf\}\}/g, "{{subst"+":mdf}}");
  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(/\{\{nap\}\}/g, "{{subst"+":nap}}");
  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(/\{\{non\}\}/g, "{{subst"+":non}}");
  txt = txt.replace(/\{\{oc\}\}/g, "{{subst"+":oc}}");
  txt = txt.replace(/\{\{pap\}\}/g, "{{subst"+":pap}}");
  txt = txt.replace(/\{\{pl\}\}/g, "{{subst"+":pl}}");
  txt = txt.replace(/\{\{pms\}\}/g, "{{subst"+":pms}}");
  txt = txt.replace(/\{\{pt\}\}/g, "{{subst"+":pt}}");
  txt = txt.replace(/\{\{rap\}\}/g, "{{subst"+":rap}}");
  txt = txt.replace(/\{\{ro\}\}/g, "{{subst"+":ro}}");
  txt = txt.replace(/\{\{ru\}\}/g, "{{subst"+":ru}}");
  txt = txt.replace(/\{\{sa\}\}/g, "{{subst"+":sa}}");
  txt = txt.replace(/\{\{scn\}\}/g, "{{subst"+":scn}}");
  txt = txt.replace(/\{\{sco\}\}/g, "{{subst"+":sco}}");
  txt = txt.replace(/\{\{se\}\}/g, "{{subst"+":se}}");
  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(/\{\{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(/\{\{tlh\}\}/g, "{{subst"+":tlh}}");
  txt = txt.replace(/\{\{tm\}\}/g, "{{subst"+":tm}}");
  txt = txt.replace(/\{\{tr\}\}/g, "{{subst"+":tr}}");
  txt = txt.replace(/\{\{tt\}\}/g, "{{subst"+":tt}}");
  txt = txt.replace(/\{\{tyv\}\}/g, "{{subst"+":tyv}}");
  txt = txt.replace(/\{\{ua\}\}/g, "{{subst"+":ua}}");
  txt = txt.replace(/\{\{uk\}\}/g, "{{subst"+":uk}}");
  txt = txt.replace(/\{\{ur\}\}/g, "{{subst"+":ur}}");
  txt = txt.replace(/\{\{uz\}\}/g, "{{subst"+":uz}}");
  txt = txt.replace(/\{\{vec\}\}/g, "{{subst"+":vec}}");
  txt = txt.replace(/\{\{vi\}\}/g, "{{subst"+":vi}}");
  txt = txt.replace(/\{\{vo\}\}/g, "{{subst"+":vo}}");
  txt = txt.replace(/\{\{wa\}\}/g, "{{subst"+":wa}}");
  txt = txt.replace(/\{\{wen\}\}/g, "{{subst"+":wen}}");
  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}}");

  // pronunciations
        // first position
  txt = txt.replace(/\[\[w:SAMPA\|SAMPA\]\]: \/\<tt\>(.*)\<\/tt\>\//g, "{{SAMPA|/$1/}}");
  txt = txt.replace(/SAMPA: \/\<tt\>(.*)\<\/tt\>\//g, "{{SAMPA|/$1/}}");
  txt = txt.replace(/SAMPA:\/\<tt\>(.*)\<\/tt\>\//g, "{{SAMPA|/$1/}}");
  txt = txt.replace(/\/\<tt\>(.*)\<\/tt\>\//g, "{{SAMPA|/$1/}}");

  txt = txt.replace(/\[\[w:AHD\|AHD\]\] (.*)/g, "{{AHD|$1}}");
  txt = txt.replace(/\[\[w:AHD\|AHD\]\] \/(.*)\//g, "{{AHD|$1}}");
  txt = txt.replace(/\[\[w:IPA\|IPA\]\] \/(.*)\//g, "{{IPA|/$1/}}");
  txt = txt.replace(/\[\[w:SAMPA\|SAMPA\]\] \/(.*)\//g, "{{SAMPA|/$1/}}");
  txt = txt.replace(/\[\[w:AHD\|AHD\]\]: (.*)/g, "{{AHD|$1}}");
  txt = txt.replace(/\[\[w:AHD\|AHD\]\]: \/(.*)\//g, "{{AHD|$1}}");
  txt = txt.replace(/\[\[w:IPA\|IPA\]\]: \/(.*)\//g, "{{IPA|/$1/}}");
  txt = txt.replace(/\[\[w:SAMPA\|SAMPA\]\]: \/(.*)\//g, "{{SAMPA|/$1/}}");
  txt = txt.replace(/\[\[w:AHD\|AHD\]\]:(.*)/g, "{{AHD|$1}}");
  txt = txt.replace(/\[\[w:AHD\|AHD\]\]:\/(.*)\//g, "{{AHD|$1}}");
  txt = txt.replace(/\[\[w:IPA\|IPA\]\]:\/(.*)\//g, "{{IPA|/$1/}}");
  txt = txt.replace(/\[\[w:SAMPA\|SAMPA\]\]:\/(.*)\//g, "{{SAMPA|/$1/}}");
  txt = txt.replace(/\[\[AHD\]\] (.*)/g, "{{AHD|$1}}");
  txt = txt.replace(/\[\[AHD\]\] \/(.*)\//g, "{{AHD|$1}}");
  txt = txt.replace(/\[\[IPA\]\] \/(.*)\//g, "{{IPA|/$1/}}");
  txt = txt.replace(/\[\[SAMPA\]\] \/(.*)\//g, "{{SAMPA|/$1/}}");
  txt = txt.replace(/\[\[AHD\]\]: (.*)/g, "{{AHD|$1}}");
  txt = txt.replace(/\[\[AHD\]\]: \/(.*)\//g, "{{AHD|$1}}");
  txt = txt.replace(/\[\[IPA\]\]: \/(.*)\//g, "{{IPA|/$1/}}");
  txt = txt.replace(/\[\[SAMPA\]\]: \/(.*)\//g, "{{SAMPA|/$1/}}");
  txt = txt.replace(/\[\[AHD\]\]:(.*)/g, "{{AHD|$1}}");
  txt = txt.replace(/\[\[AHD\]\]:\/(.*)\//g, "{{AHD|$1}}");
  txt = txt.replace(/\[\[IPA\]\]:\/(.*)\//g, "{{IPA|/$1/}}");
  txt = txt.replace(/\[\[SAMPA\]\]:\/(.*)\//g, "{{SAMPA|/$1/}}");
  txt = txt.replace(/AHD: (.*)/g, "{{AHD|$1}}");
  txt = txt.replace(/AHD: \/(.*)\//g, "{{AHD|$1}}");
  txt = txt.replace(/IPA: \/(.*)\//g, "{{IPA|/$1/}}");
  txt = txt.replace(/SAMPA: \/(.*)\//g, "{{SAMPA|/$1/}}");
  txt = txt.replace(/AHD:(.*)/g, "{{AHD|$1}}");
  txt = txt.replace(/AHD:\/(.*)\//g, "{{AHD|$1}}");
  txt = txt.replace(/IPA:\/(.*)\//g, "{{IPA|/$1/}}");
  txt = txt.replace(/SAMPA:\/(.*)\//g, "{{SAMPA|/$1/}}");

             // always last position !
  txt = txt.replace(/\=\n\{\{IPA\|/g, "=\n\*{{IPA|");
  txt = txt.replace(/\=\n\{\{SAMPA\|/g, "=\n\*{{SAMPA|");
  txt = txt.replace(/\=\n\{\{AHD\|/g, "=\n\*{{AHD|");

  // hr
  txt = txt.replace(/----\n\=\=/g, "----\n\n==");

  // text
  txt = txt.replace(/''Plural:''/gi, "''plural''");
          // Serbian: Latin -> Roman
  txt = txt.replace(/\*:Latin:/gi, "*:Roman:");

     // no multiple blank lines
     txt = txt.replace(/\n\n\n/g, "\n\n");
     txt = txt.replace(/\n\n\n\n/g, "\n\n");
     txt = txt.replace(/\n\n\n\n\n/g, "\n\n");
     txt = txt.replace(/\n\n\n\n\n\n/g, "\n\n");
     txt = txt.replace(/\n\n\n\n\n\n\n/g, "\n\n");
     txt = txt.replace(/\n\n\n\n\n\n\n\n/g, "\n\n");
     txt = txt.replace(/\n\n\n\n\n\n\n\n\n/g, "\n\n");

}

function autoFormat() {
  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, "_");

  if (pagetitle.search(/\:/) != -1) {
    return;
  }

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

  textReplace();

  if (txt==" ") txt = "";
  document.editform.wpTextbox1.value = txt;

  oldtxt = myoldtxt;
  if (txt != oldtxt) {
    if (document.editform.wpSummary.value == "")
    document.editform.wpDiff.click();
  }
}


function reformatMyPage() {
   autoFormat();
}

window.myAddOnload=function(f) {
  if (window.addEventListener) window.addEventListener("load", f, false);
  else if (window.attachEvent) window.attachEvent("onload",f);
}

myAddOnload(reformatMyPage);

// </nowiki></pre>