New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
morebits: Ignore file/category embeds when removing links #239
Conversation
morebits.js
Outdated
@@ -2999,10 +2999,11 @@ Morebits.wikitext.page = function mediawikiPage( text ) { | |||
Morebits.wikitext.page.prototype = { | |||
text: '', | |||
removeLink: function( link_target ) { | |||
var not_link_re_string = "(?!(?:[Ff]ile|[Ii]mage|[Cc]ategory):)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't test it (no time right now...), but it seems that JavaScript doesn't support lookbehinds. In any case ?! is a lookahead, not a lookbehind. Could you test this anyway in a browser and see what happens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a lookahead, which is what I wanted. I'll try to test this in a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance this can be constructed from wgNamespaceIds
? For the sake of l10n...
You could ask Magioalditis or even Reaper Eternal (since RE made many edit filters with regexes). |
File: and Category: links (without a leading colon) should not be removed. Fixes #231.
586037e
to
f4a82fa
Compare
I've finally come back to this with a simpler solution (no lookaheads!). |
…gadgets#239) File: and Category: links (without a leading colon) should not be removed. Fixes wikimedia-gadgets#231. (cherry picked from commit 83fff83)
Fixes #231. @atlight Could I get a second pair of eyes on that regex? I'm pretty sure it's correct but I might have made a simple mistake.