Add tags from CodeMirrorPluginModules to extension tags list

Currently, only registered parser tags are included in the list of
extension tags to be highlighted. This patch allows extensions that do
not register their tags as parser tags (Extension:Translate) to still
define them for highlighting using the existing CodeMirrorPluginModules
annotation.
This patch also removes the special-casing for <translate>, as it can be
defined in Translate instead.

Bug: T284883
Co-Authored-by: Tacsipacsi <tacsipacsi@jnet.hu>
Depends-On: I860c944eaeeb7771629a1ed2352c05cfd8d7ca80
Change-Id: Iba2b0b874ebbace7a892af9e1d9896e8b17ade78
This commit is contained in:
AntiCompositeNumber 2022-02-17 13:28:30 -05:00
parent 56f6731968
commit b136622875
No known key found for this signature in database
GPG key ID: A888A323AB506229
2 changed files with 6 additions and 3 deletions

View file

@ -64,11 +64,14 @@ class ResourceLoaderCodeMirrorModule extends ResourceLoaderFileModule {
$registry = ExtensionRegistry::getInstance();
$parser = MediaWikiServices::getInstance()->getParser();
$tagModes = $registry->getAttribute( 'CodeMirrorTagModes' );
$tagNames = array_merge( $parser->getTags(), array_keys( $tagModes ) );
// initialize configuration
$config = [
'pluginModules' => $registry->getAttribute( 'CodeMirrorPluginModules' ),
'tagModes' => $registry->getAttribute( 'CodeMirrorTagModes' ),
'tags' => array_fill_keys( $parser->getTags(), true ),
'tagModes' => $tagModes,
'tags' => array_fill_keys( $tagNames, true ),
'doubleUnderscore' => [ [], [] ],
'functionSynonyms' => $parser->getFunctionSynonyms(),
'urlProtocols' => $parser->getUrlProtocols(),

View file

@ -33,7 +33,7 @@
rp: true, rt: true, rtc: true, p: true, span: true, abbr: true, dfn: true,
kbd: true, samp: true, data: true, time: true, mark: true, br: true,
wbr: true, hr: true, li: true, dt: true, dd: true, td: true, th: true,
tr: true, noinclude: true, includeonly: true, onlyinclude: true, translate: true },
tr: true, noinclude: true, includeonly: true, onlyinclude: true },
voidHtmlTags = { br: true, hr: true, wbr: true },
isBold, isItalic, firstsingleletterword, firstmultiletterword, firstspace, mBold, mItalic, mTokens = [],
mStyle;