Page MenuHomePhabricator

Genfixes: <nowiki>[</nowiki> doesn't count as an opening bracket
Open, Needs TriagePublic

Description

AWB genfixes seem to ignore square brackets that are wrapped in <nowiki> tags (e.g. <nowiki>[</nowiki>) for the purposes of finding mismatched square brackets, and so they remove the closing bracket if it's not also wrapped in <nowiki> tags; for example, see this edit. There are currently about 2,839 articles with <nowiki>[</nowiki> on enwp, and 4,149 articles with <nowiki>]</nowiki>, so more than a thousand articles with mismatched <nowiki> square brackets that genfixes could break.

Ideally, would it be possible to check for these, and replace any <nowiki> brackets with {{Bracket}}, before checking for mismatched brackets, which would also improve code clarity? Failing that, I think it should be possible to ignore whether or not brackets are wrapped in <nowiki> for the purposes of checking whether or not there are mismatched brackets: I can't think of any case where a bracket in <nowiki> would affect whether brackets are mismatched or not, either in markup terms, or for readers – i.e. a bracket is a bracket, whether or not it's <nowiki>d. Only if it's found that there are unmatched brackets, then you might need to distinguish them, to work out which brackets to add/remove (which is another good reason to replace them with {{Bracket}} first, to avoid this complication).

For more info, see Wikipedia talk:AutoWikiBrowser/General fixes#Square bracket mismatch on enwp.

Event Timeline

Yodin updated the task description. (Show Details)

What happened: <nowiki>[</nowiki>[[sub-creation]]] was changed to <nowiki>[</nowiki>[[sub-creation]]
What should have happened: <nowiki>[</nowiki>[[sub-creation]]] be changed to either &#91;[[sub-creation]]&#93;, or {{Bracket|[[sub-creation]]}}
Version: I performed the edit, and did so using v6.2.1.0 SVN 12528
Note: {{Bracket}} is not allowed in CS1|2 templates, so the &#91; & &#93; option would be safer. Also, GenFixes already replaces single [ & ] not wrapping a URL with &#91; & &#93;.