Page MenuHomePhabricator

Highlighting broken in complicated templates
Closed, ResolvedPublic

Description

Example code from https://de.wikipedia.org/wiki/Vorlage:NaviBlock:

<onlyinclude><includeonly><div class="BoxenVerschmelzen">
{{#switch:{{padleft:|1|{{{1|}}}}}|<|[={{{1}}}|#default={{#if:{{{1|}}}|{{{{{1}}}}}}}{{#if:{{{2|}}}|{{{{{2}}}}}|<div style="display:none;">[[Vorlage:NaviBlock/Wartung/nur ein Element| ]]</div>}}{{#if:{{{3|}}}|{{{{{3}}}}}}}{{#if:{{{4|}}}|{{{{{4}}}}}}}{{#if:{{{5|}}}|{{{{{5}}}}}}}{{#if:{{{6|}}}|{{{{{6}}}}}}}{{#if:{{{7|}}}|{{{{{7}}}}}}}{{#if:{{{8|}}}|{{{{{8}}}}}}}{{#if:{{{9|}}}|{{{{{9}}}}}}}{{#if:{{{10|}}}|{{{{{10}}}}}}}{{#if:{{{11|}}}|{{{{{11}}}}}}}{{#if:{{{12|}}}|{{{{{12}}}}}}}{{#if:{{{13|}}}|{{{{{13}}}}}}}{{#if:{{{14|}}}|{{{{{14}}}}}}}{{#if:{{{15|}}}|{{{{{15}}}}}}}{{#if:{{{16|}}}|{{{{{16}}}}}}}{{#if:{{{17|}}}|{{{{{17}}}}}}}{{#if:{{{18|}}}|{{{{{18}}}}}}}{{#if:{{{19|}}}|{{{{{19}}}}}}}{{#if:{{{20|}}}|{{{{{20}}}}}}}{{#if:{{{21|}}}|<div class="error">Zu viele Navigationsleisten</div>}}}}
</div></includeonly></onlyinclude>
{{Dokumentation}}

There are many unhighlighted }}, though they do match correctly.
In {{#if:{{{5|}}}|{{{{{5}}}}}}}
^^^^^^ ^^ this is the parser function
^^^^^^^^ ^^^^^^^ these are parameters
^^ ^^ this is a template transclusion

Highlighting a complicated, but correct template wrongly makes editing even harder than without highlighting.

Event Timeline

Schnark raised the priority of this task from to Needs Triage.
Schnark updated the task description. (Show Details)
Schnark subscribed.
Pastakhov triaged this task as Medium priority.
Pastakhov set Security to None.

Change 232678 had a related patch set uploaded (by Pastakhov):
fix highlighting parameters inside a template transclusion (v 3.2.1)

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

Change 232678 merged by jenkins-bot:
fix highlighting parameters inside a template transclusion (v 3.2.1)

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

This is not a complete solution of the problem, but I don't know whether to spend my time on it,

... since the Editing team will be working on its own solution to syntax highlighting at some point ...

I already linked it in T109822, but just to link it again: In https://de.wikipedia.org/wiki/Benutzer:Schnark/js/syntaxhighlight.js, I use the following solution, which isn't perfect, but works in all common and not-so-common cases. To split a sequence of { into templates and parameters, I divide them as follows:

Niharika lowered the priority of this task from Medium to Low.Nov 7 2017, 11:57 PM
TBolliger removed a project: Community-Tech.
TBolliger subscribed.

There may be room for improvements, but the problem outlined in this ticket is fixed on production.

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

[mediawiki/extensions/CodeMirror@master] Much more robust detection of template {{{variables}}}

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

Change 975767 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] Much more robust detection of template {{{variables}}}

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