User:Mglovesfun/vector.js: difference between revisions

From Wiktionary, the free dictionary
Jump to navigation Jump to search
Content deleted Content added
Mglovesfun (talk | contribs)
mNo edit summary
Mglovesfun (talk | contribs)
m remove spaces before and after a bar (|)
Line 109: Line 109:


//Text replacement other than replacing headers and template redirects, which come later on
//Text replacement other than replacing headers and template redirects, which come later on
txt = txt.replace(/\ \|/g, "\|");
txt = txt.replace(/\|\ /g, "\|");
txt = txt.replace(/\ \n/g, "\n");
txt = txt.replace(/\ \n/g, "\n");
txt = txt.replace(/\=\= /g, "==");
txt = txt.replace(/\=\= /g, "==");

Revision as of 12:34, 15 November 2011

// THE FOLLOWING IS BASED ON [[User:Msh210/vector.js]] BUT HAS BEEN MODIFIED SINCE. THANKS MSH210!
//importScript('Transwiki:Gadget-HotCat.js');
importScript('User:Lupin/autoedit.js', 'en.wikipedia.org','46637295');//needed for other things
importScript('User:Conrad.Irwin/creation.js');//automates inflected-form creation; requires autoedit.js
importScript('User:Conrad.Irwin/isblocked.js');//nice display if user's blocked
document.cookie="WiktNearbyPagesLangHeadings=true";//restricts nearbypages to header not navbar
importScript('User:Ruakh/WiktEtylAlwaysLink.js');//link etyl's langnames
importScript('User:Yair rand/checktbotentries.js');
importScript('User:Yair rand/checktransremove.js');
importScript('User:Yair rand/languagenametocode.js');
GPE.deleteReasonIfBlank = "\[\[Wiktionary\:Sysop deleted\|\-\-explanation of deletion\-\-\]\]";
//start stuff copied from [[User:Connel_MacKenzie/clock.js]] and modified
function makeTime()
{
  var timeGMT = new Date();
  var time = timeGMT.toUTCString();
  var li = document.createElement( 'li' );
  li.id = 't-time';
  li.appendChild( document.createTextNode( time ) );
  var ul=document.getElementById('t-upload');
  ul.parentNode.insertBefore(li,ul);
}
addOnloadHook( makeTime );
// end stuff from User:Connel_MacKenzie/clock.js
/* begin stuff copied from [[User:Connel MacKenzie/reformat.js]] and amended */
function minorFormat() {

//subst: useless templates
  txt = txt.replace(/\{\{fr-adj-(al|en|eux)\|/gi, "{"+"{subst:fr-adj-$1|");
  txt = txt.replace(/\{\{(plural|singular)\}\}/gi, "{"+"{subst:$1}}");

//Convert infl to language-specific template
  txt = txt.replace(/\{\{infl\|(de|es|fr|it)\|adverb\}\}/gi, "{{$1-adv}}");
  txt = txt.replace(/\{\{infl\|(de|en|es|fr|pt)\|proper noun\}\}/gi, "{{$1-proper noun}}");
  txt = txt.replace(/\{\{infl\|(de|fr|it)\|verb\}\}/gi, "{{$1-verb}}");
  txt = txt.replace(/\{\{infl\|en\|adjective\}\}/gi, "{{en-adj|?}}");
  txt = txt.replace(/\{\{infl\|en\|adverb\}\}/gi, "{{en-adv|?}}");
  txt = txt.replace(/\{\{infl\|en\|conjunction\}\}/gi, "{{en-con}}");
  txt = txt.replace(/\{\{infl\|en\|noun\}\}/gi, "{{en-noun|?}}");
  txt = txt.replace(/\{\{infl\|fr\|adjective form\}\}/gi, "{{fr-adj-form}}");
  txt = txt.replace(/\{\{infl\|fr\|preposition\}\}/gi, "{{fr-prep}}");
  txt = txt.replace(/\{\{infl\|(es|fr|pt)\|verb form\}\}/gi, "{{$1-verb-form}}");
//Cyrillic script
  txt = txt.replace(/\{\{infl\|(ba|be|ce|bg|kk|ky|lez|mk|ru|uk)\|noun(\}\}|\|tr=|\|g=)/gi, "{{$1-noun$2");
  txt = txt.replace(/\{\{infl\|(bg|ru)\|proper noun(\}\}|\|tr=|\|g=)/gi, "{{$1-proper noun$2");

  txt = txt.replace(/\{\{en\-(adj|adv|noun|plural\-noun|pronoun|verb|verb form)\|(current|pos|sg)=/gi, "{{en-$1|head=");

//Merge gender and number templates
  txt = txt.replace(/\{\{m\}\} \{\{s\}\}/gi, "{{m|s}}");
  txt = txt.replace(/\{\{m\}\} \{\{p\}\}/gi, "{{m|p}}");
  txt = txt.replace(/\{\{m\}\} \{\{f\}\}/gi, "{{m|f}}");
  txt = txt.replace(/\{\{f\}\} \{\{s\}\}/gi, "{{f|s}}");
  txt = txt.replace(/\{\{f\}\} \{\{p\}\}/gi, "{{f|p}}");
  txt = txt.replace(/\{\{n\}\} \{\{p\}\}/gi, "{{n|p}}");
  txt = txt.replace(/\{\{n\}\} \{\{s\}\}/gi, "{{n|s}}");
  txt = txt.replace(/\{\{m\}\} \{\{f\|p\}\}/gi, "{{m|f|p}}");
  txt = txt.replace(/\{\{m\|f\}\} \{\{p\}\}/gi, "{{m|f|p}}");
  txt = txt.replace(/\{\{m\}\} \{\{inv\}\}/gi, "{{m|inv}}");
  txt = txt.replace(/\{\{f\}\} \{\{inv\}\}/gi, "{{f|inv}}");
  txt = txt.replace(/\{\{m\}\} \{\{f\|inv\}\}/gi, "{{m|f|inv}}");
  txt = txt.replace(/\{\{m\|f\}\} \{\{inv\}\}/gi, "{{m|f|inv}}");

//Convert *: to * before {{audio}}, {{homophones}}, {{IPA}} and {{rhymes}}
  txt = txt.replace(/\*\: \{\{(audio|homophones|IPA|rhymes)(\||\})/gi, "* {{$1$2");

//Replace obsolete IPA characters
  txt = txt.replace(/ʣ/gi, "dz");
  txt = txt.replace(/ʤ/gi, "dʒ");
  txt = txt.replace(/ʥ/gi, "dʑ");
  txt = txt.replace(/ʧ/gi, "tʃ");
  txt = txt.replace(/ʦ/gi, "ts");
  txt = txt.replace(/ʨ/gi, "tɕ");

//Adding {{qualifier}}. In some cases, you'll want to switch qualifier to context or gloss
  txt=txt.replace(/\(''([a-zA-Z\ \-\,\:\;][a-zA-Z\ \-\,\:\;]*)''\)/g, "{{qualifier|$1}}");//converts (''foo'') to {{qualifier|foo}}
  txt=txt.replace(/''\(([a-zA-Z\ \-\,\:\;][a-zA-Z\ \-\,\:\;]*)\)''/g, "{{qualifier|$1}}");//converts ''(foo)'' to {{qualifier|foo}}
  txt=txt.replace(/\{\{qualifier\|([a-zA-Z\ \-\,\:\;][a-zA-Z\ \-\,\:\;]*)\}\}\:/g, "{{sense|$1}}");//converts {{qualifier|foo}}: to {{sense|foo}}
  txt = txt.replace(/''British''/gi, "{{qualifier|British}}");
  txt = txt.replace(/''UK''/gi, "{{qualifier|UK}}");
  txt = txt.replace(/''US''/gi, "{{qualifier|US}}");

//Remove wikilinks from some common {{form of}} templates, but not piped links
  txt = txt.replace(/\{\{([\ -9\;-\\\^-z\}-ퟻ\-]+) of\|\[\[([\ -9\;-\\\^-z\}-ퟻ]+)\]\](\||\}\})/gi, "{{$1 of|$2$3");

//Actual {{form of}}
  txt = txt.replace(/\{\{form of\|([\ -9\;-\\\^-z\}-ퟻ]+)\|\[\[([\ -9\;-\\\^-z\}-ퟻ]+)\]\](\||\})/gi, "{{form of|$1|$2$3");

//Convert {{etyl|la|en}} to {{etyl|la}} (la being an example for Latin in this case). Only works for 2 or 3 letter codes, with no extra parameters like sort
  txt = txt.replace(/\{\{etyl\|([a-z]{2,3})\|en\}\}/gi, "{{etyl|$1}}");

//Add {{homophones}}
 txt=txt.replace(/([hH])omophones\: \[\[([\ -9\;-\\\^-z\}-ퟻ]+)\]\]/g, "{{homophones|$2}}");
//If two
 txt=txt.replace(/\{\{homophones\|([\ -9\;-\\\^-z\}-ퟻ]+)\}\}, \[\[([\ -9\;-\\\^-z\}-ퟻ]+)\]\]/g, "{{homophones|$1|$2}}");

//Add lang=en to several templates. Change by hand if required
  txt = txt.replace(/\{\{(defn|etystub|rfc|rfd|rfe|rfp|rfap|rfdef|rfv|rfv\-etymology|rfv\-pronunciation)\}\}/g, "{{$1|lang=en}}");
//Put {{wikipedia}} under ==English== header, not above it
  txt=txt.replace(/\{\{wikipedia\}\}\n==English==/g, "==English==\n{{wikipedia}}");
  txt=txt.replace(/\{\{wikipedia\}\}\n=/g, "{{wikipedia}}\n\n=");

//Serbo-Croatian stuff. Official with respect to categories (no Bosnian, Croatian or Serbian categories) but unofficial elsewhere.
  txt=txt.replace(/\{\{hr\-noun\|/g, "{{sh-noun|r|g=");

//Bullet point before certain templates:

  txt = txt.replace(/\n\{\{(AHD|audio|enPR|IPA|homophones|pedia|pedialite|rhyme|SAMPA|seeCites|X\-SAMPA)(\||\}\})/g, "\n* {{$1$2");

//Text replacement other than replacing headers and template redirects, which come later on
  txt = txt.replace(/\ \|/g, "\|");
  txt = txt.replace(/\|\ /g, "\|");
  txt = txt.replace(/\ \n/g, "\n");
  txt = txt.replace(/\=\= /g, "==");
  txt = txt.replace(/ \=\=/g, "==");
  txt = txt.replace(/\n\n\n/g, "\n\n");
  txt = txt.replace(/==\n==/g, "==\n\n==");
  txt = txt.replace(/\-\-\-\-\n=/g, "----\n\n=");
  txt = txt.replace(/==\n\n([a-zA-Z\*|\[|\{'])/g, "==\n$1");
  txt = txt.replace(/\n\=(\=*)([A-ȳ\ ]*)(\=*)\<\!/g, "\n=$1$2$3\n<!");
  txt = txt.replace(/===\n\'\'\'(.*)\'\'\'\n#/gi, "===\n'''$1'''\n\n#");
  txt = txt.replace(/===\n\{\{(.*)\}\}\n#/gi, "===\n{{$1}}\n\n#");
  txt = txt.replace(/\{\{PAGENAME\}\}/gi, "{"+"{subst:PAGENAME}}");
  txt = txt.replace(/ ''m''/g, " {{m}}");
  txt = txt.replace(/''m'' /g, "{{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(/\*(\ *)'''([1-9][0-9][0-9]*)'''\:/g, "* '''$2''',");
  txt = txt.replace(/\*(\ *)'''([1-9][0-9][0-9]*)\:'''/g, "* '''$2''',");
  txt=txt.replace(/\ (\ *)/g, " ");
  txt=txt.replace(/\n([\*\#\:\;]+)(\ *)([\'\{\[a-zA-Z])/g, "\n$1 $3");//Thanks, Conrad.Irwin.
  txt=txt.replace(/\n\{\{template\:PL\:/g, "\n* {"+"{template:PL:");//as previous
  txt=txt.replace(/\n\{\{pedia([\}\|])/g, "\n* {{pedia$1");
  txt=txt.replace(/\n\{\{versity([\}\|])/g, "\n* {{versity$1");
  txt=txt.replace(/\{\{form\ of\|([a-zA-Z\ \-\,\'\[\]\(\)\"\/]*)\ of\|/g, "{"+"{form of|$1|");
  txt=txt.replace(/\{\{defn([\}\|])/g, "{"+"{rfdef$1");//straight swap
  txt=txt.replace(/\{\{onym([\}\|])/g, "{"+"{l$1");//straight swap
  txt = txt.replace(/lang=Italian/gi, "lang=it");
  txt = txt.replace(/(first|First|second|Second|third|Third) person (singular|plural)/gi, "$1-person $2");
  txt = txt.replace(/Sinhala/gi, "Sinhalese");//Common misuse of secondary language name
  txt = txt.replace(/\[\[(WS|WikiSaurus)\:/gi, "[[Wikisaurus:");
  txt = txt.replace(/\#\:\*/gi, "#:");

//Redirect snaps for non-context labels. Only works when editing an entire page, not a section
//Uses a fairly simple regex system, thus can occasionally cause problems. If so, do section editing only
//Achieves not a lot, slows down editing, and has to be updated any time one of these templates is renamed
 txt=txt.replace(/\{\{alt spell\|/g, "{"+"{alternative spelling of|");
 txt=txt.replace(/\{\{alternate form of\|/g, "{"+"{alternative form of|");
 txt=txt.replace(/\{\{alternate spelling of\|/g, "{"+"{alternative spelling of|");
 txt=txt.replace(/([\|\{])bottom2([\}\|])/g, "$1bottom$2");
 txt=txt.replace(/([\|\{])(checktrans\-mid|reqtrans\-mid|ttbc\-mid)([\}\|])/g, "$1trans-mid$3");
 txt=txt.replace(/([\|\{])(checktrans\-bottom|reqtrans\-bottom|ttbc\-bot|ttbc\-bottom)([\}\|])/g, "$1trans-bottom$3");
 txt=txt.replace(/\{\{cmn\-def\|/g, "{"+"{pinyin reading of|");
 txt=txt.replace(/\{\{(en|fr)\-adjective([\}\|])/g, "{"+"{$1-adj$1");
 txt=txt.replace(/\{\{(en|fr)\-adverb([\}\|])/g, "{"+"{$1-adv$2");
 txt=txt.replace(/\{\{en\-conjunction([\}\|])/g, "{"+"{en-con$1");
 txt=txt.replace(/\{\{en\-conj([\}\|])/g, "{"+"{en-con$1");
 txt=txt.replace(/\{\{en\-interjection([\|\}])/g, "{"+"{en-interj$1");
 txt=txt.replace(/\{\{en\-intj([\|\}])/g, "{"+"{en-interj$1");
 txt=txt.replace(/\{\{en\-particle([\}\|])/g, "{"+"{en-part$1");
 txt=txt.replace(/\{\{en\-preposition([\}\|])/g, "{"+"{en-prep$1");
 txt=txt.replace(/\{\{en\-plural\-noun([\}\|])/g, "{"+"{en-plural noun$1");
 txt=txt.replace(/\{\{en\-pronoun([\}\|])/g, "{"+"{en-pron$1");
 txt=txt.replace(/\{\{en\-adj\-more([\}\|])/g, "{"+"{en-adj$1");
 txt=txt.replace(/\{\{en\-proper\-noun([\}\|])/g, "{"+"{en-proper noun$1");
 txt=txt.replace(/\{\{eye dialect([\|\}])/g, "{"+"{eye dialect of$1");
 txt=txt.replace(/\{\{Flowbreak([\|\}])/g, "{"+"{flowbreak$1");
 txt=txt.replace(/\{\{fr\-pp([\}\|])/g, "{"+"{fr-past participle$1");
 txt=txt.replace(/\{\{fr\-verb form([\}\|])/g, "{"+"{fr-verb-form$1");
 txt=txt.replace(/\{\{i([\}\|])/g, "{"+"{qualifier$1");
 txt=txt.replace(/\{\{italbrac([\|\}])/g, "{"+"{qualifier$1");//straight swap
 txt=txt.replace(/\{\{i-c([\|\}])/g, "{"+"{sense$1");
 txt=txt.replace(/\{\{italbrac-colon([\|\}])/g, "{"+"{sense$1");
 txt=txt.replace(/\{\{non gloss definition([\|\}])/g, "{"+"{non-gloss definition$1");
 txt=txt.replace(/\{\{n\-g([\|\}])/g, "{"+"{non-gloss definition$1");
 txt=txt.replace(/\{\{PL\:pedia([\}\|])/g, "{"+"{pedia$1");
 txt=txt.replace(/\{\{pf\}\}/g, "{"+"{pf.}}");
 txt=txt.replace(/([\|\{])R\:ANOLH([\}\|])/g, "$1R:Anglo-Norman On-Line Hub$2");
 txt=txt.replace(/\{\{see also\|/g, "{"+"{also|");
 txt=txt.replace(/\{\{sic([\|\}])/g, "{"+"{SIC$1");
 txt=txt.replace(/\{\{sic\.([\|\}])/g, "{"+"{SIC$1");
 txt=txt.replace(/\{\{Wikipedia([\|\}])/g, "{"+"{wikipedia$1");
 txt=txt.replace(/\{\{Wikipedia\-inline([\}\|])/g, "{"+"{pedia$1");
 txt=txt.replace(/\{\{xalso\|/g, "{"+"{xsee|");
 txt=txt.replace(/\{\{zh\-forms\|/g, "{"+"{Hani-forms|");
//the next two lines have to be after the "alt spell" snap above

 txt=txt.replace(/\n\#\ \{\{obsolete\}\}\ \{\{alternative spelling of\|/g, "\n# {"+"{obsolete spelling of|");
 txt=txt.replace(/\n\#\ \{\{archaic\}\}\ \{\{alternative spelling of\|/g, "\n# {"+"{archaic spelling of|");

//Snapping context redirects
 txt=txt.replace(/\{\{art\}\}/g, "{"+"{arts}}");
 txt=txt.replace(/([\|\{])Bible([\}\|])/g, "$1biblical$2");
 txt=txt.replace(/([\|\{])carbohydrate([\}\|])/g, "$1carbohydrates$2");
 txt=txt.replace(/([\|\{])christianity([\}\|])/g, "$1Christianity$2");
 txt=txt.replace(/([\|\{])Colloquial([\}\|])/g, "$1colloquial$2");
 txt=txt.replace(/([\|\{])communications([\}\|])/g, "$1communication$2");
 txt=txt.replace(/([\|\{])Communication([\}\|])/g, "$1communication$2");
 txt=txt.replace(/([\|\{])([Cc])omptheory([\}\|])/g, "$1computing theory$3");
 txt=txt.replace(/([\|\{])computer([\}\|])/g, "$1computing$2");
 txt=txt.replace(/([\|\{])computer programming([\}\|])/g, "$1programming$2");
 txt=txt.replace(/([\|\{])computers([\}\|])/g, "$1computing$2");
 txt=txt.replace(/([\|\{])euphemism([\}\|])/g, "$1euphemistic$2");
 txt=txt.replace(/([\|\{])greek mythology([\}\|])/g, "$1Greek mythology$2");
 txt=txt.replace(/([\|\{])GUI([\}\|])/g, "$1graphical user interface$2");
 txt=txt.replace(/([\|\{])([iI])diom([\}\|])/g, "$1idiomatic$3");
 txt=txt.replace(/(\{\{infl\|[a-z]{2,3}\|)idiomatic([\}\|])/g, "$1idiom$2");//converts {{infl|foo|idiomatic}} back to {{infl|foo|idiom}}
 txt=txt.replace(/([\|\{])indef([\}\|])/g, "$1indefinite$2");
 txt=txt.replace(/([\|\{])in plural([\}\|])/g, "$1in the plural$2");
 txt=txt.replace(/([\|\{])internet([\}\|])/g, "$1Internet$2");
 txt=txt.replace(/([\|\{])jocular([\}\|])/g, "$1humorous$2");
 txt=txt.replace(/([\|\{])Law([\}\|])/g, "$1legal$2");
 txt=txt.replace(/([\|\{])([mM])ath([\}\|])/g, "$1mathematics$3");
 txt=txt.replace(/([\|\{])maths([\}\|])/g, "$1mathematics$2");
 txt=txt.replace(/([\|\{])medical([\}\|])/g, "$1medicine$2");
 txt=txt.replace(/([\|\{])Military([\}\|])/g, "$1military$2");
 txt=txt.replace(/([\|\{])musici([\}\|])/g, "$1musical instruments$2");
 txt=txt.replace(/([\|\{])Nautical([\}\|])/g, "$1nautical$2");
 txt=txt.replace(/([\|\{])Obsolete([\}\|])/g, "$1obsolete$2");
 txt=txt.replace(/([\|\{])organic compound([\}\|])/g, "$1organic compounds$2");
 txt=txt.replace(/([\|\{])planetary science([\}\|])/g, "$1planetology$2");
 txt=txt.replace(/([\|\{])pluralia tantum([\}\|])/g, "$1plurale tantum$2");
 txt=txt.replace(/([\|\{])police([\}\|])/g, "$1law enforcement$2");
 txt=txt.replace(/([\|\{])([sS])cifi([\}\|])/g, "$1science fiction$3");
 txt=txt.replace(/([\|\{])space([\}\|])/g, "$1space science$2");
 txt=txt.replace(/([\|\{])sport([\}\|])/g, "$1sports$2");
 txt=txt.replace(/([\|\{])Theology([\}\|])/g, "$1theology$2");
 txt=txt.replace(/([\|\{])theatre([\}\|])/g, "$1theater$2");
//Redirect snaps based on dialects/regional vocabulary
 txt=txt.replace(/([\|\{])American([\}\|])/g, "$1US$2");
 txt=txt.replace(/([\|\{])AU([\}\|])/g, "$1Australia$2");
 txt=txt.replace(/([\|\{])Australian([\}\|])/g, "$1Australia$2");
 txt=txt.replace(/([\|\{])Canadian([\}\|])/g, "$1Canada$2");
 txt=txt.replace(/([\|\{])Canadian English([\}\|])/g, "$1Canada$2");
 txt=txt.replace(/([\|\{])CockneyRS([\}\|])/g, "$1Cockney rhyming slang$2");
 txt=txt.replace(/([\|\{])Indian([\}\|])/g, "$1India$2");
 txt=txt.replace(/([\|\{])North American([\}\|])/g, "$1North America$2");
 txt=txt.replace(/([\|\{])New Zealand English([\}\|])/g, "$1New Zealand$2");
 txt=txt.replace(/([\|\{])NZ([\}\|])/g, "$1New Zealand$2");
 txt=txt.replace(/([\|\{])Scottish([\}\|])/g, "$1Scotland$2");
 txt=txt.replace(/([\|\{])Scottish English([\}\|])/g, "$1Scotland$2");
 txt=txt.replace(/([\|\{])USA([\}\|])/g, "$1US$2");
//A few redirects to non-categorizing template redirects
 txt=txt.replace(/([\|\{])figurative([\}\|])/g, "$1figuratively$2");
 txt=txt.replace(/([\|\{])literal([\}\|])/g, "$1literally$2");
 txt=txt.replace(/([\|\{])metaphorical([\}\|])/g, "$1figuratively$2");

//Remove {{context| before some common labels; too many to list all of them. Must be listed here after redirect snaps
  txt = txt.replace(/\{\{context\|(archaic|biology|botany|chemistry|colloquial|countable|formal|geography|geology|history|idiomatic|informal|intransitive|mathematics|music|obsolete|physics|slang|sports|transitive|UK|uncountable|US|vulgar)([\}\|])/gi, "{{$1$2");
}
 
// get all the {-header-} templates replaced
function headLevel() {
  txt = txt.replace(/==adjective form==/gi, "==Adjective==");
  txt = txt.replace(/==(alternative spellings|alternate forms)==/gi, "==Alternative forms==");
  txt = txt.replace(/==cardinal numeral==/gi, "==Cardinal number==");
  txt = txt.replace(/==citations==/gi, "==Quotations==");
  txt = txt.replace(/==derivation==/gi, "==Etymology==");
  txt = txt.replace(/==note==/gi, "==Usage notes==");
  txt = txt.replace(/==notes==/gi, "==Usage notes==");
  txt = txt.replace(/==NOun==/gi, "==Noun==");
  txt = txt.replace(/==noun form==/gi, "==Noun==");
  txt = txt.replace(/==(pinyin|pinyin syllable)==/gi, "==Romanization==");
  txt = txt.replace(/==proper Noun==/gi, "==Proper noun==");
  txt = txt.replace(/==ordinal numeral==/gi, "==Ordinal number==");
  txt = txt.replace(/==reference==/gi, "==References==");
  txt = txt.replace(/==translation==/gi, "==Translations==");
  txt = txt.replace(/==usage==/gi, "==Usage notes==");
  txt = txt.replace(/==variants==/gi, "==Alternative forms==");
  txt = txt.replace(/==verb form==/gi, "==Verb==");
  txt = txt.replace(/==chinese==/gi, "==Mandarin==");//Chinese will usually refer to Mandarin. If the templates aren't cmn, change by hand
//Fix User:2.125.74.117 stuff
  txt = txt.replace(/==see Also==/gi, "==See also==");
  txt = txt.replace(/\n====Also See====\n/gi, "{"+"{subst:blank}}");
//Header levels, L3 to L4
  txt=txt.replace(/\n===(Antonyms|Coordinate terms|Derived terms|Descendants|Related terms|Synonyms|Translations|Usage notes)===\n/gi, "\n====$1====\n");
//Header levels, L2 to L3
  txt=txt.replace(/\n==(Etymology|References|See also)==\n/gi, "\n===$1===\n");
}

function langHdrs() {
  txt=txt.replace(/\n==(=*)([a-z])/gi, "\n==$1$2".toUpperCase() );
  txt=txt.replace(/==\[\[([a-zA-ZÀ-ž\-\ ]+)\]\]==/g, "==$1==");
}

function langSubsts() {
  txt=txt.replace(/([=\ \*\:])\{\{([a-z]{2,3})\}\}/g, "$1{{subst"+":#ifexist:{{subst:"+"$2|l=}}|{{etyl|$2|-}}|{{"+"$2}}}}");
}

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

function superAutoFormat() {
  // get page title
  pagetitle = document.getElementById('content').getElementsByTagName('h1').item(0).firstChild.nodeValue;
  //if (pagetitle.search(/Editing /) != 0) return;
    switch(wgAction){case 'submit': case 'edit': break; default: return};
 
  // is this in the main namespace?  If not, stop.
  if (wgNamespaceNumber) return;

  // If editing a section, skip all of everything.
  if (pagetitle.search(/\(section\)/) != -1) return;
 
  txt = " " + document.editform.wpTextbox1.value;
  txt = txt.substr (1, txt.length-1);
  oldtxt = txt;
  if (txt.length < 2) txt = " " + txt;
 
  //safety valves
  if (txt.search(/^#redirect \[/i) != -1) return;
 
    minorFormat(); //minor format problems that must be dealt with first
    langHdrs();    //swap 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
 
 if (txt == " ") txt = "";
 
 document.editform.wpTextbox1.value = txt;

  if (txt != oldtxt) {
    window.status = "...clicking the [Show changes] button...";
    setTimeout( "wiktClickMyDiff();", 2000 );
  }
}
 
addOnloadHook( superAutoFormat );
/* end stuff copied from User:Connel MacKenzie/reformat.js */