Page MenuHomePhabricator

CodeMirror: Template argument names containing hyphens are not highlighted appropriately
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Start editing a page and add a template transclusion with a parameter name containing a hyphen:
{{Test
|Correct name highlight=Param value
|Incorrect name-highlight=Param value
}}

What happens?:
"Incorrect name-highlight" receives a tag of template instead of templateArgumentName.

T405267.png (89×333 px, 12 KB)

What should have happened instead?:
Should have received a tag of templateArgumentName.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):
Happens on WMF wikis.

Other information (browser name/version, screenshots, etc.):
This is a regression after c61e20dda38b6e3b4b7f3d284261635f35c8fe61 (T281024) which added hyphens to the terminating character set for template arguments, causing eatTemplateArgument to bail with a template tag as the only terminator qualifying for templateArgumentName is an equality sign =. Unsure if this affects other tags.

Event Timeline

I will not call it a bug because it is expected to some extent and a comprehensive fix for template argument names containing specific characters will be difficult. The same issue exists for ~, <, etc, for a long time. I will provide a simple fix for - soon.

Yeah, wasn't sure how to categorise this as I'm aware a "proper" fix is going to be difficult, but hyphens are probably common enough to call this behaviour change a regression :/

I hope I'm not coming off as complaining; the work y'all do on the extension is superb

Change #1190644 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/CodeMirror@master] CodeMirrorMediaWiki: template arg name containing `-`

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

Thanks for your kind words! The above patch will fix it for - as a special case, and we can leave a more comprehensive fix later (I do have some success in my online demo).

Can confirm the patch corrects the highlighting :)

Change #1190644 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] CodeMirrorMediaWiki: template arg name containing `-`

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

Bhsd moved this task from Improvement to Done on the MediaWiki-extensions-CodeMirror board.