Page MenuHomePhabricator

Wikitext syntax highlighter fails on comments in template names
Closed, ResolvedPublic2 Estimated Story PointsBUG REPORT

Description

Reported by a user on the talk page on Meta:

It's really a minor and only visual mistake. In ca:special:permalink/26622503 the last closing brackets are not highlighted, although it is paired with the first one and the bracket matching detect it, but do not highlight.

Tested in Mozilla & Chrome.

Event Timeline

Aklapper removed a subscriber: WMDE-TechWish.

Please avoid adding project tags as subscribers - thanks.

thiemowmde changed the subtype of this task from "Task" to "Bug Report".
thiemowmde added a subscriber: thiemowmde.

It took me a bit to understand what the user is talking about. The bracket matching works fine. It's the red-ish background shading that is broken for the very last }}:

Screenshot from 2021-03-19 09-35-16.png (227×1 px, 46 KB)

In other words, the bug is in the "mediawiki" mode a.k.a. the syntax highlighter for wikitext. I was able to minimize the counterexample like this:

{{#if: | {{some template
<!-- comment --> }} }}

The bug is triggered by the newline at the end of the template name. Technically, newlines in template names are not allowed. That's why the syntax highlighter kind of "gives up" at this point. But the actual wikitext parser does not care about this specific newline. It's not in the template name, but after. The parser strips comments and trailing newlines, and works just fine with the remaining "some template" template name.

It should be possible to update the syntax highlighter so it's a little more relaxed in a situation like this.

thiemowmde renamed this task from The last closing brackets are not highlighted to Wikitext syntax highlighter fails on comments in template names.Mar 19 2021, 9:04 AM
Lena_WMDE set the point value for this task to 2.Apr 1 2021, 3:28 PM
Lena_WMDE added a subscriber: Lena_WMDE.

Conclusion from discussions during story time:

This is an existing issue (prior to our work on the syntax highlighter), that seems to be caused by HTML comments. The fix may be straightforward, so we will do a time-boxed exploration to try to solve it. If it turns out to be more complicated, we'll reassess before investing more effort.

Change 682128 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/CodeMirror@master] Allow HTML comments and newlines in template names

https://gerrit.wikimedia.org/r/682128

Change 682128 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] Allow HTML comments and newlines in template names

https://gerrit.wikimedia.org/r/682128