User:Lenore/autolink.js: Difference between revisions

Content deleted Content added
m Added autolinkMySpecialPage; don't parse template variables anymore
Parse not-template pages included code too; fix problem with parser functions (Template:# -> Help:)
Line 116:
autolinkRegexWlink = /(\<span class\="diffchange"\>|)\[{2}(\<\/span\>|)([^\[\]<>\n]*?)(\<span class\="diffchange"\>|)([^\[\]<>\n]*?)(\<\/span\>|)([^\[\]<>\n]*?)(|\|[^\n]*?)(\<span class\="diffchange"\>|)\]{2}(\<\/span\>|)/g;
// Wikilinks
 
autolinkRegexOtherPages = /(\<span class\="diffchange"\>|)([^\{]|\{{2}|^)(\<\/span\>|)(\<span class\="diffchange"\>|)\{{2}(\<\/span\>|)(\<span class\="diffchange"\>|)([Ss][Uu][Bb][Ss][Tt]\:|[Mm][Ss][Gg]\:|[Mm][Ss][Gg][Nn][Ww]\:|)(\<\/span\>|)(\<span class\="diffchange"\>|)((?:[Ss]peciale?|[Ww]ikipedia|[Tt]emplate|[Pp]ortale?|[Pp]rogetto|)\:[^\{\}\:\&\|<>\n]*?)(\<\/span\>|)(\<span class\="diffchange"\>|)([^\{\}\:\&\|<>\n]*?)(\<\/span\>|)([^\{\}\:\&\|<>\n]*?)(?=\s*(?:(?:\:|\|)|\}{2}))/gm;
// Not-template pages included
 
autolinkRegexTemplate = /(\<span class\="diffchange"\>|)([^\{]|\{{2}|^)(\<\/span\>|)(\<span class\="diffchange"\>|)\{{2}(\<\/span\>|)(\<span class\="diffchange"\>|)([Ss][Uu][Bb][Ss][Tt]\:|[Mm][Ss][Gg]\:|[Mm][Ss][Gg][Nn][Ww]\:|)(\<\/span\>|)([^\{\}\:\&\|<>\n]*?)(\<span class\="diffchange"\>|)([^\{\}\:\&\|<>\n]*?)(\<\/span\>|)([^\{\}\:\&\|<>\n]*?)(?=\s*(?:(?:\:|\|)|\}{2}))/gm;
Line 150 ⟶ 153:
'$1[[$2<a class="autolink" style="color:' + autolinkColor + '" href="/wiki/$3$5$7">$3$4$5$6$7$8</a>$9]]$10');
// Make wikilink code into links
 
autolinkContent = autolinkContent.replace(autolinkRegexOtherPages,
'$1$2$3$4{{$5$6<a class="autolink" style="color:' + autolinkColor + '" href="/wiki/Help:$7">$7</a>$8<a class="autolink" style="color:' + autolinkColor + '" href="/wiki/$10$13$15">$9$10$11$12$13$14$15</a>');
// Make not-template pages included code into links
 
autolinkContent = autolinkContent.replace(autolinkRegexTemplate,
'$1$2$3$4{{$5$6<a class="autolink" style="color:' + autolinkColor + '" href="/wiki/Help:$7">$7</a>$8<a class="autolink" style="color:' + autolinkColor + '" href="/wiki/Template:$9$11$13">$9$10$11$12$13</a>');
autolinkContent = autolinkContent.replace(/Template\:#/g, 'Help:');
// Make template code into links