Page MenuHomePhabricator

Using RegExTypoFix with subst and #invoke functions
Open, LowPublic

Description

On frwiki, we'd like to use RegExTypoFix including "subst:" and "#invoke" functions for to make the regular expressions simpler in some cases. It also improves performance a lot in some cases.

Something like:

<Typo word="formatnum" find="( |\n|\(|\|)([1-9]{1,3}) ((( |&nbsp;)?([0-9]{3}))+)( |\n|\)|\|)" replace="$1{{formatnum:{{subst:#invoke:String|replace|$2$3|%s|||false}}}}$7" />

It seems to work, but with a drawback for the automatic comment :
https://fr.wikipedia.org/w/index.php?title=Utilisateur:SyntaxTerror/Brouillon10&diff=122960555&oldid=122960543

typos fixed: 99 999 → {{formatnum:{{subst:#invoke:String|replace|99999|%s|||false}}}}

Also, I haven't checked, but there may be a problem if the replacement is done in a <ref> tag, as it prevents PreSaveTransform to be run, so the subst: and invoke would stay.

Would it be possible for AWB to detect the presence of such elements in the "replace" value and expand this text to a more readable one using for example the MW API parse request with the attribute "onlypst" ?
It would give a more human readable comment, and would prevent potential problems with <ref> tags.