Open wikipedia-mabdul opened 11 years ago
//Wikilink correction
text = text.replace(/(\[){2}(?:https?:)?\/\/(en.wikipedia.org\/wiki|enwp.org)\/([^\s\|]+)(\s|\|)?((?:\[\[[^\[\]]*\]\]|[^\]\[])*)(\]){2}/gi, "\[\[$3$4$5\]\]");
text = text.replace(/(\[){1}(?:https?:)?\/\/(en.wikipedia.org\/wiki|enwp.org)\/([^\s\|]+)(\s|\|)?((?:\[\[[^\[\]]*\]\]|[^\]\[])*)(\]){1}/gi, "\[\[$3$4$5\]\]");
should be changed so that $4 is replacing the whitespace to a pipe...
maybe we don't need the regex any more as this COULD be already done by AutoED's wikilink.js
Shouldn't (en.wikipedia.org\/wiki|enwp.org)
be (en.wikipedia.org\/wiki|en.wikipedia.org\/w\/index\.php\?title=|enwp.org)
?
better not. what happens if somebody provides a complete link to a certain revision? this would completely break the link as this can't be done by normal wikiliks (or either we would have to detect these kind of links and ignore them, or we would loose information)
(en.wikipedia.org\/wiki|en.wikipedia.org\/w\/index\.php\?title=[.*?][^&=]^|enwp.org)
maybe? That says anything with an index.php?title= title unless it has & or = (extra parameters) before the end of the line. That should only catch https?://en.wikipedia.org/w/index.php?title=foo
but not https?://en.wikipedia.org/w/index.php?title=foo&oldid=87658354
if I've had enough coffee this morning.
AutoEd wikilinks is solely for wikilink correction -- it doesn't do any conversion from url to wikilink. @wikipedia-mabdul what we need is some sort of conditional regex or maybe just two more regexes (for the spaces)... didn't we run into this problem before?
mhhh sounds good. Although I still THINK that autoed covers most of our regex and we should talk to plasticpork if he could (with our help) improve his regex. this would reduce time of our script (not trying to cleanup the same stuff multiple times) and would help more users (who are using autoed)
@wikipedia-mabdul i'm sorry, I didn't see you assigned yourself to this...
includes:
//rem 'external' wiktionary links regex(/[https?:\/\/en.wiktionary.org\/wiki\/[\w][ ](\w[^]])]/g, '$1');
yeah, no problem. ;-)
So the new code correctly handles
[[http://en.wikipedia.org/wiki/Example]]
:arrow_right: [[Example]]
[https://en.wikipedia.org/wiki/Examplety_exemplar Yoohoo]
:arrow_right: [[Examplety exemplar|Yoohoo]]
...And much more more! Let me know if you can think of any cases that the code currently doesn't handle.
as I said: we should talk to plastigpork if he wants to add it to autoed.
btw: what has happened to my idea that your bot monitors autoed and ohconfucius' scritps and merge them here (?) at github so that we only have to import one script?
@wikipedia-mabdul not really worth it...time is negligible and mw.loader already does aggressive caching. In https://github.com/WPAFC/afch/commit/0a0efd071fadd74839883267059dccf7a048bdd4 I already changed it so that autoed and formatgeneral are not run on initial load (only when saving), so they don't delay the opening of the review window at all.
see edit at https://en.wikipedia.org/w/index.php?title=Wikipedia_talk%3AArticles_for_creation%2FPriscillia_Sari_Dewi_%282%29&diff=573010217&oldid=573003641