| Summary: | javascript-react.xml has external file ref in a Rule's context | ||
|---|---|---|---|
| Product: | [Frameworks and Libraries] frameworks-syntax-highlighting | Reporter: | Gene Thomas <gene> |
| Component: | syntax | Assignee: | KWrite Developers <kwrite-bugs-null> |
| Status: | RESOLVED NOT A BUG | ||
| Severity: | normal | CC: | nibgonz, walter.von.entferndt |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Other | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Gene Thomas
2021-02-11 05:14:22 UTC
Of the 28,000 rule lines in the syntax directory, only 10 use extern file ref context attributes. These are a mistake are they not? coffee.xml:270: <Detect2Chars attribute="JavaScript Template" context="RegExpAfterString##JavaScript" char="\" char1="`" endRegion="Template"/> <!-- End template. --> coffee.xml:292: <Detect2Chars attribute="JavaScript Template" context="RegExpAfterString##JavaScript" char="\" char1="`" endRegion="Template"/> <!-- End template. --> javascript-react.xml:81: <DetectChar attribute="Normal Text" context="NoRegExp##JavaScript" char="]" endRegion="List" /> javascript-react.xml:96: <DetectChar context="RegExpAfterString##JavaScript" attribute="Template" char="`" endRegion="Template" /> qml.xml:121: <RegExpr attribute="Objects" context="FindMemberObjectMath##JavaScript" String="\bMath(?=\s*\.)" /> qml.xml:148: <DetectChar attribute="String" context="RegExpAfterString##JavaScript" char=""" /> selinux-fc.xml:90: <IncludeRules context="_m4_builtin_keywords##SELinux Policy"/> typescript.xml:406: <DetectChar context="RegExpAfterString##JavaScript" attribute="Template" char="`" endRegion="Template" /> typescript-react.xml:103: <DetectChar context="RegExpAfterString##JavaScript" attribute="Template" char="`" endRegion="Template" /> yara.xml:66: <RegExpr attribute="Start Regular Expression" context="(regex caret first check)##JavaScript" String="/(?=(?:[^/\\\[]|\\.|\[(?:[^\]\\]|\\.)+\])+/(?:[gimsuy]+(?!\s*[\w$])|(?![/\*])|(?=/\*)))" /> This is valid and it works! Using "NoRegExp##JavaScript" switches to the "NoRegExp" context of the "JavaScript" definition. Apparently this type of context switch isn't in the documentation, I will have to add it. I added this context switch to the documentation: """ An identifier, which is a context name, followed by two hashes (##) and another identifier, which is the name of a language definition. This naming is similar to that used in IncludeRules rules and allows you to switch to a context belonging to another syntax highlighting definition, e.g. "SomeContext##JavaScript". Note that it is not possible to use this context switch in combination with #pop, for example, "#pop!SomeContext##JavaScript" is not valid. """ See the commit here: https://invent.kde.org/utilities/kate/-/commit/858b18d7a8d49348e4d4e24531f36e4f93cc6834 The documentation is not updated automatically, so we will have to wait. In case you still have doubts, you can check the KSyntaxHighlighting source code: https://invent.kde.org/frameworks/syntax-highlighting/-/blob/master/src/lib/contextswitch.cpp#L47 |