WPAFC / afch

Yet another Articles for creation helper script -- ACTIVE DEVELOPMENT NO LONGER HAPPENS IN THIS REPOSITORY AND HAS MOVED TO
https://github.com/WPAFC/afch-rewrite
10 stars 3 forks source link

FFU: cleanup #195

Open wikipedia-mabdul opened 11 years ago

wikipedia-mabdul commented 11 years ago

There are regular users (requester) providing full information and templates for proposed uploads like:

''License:''' {{Non-free logo|image has rationale=yes}}

The cleanup should transform that stuff to

'''License:''' {{tlx|Non-free logo|<nowiki>image has rationale=yes</nowiki>}}

see edit by [[User:Armbrust]]

https://en.wikipedia.org/w/index.php?title=Wikipedia:Files_for_upload&curid=9176046&diff=576246132&oldid=576225994

Technical-13 commented 11 years ago

I would think {{tlx|Non-free logo|image has rationale{{=}}yes}} would not only look better but be easier to do than trying to wrap things in <nowiki>...</nowiki> tags.

.replace(/\{\{(.*?)\}\}/g, '{{tlx|$1}}').replace('=', '{{=}}');

wikipedia-mabdul commented 11 years ago

you missed to replace the additional pipes so another

.replace(/\{\{(.*?)\}\}/g, '{{tlx|$1}}').replace(/=/g, '{{=}}').replace(/\|/g, '{{!}}');

and then

.replace(/\{\{\!\}\}/, '\|');

(first global, then one time rereplace)

wikipedia-mabdul commented 11 years ago

but actually it IS easier...

.replace(/\{\{(.*?)\}\}/g, '{{tlx|\<nowiki\<$1\<\/nowiki\>}}');

not really that hard, if you check the above code...

wikipedia-mabdul commented 11 years ago

and... btw: this is a bad regex.

moreover we would detect ALL templates (also afc comments, archive bottom etc...)

I'm working on that