Misplaced Pages

:AutoEd/htmltowikitext.js - Misplaced Pages

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< Misplaced Pages:AutoEd

This is an old revision of this page, as edited by Plastikspork (talk | contribs) at 22:27, 25 May 2020 (Per talk page). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Revision as of 22:27, 25 May 2020 by Plastikspork (talk | contribs) (Per talk page)(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

//Convert HTML to wikitext function autoEdHTMLtoWikitext(str) {

 // , , , and  tags
 str = str.replace(/<(B|STRONG)*>((?:|<*\/>|<(+)(?:| *)>*<\/\3>)*?)<\/\1*>/gi,  "$2");
 str = str.replace(/<(I|EM)*>((?:|<*\/>|<(+)(?:| *)>*<\/\3>)*?)<\/\1*>/gi,  "$2");
 // 
, <\br>, <br\>,
, ... str = str.replace(/<+BR*>/gim, '
'); str = str.replace(/<*BR*+*>/gim, '
'); // <.br>, <br.>,
, ... str = str.replace(/<*BR*>/gim, '
'); //
>, <
, <
> ... str = str.replace(/<*(<br*>)/gim, '$1'); str = str.replace(/(<br*>)*>/gim, '$1');

//


 str = str.replace(/()*<*HR*>/gi, '$1----');
 str = str.replace(/(.)<*HR*>/gi, '$1\n----');
 // Not really an HTML-to-wikitext fix, but close enough
 str = str.replace(/(\s*)<*REFERENCES*>/gim, '$1');
 // Repeated references tag
 str = str.replace(/()*\1/gim, '$1');

// Make sure

, ...,

is after a newline str = str.replace(/()*(<H*>)/gim, '$1\n$2'); // Make sure

, ..., is before a newline

 str = str.replace(/(<\/H*>)*()/gim, '$1\n$2');

// Remove newlines from inside

, ...,

var loopcount = 0; while( str.search( /<H()*>(?:|<\/?*>)*?<\/H\1*>/gim ) >= 0 && loopcount <= 10 ) { str = str.replace(/(<H)()(*>(?:|<\/?*>)*?)((?:|<\/?*>)*?<\/H)\2(*>)/gim, '$1$2$3 $4$2$5'); loopcount++; } // Replace

, ...,

with wikified section headings str = str.replace(/(^|)*<H1*>(*?)<\/H1*>*(|$)/gim, '$1=$2=$3'); str = str.replace(/(^|)*<H2*>(*?)<\/H2*>*(|$)/gim, '$1==$2==$3'); str = str.replace(/(^|)*<H3*>(*?)<\/H3*>*(|$)/gim, '$1===$2===$3'); str = str.replace(/(^|)*<H4*>(*?)<\/H4*>*(|$)/gim, '$1====$2====$3'); str = str.replace(/(^|)*<H5*>(*?)<\/H5*>*(|$)/gim, '$1=====$2=====$3'); str = str.replace(/(^|)*<H6*>(*?)<\/H6*>*(|$)/gim, '$1======$2======$3'); return str; }