跳转到内容

User:Ricky Lau/fixWikiAutofix.js

维基百科,自由的百科全书

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。

/*<nowiki>
	fixWikiAutofix.js - Autofix specific problem
	Author: Ricky Lau (RickyLauKO [at] GMail [dot] Com)
	Last modified: 2009-06-01T13:30Z

	This file should not be edited unless you know what these syntax exactly do
*/

var fiwAutofixes = [];

// Error code 001: Lack of bold title
var wgBasePageName = wgTitle.split (/\//).first ();
fiwAutofixes.push ({ find: new RegExp ('^' + wgBasePageName, 'ig'), pattern: new RegExp (wgBasePageName, 'i'), replace: "'''" + wgBasePageName + "'''", code: 1, description: fiwText.lackBold });

// Error code 002: Inappropriate <br/> tags
fiwAutofixes.push ({ find: /.{1,30}[<]+[^ <]*[ ]*br[ ]*[\/]*[^ ]?>/ig, pattern: /[<]+[^ <]*[ ]*br[ ]*[\/]*[^ ]?>/i, replace: '<br/>', check: /[<]+[^ <]*[ ]*br[ ]*[\/]*[^ ]?>/ig, valid: /<br[ ]*\/>/g, code: 2, description: fiwText.brTags });

// Error code 008: Irregular headlines
// fiwAutofixes.push ({ find: /^[=]{1,6}[^=]+[==]{1,6}[^\n]+/ig, pattern: /([=]+)[ ]*([^==]+)[ ]*[==]*([^\n]+)/i, replace: '$1$ $2 1\n$3', code: 8, description: fiwText.irregularHeadlines });
//fiwAutofixes.push ({ find: /\n[=]{1,6}[^=]+[==]{1,6}[^\n]+/ig, pattern: /([=]+)[ ]*([^==]+)[ ]*[==]*([^\n]+)/i, replace: '$1 $2 $1\n$3', code: 8, description: fiwText.irregularHeadlines });

// Error code 019: Level one headlines
fiwAutofixes.push ({ find: /^=[^=]+=/ig, pattern: /=[ ]*([^=]+)[ ]*=/i, replace: '\n== $1 ==\n', code: 19, description: fiwText.lv1Headlines });
fiwAutofixes.push ({ find: /\n=[^=]+=/ig, pattern: /=[ ]*([^=]+)[ ]*=/i, replace: '\n== $1 ==\n', code: 19, description: fiwText.lv1Headlines });

// Error code 032: Pipes in one link
fiwAutofixes.push ({ find: /\[\[[^\|\]]+\|([^\|\]]*\|)+([\]]{1,2}|.{0,60})/ig, pattern: /\[\[([^\|\]]+)\|([^\|\]]*\|)+([\]]{1,2}|.{0,60})/i , replace: '[[$1|$2]]', check: /\[\[[^\|\]]+\|/ig, valid: /\[\[(File\:|Image\:|Media\:|檔案\:|档案\:|圖像\:|图像\:|媒體\:|媒体\:)[^\|\]]+\|/g, code: 32, description: fiwText.linkPipes });
//fiwAutofixes.push ({ find: /\[\[^(File\:|Image\:|Media\:|檔案\:|档案\:|圖像\:|图像\:|媒體\:|媒体\:)[^\|\]]+\|([^\|\]]*\|)+(\]\])?/ig, pattern: /\[\[([^\|\]]+)/i , replace: '[[$1]]', code: 32, description: fiwText.linkPipes });

// Error code 048: Self-links (One at begining will be bold)
fiwAutofixes.push ({ find: new RegExp ('^\\[\\[' + wgBasePageName + '\\]\\]', 'ig'), pattern: new RegExp ('\\[\\[' + wgBasePageName + '\\]\\]', 'i'), replace: "'''" + wgBasePageName + "'''", code: 48, description: fiwText.selfLinks });
fiwAutofixes.push ({ find: new RegExp ('\\[\\[' + wgBasePageName + '\\]\\]', 'ig'), pattern: new RegExp ('\\[\\[' + wgBasePageName + '\\]\\]', 'i'), replace: wgBasePageName, code: 48, description: fiwText.selfLinks });

// Error code 054: Line breaks within list item
fiwAutofixes.push ({ find: /^[\*]+.+(?:[<]+[^ <]*[ ]*br[ ]*[\/]*[^ ]?>)+/ig, pattern: /[<]+[^ <]*[ ]*br[ ]*[\/]*[^ ]?>$/i, replace: '', code: 54, description: fiwText.brInList });
fiwAutofixes.push ({ find: /\n[\*]+.+(?:[<]+[^ <]*[ ]*br[ ]*[\/]*[^ ]?>)+/ig, pattern: /[<]+[^ <]*[ ]*br[ ]*[\/]*[^ ]?>$/i, replace: '', code: 54, description: fiwText.brInList });

// Error code 056: Arrows as ASCII art
fiwAutofixes.push ({ find: /.{1,30}<[=]+.{1,30}/ig, pattern: /<[=]+/i, replace: '⇐', code: 56, description: fiwText.asciiArrows });
fiwAutofixes.push ({ find: /.{1,30}<[-]+.{1,30}/ig, pattern: /<[-]+/i, replace: '←', code: 56, description: fiwText.asciiArrows });
//fiwAutofixes.push ({ find: /.{1,30}[=]+>.{1,30}/ig, pattern: /[=]+>/i, replace: '⇒', code: 56, description: fiwText.asciiArrows });
fiwAutofixes.push ({ find: /.{1,30}[-]+>.{1,30}/ig, pattern: /[-]+>/i, replace: '→', code: 56, description: fiwText.asciiArrows });
fiwAutofixes.push ({ find: /<!--.+(?!-->)→/igm, pattern: /→$/i, replace: '-->', code: 56, description: fiwText.asciiArrows });

// Error code 064: Links with same display text
fiwAutofixes.push ({ find: /\[\[([^\|\]]+)\|()\1\]\]/ig, pattern: /\[\[([^\|\]]+)\|()\1\]\]/i, replace: '[[$1]]', code: 64, description: fiwText.redundantLinkTexts });

// Error code 074: Links without destination
fiwAutofixes.push ({ find: /\[\[[\|]+[^\]]+\]\]/ig, pattern: /\[\[[\|]+([^\]]+)\]\]/i, replace: '[[$1]]', code: 74, description: fiwText.linksWithoutDest });

// Non-error 1001: Lack of introduction
//fiwAutofixes.push ({ find: /^[=]+/ig, pattern: /^/i, replace: '{{ Lead section }}\n', code: 1001, description: fiwText.lackIntro });

/* New entries
	This is the end of fixWikiAutofix.js
</nowiki>*/