Page MenuHomePhabricator

CodeMirror – support highlighting the new <tvar> tag syntax
Closed, ResolvedPublicFeature

Description

Currently, the CodeMirror extension only highlights the <languages /> and <translate> tags, but not the new <tvar name=n>...</tvar> tag syntax.


Support for highlighting the <translate> tag was added in T172456: Syntax highlighting - translate and tvar tags, and the new <tvar> syntax was introduced to Extension:Translate in T274881: Change translation variable (tvar) syntax, but CodeMirror still shows them unstyled.


Note that <tvar> tags are only valid inside the <translate> tags.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

The problem mentioned in T172456#4024855 still applies. Adding support for <tvar name="1"></tvar> is fairly easy, it would just be defined as another HTML tag (since Translate doesn't register it as a parser tag). However, highlighting will break on pages that use <tvar|1></> syntax. It doesn't break horribly, but it treats the <tvar|1> tag as unclosed.

image.png (82×568 px, 13 KB)

I think this is reasonable enough given that the </> syntax is deprecated.

Change 763585 had a related patch set uploaded (by AntiCompositeNumber; author: AntiCompositeNumber):

[mediawiki/extensions/CodeMirror@master] Add <tvar> to list of HTML tags

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

Change 763918 had a related patch set uploaded (by AntiCompositeNumber; author: AntiCompositeNumber):

[mediawiki/extensions/Translate@master] Add CodeMirror configuration

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

MusikAnimal subscribed.

Sorry for the wait. Moving this to the Community Tech sprint board so we can prioritize code review.

Is it possible to only highlight those tags related to translation on a site with Extension:Translate installed? If it is impossible to actually mark a page for translation, it is useless to highlight those tags.

Is it possible to only highlight those tags related to translation on a site with Extension:Translate installed? If it is impossible to actually mark a page for translation, it is useless to highlight those tags.

Yes, and that was the concern with the initial approach here and with your patch. The new patches are supposed to address this, once we get around to code review (please feel free to help :). I hope to look at this today/tomorrow if no one beats me to it.

TheresNoTime changed the subtype of this task from "Task" to "Feature Request".Aug 4 2022, 6:14 PM

Change 763918 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Add CodeMirror configuration

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

Change 763585 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] Add tags from CodeMirrorPluginModules to extension tags list

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

This works fine, expect in link target, where they are mainly used. CodeMirror should also parse link targets to look for tvar tag:

  • In internal link syntax, tvar tags should display as cm-mw-exttag-* e.g. [[<tvar name=1>Special:MyLanguage/Target</tvar>|text]].
  • In external link syntax, tvar tags should not break cm-mw-link-ground and cm-mw-extlink-* e.g. [<tvar name=url>https//w.wiki</tvar> text].

@Pols12, could you create two new tasks for that? I personally don't consider the first to be a bug though.