-
Notifications
You must be signed in to change notification settings - Fork 3
Integrate User:Ohconfucius/script/formatgeneral.js similar to AutoEd #47
Comments
Since Ohconfucius hasn't changed the script, I went ahead and spent a few minutes just writing a little parser that will take the script contents, suck the regexes out of it, and perform the replacements on its own. This feels quite hacky, however, and I'm not sure about integrating it into the production code...even though security-wise it's fine (since it assembles a regexp object and doesn't use eval()). Your thoughts, @wikipedia-mabdul? // Run User:Ohconfucius/script/formatgeneral.js automatically... hacky
var text = '==External Links==\n kljdhsajdkjfj 2<sup>nd</sup>'; // this is for testing only
var formatgeneraltext = afcHelper_getPageText('User:Ohconfucius/script/formatgeneral.js');
regexes = /regex\(\/(.*?)(?:\s*\/([igm]*),\s*')(.*?)(?:'\s*\));/ig; // this is the way regexps are stored in the formatgeneral script
while (matchedexpression = regexes.exec(formatgeneraltext)) { // for each regexp in formatgeneral
text = text.replace(new RegExp(matchedexpression[1],matchedexpression[2]),matchedexpression[3]); // parse it and create a new regexp object, then perform the replacement
} |
I have to think about it. at least we should filter out the regex which are commented out, e.g. |
BTW: nice cherry pick ;-) |
we should also use /igm and detect the regex with ^and $ (see the other ticket) |
your regex can't work. where is matchedexpression[3](so the third bracket pair) in your regex? I'm still not really shure if that is a good idea... maybe we should "improve" the script and do the coding for Ohconfucius and request either a editprotected or ask him politely to push our changes... |
this would be much faster (our Javascript) and cleaner and not that hackisch... YK |
I agree with you completely...felt too hacky, even for me ;) Thing is, right now he's using some third party regex() function...but I guess it'd be pretty trivial to refactor it to do all the replacements and then drop them into the edit window. (An aside: my regex does work, actually. :p Matched expression #3 is the third capture group... remember, |
regex(/(.?)(?:\s/([igm]),\s')(.?)(?:'\s)); d'oh... yeah didn't recognized the second... |
ok, the code is rather easy to fix if you check the code. I will ask Ohconfucius after modifying a version for his userspace so that we could use a subpage by him and sharing the same code. |
see also thread at https://en.wikipedia.org/wiki/User_talk:Ohconfucius#formatgeneral - my first attempts were successful; so we might getting closer to include the cleanup scrip! |
@theopolisme - Why did you reopen? |
see comment in 108: not in live version onwiki. @theopolisme and @Technical-13 how to hanle autocloses by the AI as in this ticket? ^ |
@wikipedia-mabdul we have to sigh, smile, and reopen them. ;) |
There are autocloses? It's not offering two options? [close & submit] or [submit]? I always see two? |
it autocloses when you merge a pull request. |
I wish we could just close when it's fixed as opposed to waiting for it to be pushed. Pretty counter-intuitive... |
I realize that it is from our perspective, but it's the end user's perspective that is more important here. I've already said (many times over), to feel free to just comment, label, or milestone and I'll come through daily and sync each changed ticket up. 😀 |
@Technical-13 - I don't really understand why end users would be searching through here. Most of them refuse to even file their tickets on here. xD |
NOT WORKING @wikipedia-mabdul: your code did not work; are you sure |
I just recognized: we should better use: as importscriptURI is listed under I wonder, AUTOED is def. loading. why do you think that formatgeneral is not working? the code itself or the loading? |
When I tested it last night, it appeared to be trying to use the original |
The scripts are probably being loaded asynchronously. We need a better way to do this -- |
Consolidated: #197 |
See my thread at https://en.wikipedia.org/wiki/User_talk:Ohconfucius#WP:AFCH_integration_of_formatgeneral - this can't be done at the moment until Ohconfucius changes a few bits in his script.
The integration is as simple as AutoEd's integration.
The text was updated successfully, but these errors were encountered: