Changeset View
Changeset View
Standalone View
Standalone View
data/syntax/typescript-react.xml
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
---|---|---|---|---|---|
2 | <!DOCTYPE language SYSTEM "language.dtd" | 2 | <!DOCTYPE language SYSTEM "language.dtd" | ||
3 | [ | 3 | [ | ||
4 | <!ENTITY simpleName "([a-z][a-z\d]*:)?[a-z][a-z\d]*"> | 4 | <!ENTITY simpleName "([a-z][a-z\d]*:)?[a-z][a-z\d]*"> | ||
5 | <!ENTITY name "([a-zA-Z_\$]([\w\$\-\.]*[\w\$])?:)?[a-zA-Z_\$]([\w\$\-\.]*[\w\$])?"> | 5 | <!ENTITY baseName "([a-zA-Z_\$]|[^[:ascii:]])(([\w\$\-\.]|[^[:ascii:]])*([\w\$]|[^[:ascii:]]))?"> | ||
6 | <!ENTITY simpleTag "<\s*&simpleName;"> | 6 | <!ENTITY name "(&baseName;:)?&baseName;"> | ||
7 | <!ENTITY tag "<\s*&name;"> | 7 | <!ENTITY baseNameWithBound "(\b[a-zA-Z_\$]|[^[:ascii:]])(([\w\$\-\.]|[^[:ascii:]])*([\w\$]|[^[:ascii:]]))?"> | ||
8 | <!ENTITY nameWithBound "(&baseNameWithBound;:)?&baseNameWithBound;"> <!-- Use this instead of "\b&name;" --> | ||||
9 | | ||||
10 | <!ENTITY simpleTag "<\s*&simpleName;"> <!-- Element tag --> | ||||
11 | <!ENTITY tag "<\s*(&name;|>)"> | ||||
8 | <!ENTITY entref "&([a-zA-Z\d]+|#\d+|#x[a-fA-F\d]+);"> | 12 | <!ENTITY entref "&([a-zA-Z\d]+|#\d+|#x[a-fA-F\d]+);"> | ||
13 | <!ENTITY identifier "([a-zA-Z_$]|[^[:ascii:]])([\w$]|[^[:ascii:]])*"> | ||||
9 | ]> | 14 | ]> | ||
10 | 15 | | |||
11 | <!-- | 16 | <!-- | ||
12 | ==================================================================== | 17 | ==================================================================== | ||
13 | 18 | | |||
14 | This file is part of the KDE's KSyntaxHighlighting framework. | 19 | This file is part of the KDE's KSyntaxHighlighting framework. | ||
15 | 20 | | |||
16 | Copyright 2018 Nibaldo González S. (nibgonz@gmail.com) | 21 | Copyright 2018 Nibaldo González S. (nibgonz@gmail.com) | ||
17 | 22 | | |||
18 | This Source Code Form is subject to the terms of the MIT License. | 23 | This Source Code Form is subject to the terms of the MIT License. | ||
19 | If a copy of the license was not distributed with this file, | 24 | If a copy of the license was not distributed with this file, | ||
20 | You can obtain one at: https://opensource.org/licenses/MIT | 25 | You can obtain one at: https://opensource.org/licenses/MIT | ||
21 | 26 | | |||
22 | ==================================================================== | 27 | ==================================================================== | ||
23 | 28 | | |||
24 | This file is an extension of the TypeScript highlighter | 29 | This file is an extension of the TypeScript highlighter | ||
25 | (typescript.xml). | 30 | (typescript.xml). | ||
26 | IMPORTANT: Keep sync with "javascript-react.xml". | 31 | IMPORTANT: Keep sync with "javascript-react.xml". | ||
27 | 32 | | |||
28 | Based on the XML syntax highlighting (v7), by Wilbert Berendsen | 33 | Based on the XML syntax highlighting (v7), by Wilbert Berendsen | ||
29 | (wilbert@kde.nl), and the TypeScript React grammar files, | 34 | (wilbert@kde.nl), and the TypeScript React grammar files, | ||
30 | available at: https://github.com/Microsoft/TypeScript-TmLanguage | 35 | available at: https://github.com/Microsoft/TypeScript-TmLanguage | ||
31 | 36 | | |||
32 | Change log: | 37 | Change log: | ||
38 | * v2 [2018-12-30]: Adapt to version 2 of "typescript.xml". | ||||
39 | Allow type assertion in the tag name. | ||||
40 | Allow tags after the keywords "await" & "yield". | ||||
41 | Allow empty tags and non-ASCII tag name & attributes. | ||||
33 | * v1 [2018-11-18]: Initial version | 42 | * v1 [2018-11-18]: Initial version | ||
34 | --> | 43 | --> | ||
35 | 44 | | |||
36 | <language name="TypeScript React" version="1" kateversion="5.53" section="Scripts" indenter="cstyle" | 45 | <language name="TypeScript React" version="2" kateversion="5.53" section="Scripts" indenter="cstyle" | ||
37 | priority="8" extensions="*.tsx" mimetype="text/tsx;text/x-tsx;application/tsx;application/x-tsx;" | 46 | priority="8" extensions="*.tsx" mimetype="text/tsx;text/x-tsx;application/tsx;application/x-tsx;" | ||
38 | author="Nibaldo González (nibgonz@gmail.com)" license="MIT"> | 47 | author="Nibaldo González (nibgonz@gmail.com)" license="MIT"> | ||
39 | 48 | | |||
40 | <highlighting> | 49 | <highlighting> | ||
41 | 50 | | |||
42 | <contexts> | 51 | <contexts> | ||
43 | 52 | | |||
44 | <context name="Shebang" attribute="Normal Text" lineEndContext="#pop!Normal" lineEmptyContext="#pop!Normal" fallthrough="true" fallthroughContext="#pop!Normal"> | 53 | <context name="Shebang" attribute="Normal Text" lineEndContext="#pop!Normal" lineEmptyContext="#pop!Normal" fallthrough="true" fallthroughContext="#pop!Normal"> | ||
45 | <Detect2Chars context="ShebangLine" attribute="Comment" char="#" char1="!" column="0" /> | 54 | <Detect2Chars context="ShebangLine" attribute="Comment" char="#" char1="!" column="0" /> | ||
46 | </context> | 55 | </context> | ||
47 | <context name="ShebangLine" attribute="Comment" lineEndContext="#pop#pop!Normal" /> | 56 | <context name="ShebangLine" attribute="Comment" lineEndContext="#pop#pop!Normal" /> | ||
48 | 57 | | |||
49 | <context name="Normal" attribute="Normal Text" lineEndContext="#stay"> | 58 | <context name="Normal" attribute="Normal Text" lineEndContext="#stay"> | ||
50 | <IncludeRules context="React" /> | 59 | <IncludeRules context="React" /> | ||
51 | <IncludeRules context="Normal##TypeScript" /> | 60 | <IncludeRules context="Normal##TypeScript" /> | ||
52 | </context> | 61 | </context> | ||
53 | 62 | | |||
54 | <!-- TypeScript --> | 63 | <!-- TypeScript --> | ||
55 | 64 | | |||
56 | <!-- Overwrite rules of 'typescript.xml'. These rules send to contexts | 65 | <!-- Overwrite rules of 'typescript.xml'. These rules send to contexts | ||
57 | that contain: <IncludeRules context="Normal"/> in the TypeScript XML file. --> | 66 | that contain: <IncludeRules context="Normal"/> in the TypeScript XML file. --> | ||
58 | <context name="OverwriteTypeScript" attribute="Normal Text" lineEndContext="#stay"> | 67 | <context name="OverwriteTypeScript" attribute="Normal Text" lineEndContext="#stay"> | ||
59 | <DetectChar context="Template" attribute="Template" char="`" /> | 68 | <DetectChar context="Template" attribute="Template" char="`" /> | ||
60 | <DetectChar context="Object" attribute="Symbol" char="{" beginRegion="Brace" /> | 69 | <DetectChar context="Object" attribute="Symbol" char="{" beginRegion="Brace" /> | ||
61 | <DetectChar context="Annotation" attribute="Symbol" char=":" /> | 70 | <DetectChar context="Types" attribute="Symbol" char=":" /> | ||
62 | <RegExpr context="Annotation" attribute="Reserved" String="\btype\b(?!\s*[\?!]?:)" /> | 71 | <RegExpr context="TypeDeclaration" attribute="Reserved" String="\btype\b(?!\s*[\?!]?:)" /> | ||
63 | <AnyChar context="#stay" attribute="Symbol" String="[]" /> | 72 | <RegExpr context="TypesAngleBracket" attribute="Symbol" String="<(?=(&identifier;|[\[\{\(<]).*>)" /> | ||
73 | <DetectChar context="#stay" attribute="Symbol" char="[" beginRegion="List" /> | ||||
74 | <DetectChar context="#stay" attribute="Symbol" char="]" endRegion="List" /> | ||||
64 | </context> | 75 | </context> | ||
76 | | ||||
65 | <context name="Object" attribute="Normal Text" lineEndContext="#stay"> | 77 | <context name="Object" attribute="Normal Text" lineEndContext="#stay"> | ||
66 | <DetectChar context="#pop" attribute="Symbol" char="}" endRegion="Brace" /> | 78 | <DetectChar context="#pop" attribute="Symbol" char="}" endRegion="Brace" /> | ||
67 | <IncludeRules context="React" /> | 79 | <IncludeRules context="React" /> | ||
68 | <IncludeRules context="Object##TypeScript" /> | 80 | <IncludeRules context="Object##TypeScript" /> | ||
69 | </context> | 81 | </context> | ||
70 | <context name="Template" attribute="Template" lineEndContext="#stay"> | 82 | <context name="Template" attribute="Template" lineEndContext="#stay"> | ||
71 | <DetectChar context="#pop" attribute="Template" char="`" /> | 83 | <DetectChar context="#pop" attribute="Template" char="`" /> | ||
72 | <Detect2Chars context="Substitution" attribute="Substitution" char="$" char1="{" /> | 84 | <Detect2Chars context="Substitution" attribute="Substitution" char="$" char1="{" /> | ||
73 | <IncludeRules context="Template##TypeScript" /> | 85 | <IncludeRules context="Template##TypeScript" /> | ||
74 | </context> | 86 | </context> | ||
75 | <context name="Substitution" attribute="Normal Text" lineEndContext="#stay"> | 87 | <context name="Substitution" attribute="Normal Text" lineEndContext="#stay"> | ||
76 | <DetectChar context="#pop" attribute="Substitution" char="}" /> | 88 | <DetectChar context="#pop" attribute="Substitution" char="}" /> | ||
77 | <IncludeRules context="React" /> | 89 | <IncludeRules context="React" /> | ||
78 | <IncludeRules context="Substitution##TypeScript" /> | 90 | <IncludeRules context="Substitution##TypeScript" /> | ||
79 | </context> | 91 | </context> | ||
80 | 92 | | |||
81 | <context name="Annotation" attribute="Normal Text" lineEndContext="#pop"> | 93 | <!-- NOTE: Contexts completely overwritten! --> | ||
82 | <AnyChar context="#pop" String=";,{})]" lookAhead="true" /> | | |||
83 | <Detect2Chars context="#pop" char="/" char1="/" lookAhead="true" /> | | |||
84 | 94 | | |||
85 | <DetectChar context="SquareBracket-BeforeTag" attribute="Symbol" char="[" /> | 95 | <context name="TypeDeclaration" attribute="Normal Text" lineEndContext="#stay"> | ||
86 | <DetectChar context="RoundBracket-BeforeTag" char="(" /> | 96 | <DetectSpaces /> | ||
97 | <IncludeRules context="TypeDeclarationEnd##TypeScript" /> | ||||
98 | <!-- React --> | ||||
99 | <IncludeRules context="TypesFindBrackets" /> | ||||
100 | <IncludeRules context="React" /> | ||||
101 | <!-- TypeDeclaration##TypeScript --> | ||||
102 | <IncludeRules context="DefaultTypes##TypeScript" /> | ||||
103 | <IncludeRules context="Normal##TypeScript" /> | ||||
104 | </context> | ||||
87 | 105 | | |||
106 | <context name="Types" attribute="Normal Text" lineEndContext="#pop"> | ||||
107 | <IncludeRules context="FixPopLineEndContext##TypeScript" /> | ||||
108 | <IncludeRules context="TypesCommon" /> | ||||
109 | </context> | ||||
110 | <context name="TypesCommon" attribute="Normal Text" lineEndContext="#pop"> | ||||
111 | <DetectSpaces /> | ||||
112 | <IncludeRules context="TypesEnd##TypeScript" /> | ||||
113 | <RegExpr context="#pop!TypesNewLine" attribute="Symbol" String="\|(?=\s*($|//|(/\*.*\*/\s*)+$))" /> | ||||
114 | <!-- React --> | ||||
115 | <IncludeRules context="TypesFindBrackets" /> | ||||
88 | <IncludeRules context="React" /> | 116 | <IncludeRules context="React" /> | ||
89 | <IncludeRules context="Annotation##TypeScript" /> | 117 | <!-- TypesCommon##TypeScript --> | ||
118 | <IncludeRules context="DefaultTypes##TypeScript" /> | ||||
119 | <IncludeRules context="Normal##TypeScript" /> | ||||
120 | </context> | ||||
121 | <context name="TypesNewLine" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!TypesCommon"> | ||||
122 | <IncludeRules context="TypesNewLine##TypeScript" /> | ||||
90 | </context> | 123 | </context> | ||
91 | <context name="SquareBracket" attribute="Normal Text" lineEndContext="#stay"> | | |||
92 | <DetectChar context="#pop" attribute="Symbol" char="]" /> | | |||
93 | <DetectChar context="SquareBracket-BeforeTag" attribute="Symbol" char="[" /> | | |||
94 | <DetectChar context="RoundBracket-BeforeTag" char="(" /> | | |||
95 | 124 | | |||
125 | <!-- Overwrite TypesFindBrackets##TypeScript (place before "React") --> | ||||
126 | <context name="TypesFindBrackets" attribute="Normal Text" lineEndContext="#stay"> | ||||
127 | <DetectChar context="TypesSquareBracket-BeforeTag" attribute="Symbol" char="[" beginRegion="List" /> | ||||
128 | <DetectChar context="TypesCurlyBracket-BeforeTag" attribute="Symbol" char="{" beginRegion="Brace" /> | ||||
129 | <DetectChar context="TypesRoundBracket-BeforeTag" char="(" /> | ||||
130 | </context> | ||||
131 | <context name="TypesSquareBracket" attribute="Normal Text" lineEndContext="#stay"> | ||||
132 | <DetectChar context="#pop" attribute="Symbol" char="]" endRegion="List" /> | ||||
133 | <!-- React --> | ||||
134 | <IncludeRules context="TypesFindBrackets" /> | ||||
96 | <IncludeRules context="React" /> | 135 | <IncludeRules context="React" /> | ||
97 | <IncludeRules context="SquareBracket##TypeScript" /> | 136 | <!-- TypesSquareBracket##TypeScript --> | ||
137 | <IncludeRules context="DefaultTypes##TypeScript" /> | ||||
138 | <IncludeRules context="Normal##TypeScript" /> | ||||
98 | </context> | 139 | </context> | ||
99 | <context name="RoundBracket" attribute="Normal Text" lineEndContext="#pop"> | 140 | <context name="TypesCurlyBracket" attribute="Normal Text" lineEndContext="#pop!Object"> | ||
141 | <DetectChar context="#pop" attribute="Symbol" char="}" endRegion="Brace" /> | ||||
142 | <!-- FixPopLineEndContext##TypeScript --> | ||||
143 | <RegExpr context="#pop!Object" String="\S" firstNonSpace="true" lookAhead="true" /> | ||||
144 | <!-- React --> | ||||
145 | <IncludeRules context="TypesFindBrackets" /> | ||||
146 | <IncludeRules context="React" /> | ||||
147 | <!-- TypesCurlyBracket##TypeScript --> | ||||
148 | <IncludeRules context="DefaultTypes##TypeScript" /> | ||||
149 | <IncludeRules context="Object##TypeScript" /> | ||||
150 | </context> | ||||
151 | <context name="TypesRoundBracket" attribute="Normal Text" lineEndContext="#pop"> | ||||
100 | <DetectChar context="#pop" char=")" /> | 152 | <DetectChar context="#pop" char=")" /> | ||
101 | <DetectChar context="SquareBracket-BeforeTag" attribute="Symbol" char="[" /> | 153 | <IncludeRules context="FixPopLineEndContext##TypeScript" /> | ||
102 | <DetectChar context="RoundBracket-BeforeTag" char="(" /> | 154 | <!-- React --> | ||
103 | 155 | <IncludeRules context="TypesFindBrackets" /> | |||
104 | <IncludeRules context="React" /> | 156 | <IncludeRules context="React" /> | ||
105 | <IncludeRules context="RoundBracket##TypeScript" /> | 157 | <!-- TypesRoundBracket##TypeScript --> | ||
158 | <IncludeRules context="DefaultTypes##TypeScript" /> | ||||
159 | <IncludeRules context="Normal##TypeScript" /> | ||||
160 | </context> | ||||
161 | <context name="TypesAngleBracket" attribute="Normal Text" lineEndContext="#pop"> | ||||
162 | <DetectChar context="#pop" attribute="Symbol" char=">" /> | ||||
163 | <IncludeRules context="TypesAngleBracketEnd##TypeScript" /> | ||||
164 | <IncludeRules context="FixPopLineEndContext##TypeScript" /> | ||||
165 | <!-- React! --> | ||||
166 | <IncludeRules context="TypesFindBrackets" /> | ||||
167 | <IncludeRules context="React" /> | ||||
168 | <!-- TypesAngleBracket##TypeScript --> | ||||
169 | <IncludeRules context="DefaultTypes##TypeScript" /> | ||||
170 | <IncludeRules context="Normal##TypeScript" /> | ||||
106 | </context> | 171 | </context> | ||
107 | 172 | | |||
108 | <!-- ReactJS --> | 173 | <!-- ReactJS --> | ||
109 | 174 | | |||
110 | <!-- Tags highlighting --> | 175 | <!-- Tags highlighting --> | ||
111 | <context name="React" attribute="Normal Text" lineEndContext="#stay"> | 176 | <context name="React" attribute="Normal Text" lineEndContext="#stay"> | ||
112 | <!-- Tag in new line --> | 177 | <!-- Tag in new line --> | ||
113 | <RegExpr context="ValidTag" attribute="Normal Text" String="&tag;" firstNonSpace="true" lookAhead="true" /> | 178 | <RegExpr context="ValidTag" attribute="Normal Text" String="&tag;" firstNonSpace="true" lookAhead="true" /> | ||
114 | <!-- Highlight tags only after some keywords --> | 179 | <!-- Highlight tags only after some keywords --> | ||
115 | <RegExpr context="ValidTag" attribute="ControlFlow" String="\b(return)\s*(?=&tag;|/\*)" /> | 180 | <RegExpr context="ValidTag" attribute="ControlFlow" String="\b(return|await)\s*(?=&tag;|/\*)" /> | ||
116 | <RegExpr context="ValidTag" attribute="Module" String="\b(default)\s*(?=&tag;|/\*)" /> | 181 | <RegExpr context="ValidTag" attribute="Module" String="\b(default)\s*(?=&tag;|/\*)" /> | ||
182 | <RegExpr context="ValidTag" attribute="Reserved" String="\b(yield)\s*(?=&tag;|/\*)" /> | ||||
117 | 183 | | |||
118 | <!-- Characters before a valid tag --> | 184 | <!-- Characters before a valid tag --> | ||
185 | <RegExpr context="ValidTag" attribute="Special Operators" String="\=>\s*(?=&tag;|/\*)" /> | ||||
119 | <RegExpr context="ValidTag" attribute="Symbol" String="([\[,\=>\*\?]|&&|\|\|)\s*(?=&tag;|/\*)" /> | 186 | <RegExpr context="ValidTag" attribute="Symbol" String="([\[,\=>\*\?]|&&|\|\|)\s*(?=&tag;|/\*)" /> | ||
120 | <RegExpr context="ValidTag" attribute="Normal Text" String="\(\s*(?=&tag;|/\*)" /> | 187 | <RegExpr context="ValidTag" attribute="Normal Text" String="\(\s*(?=&tag;|/\*)" /> | ||
121 | <!-- The "Object-BeforeTag" context looks for a valid Tag and then sends the "Object" context --> | 188 | <!-- The "Object-BeforeTag" context looks for a valid Tag and then sends the "Object" context --> | ||
122 | <RegExpr context="Object-BeforeTag" attribute="Symbol" String="\{\s*(?=&tag;|/\*)" beginRegion="Brace" /> | 189 | <RegExpr context="Object-BeforeTag" attribute="Symbol" String="\{\s*(?=&tag;|/\*)" beginRegion="Brace" /> | ||
123 | <RegExpr context="Annotation-BeforeTag" attribute="Symbol" String=":\s*(?=&tag;|/\*)" /> | 190 | <RegExpr context="Types-BeforeTag" attribute="Symbol" String=":\s*(?=&tag;|/\*)" /> | ||
191 | | ||||
192 | <RegExpr context="ValidTag" attribute="Symbol" String="<\s*>\s*(?=&tag;|/\*)" /> | ||||
124 | 193 | | |||
125 | <!-- Tag after a comment on a new line --> | 194 | <!-- Tag after a comment on a new line --> | ||
126 | <Detect2Chars context="ValidTag" attribute="Comment" char="/" char1="*" firstNonSpace="true" lookAhead="true" /> | 195 | <Detect2Chars context="ValidTag" attribute="Comment" char="/" char1="*" firstNonSpace="true" lookAhead="true" /> | ||
127 | 196 | | |||
128 | <!-- Overwrite TypeScript rules to highlight tags within some contexts --> | 197 | <!-- Overwrite TypeScript rules to highlight tags within some contexts --> | ||
129 | <IncludeRules context="OverwriteTypeScript" /> | 198 | <IncludeRules context="OverwriteTypeScript" /> | ||
130 | </context> | 199 | </context> | ||
131 | 200 | | |||
132 | <!-- Highlight nested tags with comments in between. | 201 | <!-- Detect tags before starting a context --> | ||
133 | NOTE: The highlighting of Tags after a multiline comment does not work with: lineEndContext="#pop" --> | | |||
134 | <context name="ValidTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop"> | | |||
135 | <RegExpr context="#stay" attribute="Normal Text" String="\s+(?=<|/\*)" /> | | |||
136 | <IncludeRules context="FindTags" /> | | |||
137 | <!-- Doxygen & Multi-line comments! --> | | |||
138 | <Detect2Chars context="#pop" attribute="Comment" char="/" char1="/" lookAhead="true" /> | | |||
139 | <IncludeRules context="AllComments" /> | | |||
140 | </context> | | |||
141 | <context name="Object-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!Object"> | 202 | <context name="Object-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!Object"> | ||
142 | <IncludeRules context="ValidTag" /> | 203 | <IncludeRules context="ValidTag" /> | ||
143 | </context> | 204 | </context> | ||
144 | <context name="EvaluatedCode-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!EvaluatedCode"> | 205 | <context name="EvaluatedCode-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!EvaluatedCode"> | ||
145 | <IncludeRules context="ValidTag" /> | 206 | <IncludeRules context="ValidTag" /> | ||
146 | </context> | 207 | </context> | ||
147 | 208 | | |||
148 | <context name="Annotation-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!Annotation"> | 209 | <context name="Types-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!Types"> | ||
149 | <IncludeRules context="ValidTag" /> | 210 | <IncludeRules context="ValidTag" /> | ||
150 | </context> | 211 | </context> | ||
151 | <context name="SquareBracket-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!SquareBracket"> | 212 | <context name="TypesSquareBracket-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!TypesSquareBracket"> | ||
152 | <IncludeRules context="ValidTag" /> | 213 | <IncludeRules context="ValidTag" /> | ||
153 | </context> | 214 | </context> | ||
154 | <context name="RoundBracket-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!RoundBracket"> | 215 | <context name="TypesCurlyBracket-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!TypesCurlyBracket"> | ||
155 | <IncludeRules context="ValidTag" /> | 216 | <IncludeRules context="ValidTag" /> | ||
156 | </context> | 217 | </context> | ||
218 | <context name="TypesRoundBracket-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!TypesRoundBracket"> | ||||
219 | <IncludeRules context="ValidTag" /> | ||||
220 | </context> | ||||
221 | | ||||
222 | <!-- TAGS: | ||||
223 | NOTE & TODO: The following code is common for 'javascript-react.xml' and 'typescript-react.xml' | ||||
224 | and is replicated in both files. Look for some way to avoid having repeated code, for example, | ||||
225 | with a common XML file or with a generator script. The only drawback is that the | ||||
226 | "EvaluatedCode" context includes "Normal". --> | ||||
227 | | ||||
228 | <!-- Highlight nested tags with comments in between. | ||||
229 | NOTE: The highlighting of Tags after a multiline comment does not work with: lineEndContext="#pop" --> | ||||
230 | <context name="ValidTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop"> | ||||
231 | <RegExpr context="#stay" attribute="Normal Text" String="\s+(?=<|/\*)" /> | ||||
232 | <IncludeRules context="FindTags" /> | ||||
233 | <!-- Doxygen & Multi-line comments! --> | ||||
234 | <Detect2Chars context="#pop" attribute="Comment" char="/" char1="/" lookAhead="true" /> | ||||
235 | <IncludeRules context="AllComments" /> | ||||
236 | </context> | ||||
157 | 237 | | |||
158 | <!-- Start tag --> | 238 | <!-- Start tag --> | ||
159 | <context name="FindTags" attribute="Normal Text" lineEndContext="#stay"> | 239 | <context name="FindTags" attribute="Normal Text" lineEndContext="#stay"> | ||
240 | <!-- Empty tag (element) --> | ||||
241 | <RegExpr context="ElementTagContent" attribute="Element Tag" String="<\s*>" beginRegion="Element" /> | ||||
242 | <!-- Detect non-ASCII character in the tag name (component). This prevents highlighting as Element, | ||||
243 | tag names that don't start with a non-ASCII character. --> | ||||
244 | <RegExpr context="ComponentTagNonASCII" attribute="Component Tag" String="<\s*(?=([a-z][a-z\d]*:)?([a-z][a-z\d]*)?[^[:ascii:]])" beginRegion="ComponentElement" /> <!-- &simpleName; --> | ||||
245 | <!-- Element & component tags --> | ||||
160 | <RegExpr context="ElementTag" attribute="Element Tag" String="&simpleTag;(?=[^\w\$\-\.:]|$|[\-\.]+([^\w\$\-\.]|$)|:([^a-zA-Z_\$]|$))" beginRegion="Element" /> | 246 | <RegExpr context="ElementTag" attribute="Element Tag" String="&simpleTag;(?=[^\w\$\-\.:]|$|[\-\.]+([^\w\$\-\.]|$)|:([^a-zA-Z_\$]|$))" beginRegion="Element" /> | ||
161 | <RegExpr context="ComponentTag" attribute="Component Tag" String="&tag;" beginRegion="ComponentElement" /> | 247 | <RegExpr context="ComponentTagFindType" attribute="Component Tag" String="&tag;" beginRegion="ComponentElement" /> | ||
162 | </context> | 248 | </context> | ||
163 | <context name="FindEntityRefs" attribute="Normal Text" lineEndContext="#stay"> | 249 | <context name="FindEntityRefs" attribute="Normal Text" lineEndContext="#stay"> | ||
164 | <RegExpr context="#stay" attribute="EntityRef" String="&entref;" /> | 250 | <RegExpr context="#stay" attribute="EntityRef" String="&entref;" /> | ||
165 | </context> | 251 | </context> | ||
166 | 252 | | |||
253 | <!-- Inside the tag --> | ||||
167 | <context name="ElementTag" attribute="Normal Text" lineEndContext="#stay"> | 254 | <context name="ElementTag" attribute="Normal Text" lineEndContext="#stay"> | ||
168 | <Detect2Chars context="#pop" attribute="Element Tag" char="/" char1=">" endRegion="Element" /> | 255 | <Detect2Chars context="#pop" attribute="Element Tag" char="/" char1=">" endRegion="Element" /> | ||
169 | <DetectChar context="#pop!ElementTagContent" attribute="Element Tag" char=">" /> | 256 | <DetectChar context="#pop!ElementTagContent" attribute="Element Tag" char=">" /> | ||
170 | <IncludeRules context="DefaultTag" /> | 257 | <IncludeRules context="DefaultTag" /> | ||
171 | </context> | 258 | </context> | ||
172 | <context name="ComponentTag" attribute="Normal Text" lineEndContext="#stay"> | 259 | <context name="ComponentTag" attribute="Normal Text" lineEndContext="#stay"> | ||
173 | <Detect2Chars context="#pop" attribute="Component Tag" char="/" char1=">" endRegion="ComponentElement" /> | 260 | <Detect2Chars context="#pop" attribute="Component Tag" char="/" char1=">" endRegion="ComponentElement" /> | ||
174 | <DetectChar context="#pop!ComponentTagContent" attribute="Component Tag" char=">" /> | 261 | <DetectChar context="#pop!ComponentTagContent" attribute="Component Tag" char=">" /> | ||
175 | <IncludeRules context="DefaultTag" /> | 262 | <IncludeRules context="DefaultTag" /> | ||
176 | </context> | 263 | </context> | ||
264 | <!-- Type after the tag name. Ex: <C<number> /> --> | ||||
265 | <context name="ComponentTagFindType" attribute="Normal Text" lineEndContext="#pop!ComponentTag" fallthrough="true" fallthroughContext="#pop!ComponentTag"> | ||||
266 | <DetectChar context="#pop!TypeInsideTag" attribute="Symbol" char="<" /> | ||||
267 | </context> | ||||
268 | <!-- Highlight tag name with non-ASCII characters --> | ||||
269 | <context name="ComponentTagNonASCII" attribute="Normal Text" lineEndContext="#pop!ComponentTag" fallthrough="true" fallthroughContext="#pop!ComponentTag"> | ||||
270 | <RegExpr context="#pop!ComponentTagFindType" attribute="Component Tag" String="&name;" /> | ||||
271 | </context> | ||||
177 | <context name="DefaultTag" attribute="Normal Text" lineEndContext="#stay"> | 272 | <context name="DefaultTag" attribute="Normal Text" lineEndContext="#stay"> | ||
178 | <RegExpr context="Attribute" attribute="Attribute" String="\b&name;" /> | 273 | <RegExpr context="Attribute" attribute="Attribute" String="&nameWithBound;" /> | ||
274 | <IncludeRules context="FindEvaluatedCode" /> | ||||
179 | <IncludeRules context="AllComments" /> | 275 | <IncludeRules context="AllComments" /> | ||
180 | <RegExpr context="#stay" attribute="Error" String="\S+&name;" /> | 276 | <RegExpr context="#stay" attribute="Error" String="\S+&name;" /> | ||
181 | <RegExpr context="#stay" attribute="Error" String="\S" /> | 277 | <RegExpr context="#stay" attribute="Error" String="\S" /> | ||
182 | </context> | 278 | </context> | ||
183 | 279 | | |||
280 | <!-- Type assertion after the tag name --> | ||||
281 | <context name="TypeInsideTag" attribute="Component Tag" lineEndContext="#stay"> | ||||
282 | <DetectChar context="#pop!ComponentTag" attribute="Symbol" char=">" /> | ||||
283 | <IncludeRules context="DefaultTypeInsideTag" /> | ||||
284 | </context> | ||||
285 | <context name="DefaultTypeInsideTag" attribute="Component Tag" lineEndContext="#stay"> | ||||
286 | <DetectChar context="TypeInsideTag-AngleBracket" attribute="Symbol" char="<" /> | ||||
287 | <DetectChar context="TypeInsideTag-CurlyBracket" attribute="Symbol" char="{" /> | ||||
288 | <DetectChar context="TypeInsideTag-SquareBracket" attribute="Symbol" char="[" /> | ||||
289 | <DetectChar context="TypeInsideTag-RoundBracket" attribute="Symbol" char="(" /> | ||||
290 | <IncludeRules context="AllComments" /> | ||||
291 | </context> | ||||
292 | <context name="TypeInsideTag-AngleBracket" attribute="Component Tag" lineEndContext="#stay"> | ||||
293 | <DetectChar context="#pop" attribute="Symbol" char=">" /> | ||||
294 | <IncludeRules context="DefaultTypeInsideTag" /> | ||||
295 | </context> | ||||
296 | <context name="TypeInsideTag-CurlyBracket" attribute="Component Tag" lineEndContext="#stay"> | ||||
297 | <DetectChar context="#pop" attribute="Symbol" char="}" /> | ||||
298 | <IncludeRules context="DefaultTypeInsideTag" /> | ||||
299 | </context> | ||||
300 | <context name="TypeInsideTag-SquareBracket" attribute="Component Tag" lineEndContext="#stay"> | ||||
301 | <DetectChar context="#pop" attribute="Symbol" char="]" /> | ||||
302 | <IncludeRules context="DefaultTypeInsideTag" /> | ||||
303 | </context> | ||||
304 | <context name="TypeInsideTag-RoundBracket" attribute="Component Tag" lineEndContext="#stay"> | ||||
305 | <DetectChar context="#pop" attribute="Symbol" char=")" /> | ||||
306 | <IncludeRules context="DefaultTypeInsideTag" /> | ||||
307 | </context> | ||||
308 | | ||||
309 | <!-- Tag content: <Tag> content </Tag> --> | ||||
184 | <context name="ElementTagContent" attribute="Tag Content Text" lineEndContext="#stay"> | 310 | <context name="ElementTagContent" attribute="Tag Content Text" lineEndContext="#stay"> | ||
311 | <RegExpr context="#pop" attribute="Element Tag" String="</\s*>" endRegion="Element" /> | ||||
185 | <RegExpr context="ElementTagEnd" attribute="Element Tag" String="</\s*&simpleName;" /> | 312 | <RegExpr context="ElementTagEnd" attribute="Element Tag" String="</\s*&simpleName;" /> | ||
186 | <RegExpr context="ElementTagEnd" attribute="Element Tag" String="</\s*(?=[A-Z_\$])" /> <!-- Component tag (error) --> | 313 | <RegExpr context="ElementTagEnd" attribute="Element Tag" String="</\s*(?=[A-Z_\$])" /> <!-- Component tag (error) --> | ||
187 | <IncludeRules context="DefaultTagContent" /> | 314 | <IncludeRules context="DefaultTagContent" /> | ||
188 | </context> | 315 | </context> | ||
189 | <context name="ComponentTagContent" attribute="Tag Content Text" lineEndContext="#stay"> | 316 | <context name="ComponentTagContent" attribute="Tag Content Text" lineEndContext="#stay"> | ||
317 | <RegExpr context="#pop" attribute="Component Tag" String="</\s*>" endRegion="ComponentElement" /> | ||||
190 | <RegExpr context="ComponentTagEnd" attribute="Component Tag" String="</\s*&name;" /> | 318 | <RegExpr context="ComponentTagEnd" attribute="Component Tag" String="</\s*&name;" /> | ||
191 | <IncludeRules context="DefaultTagContent" /> | 319 | <IncludeRules context="DefaultTagContent" /> | ||
192 | </context> | 320 | </context> | ||
193 | <context name="DefaultTagContent" attribute="Tag Content Text" lineEndContext="#stay"> | 321 | <context name="DefaultTagContent" attribute="Tag Content Text" lineEndContext="#stay"> | ||
194 | <IncludeRules context="FindTags" /> | 322 | <IncludeRules context="FindTags" /> | ||
195 | <IncludeRules context="FindEntityRefs" /> | 323 | <IncludeRules context="FindEntityRefs" /> | ||
196 | <RegExpr context="EvaluatedCode-BeforeTag" attribute="Code Brackets" String="\{\s*(?=&tag;|/\*)" beginRegion="Code" /> | 324 | <IncludeRules context="FindEvaluatedCode" /> | ||
197 | <DetectChar context="EvaluatedCode" attribute="Code Brackets" char="{" beginRegion="Code" /> | | |||
198 | <DetectChar context="#stay" attribute="Error" char="<" /> | 325 | <DetectChar context="#stay" attribute="Error" char="<" /> | ||
199 | </context> | 326 | </context> | ||
200 | 327 | | |||
201 | <context name="ElementTagEnd" attribute="Normal Text" lineEndContext="#stay"> | 328 | <context name="ElementTagEnd" attribute="Normal Text" lineEndContext="#stay"> | ||
202 | <DetectChar context="#pop#pop" attribute="Element Tag" char=">" endRegion="Element" /> | 329 | <DetectChar context="#pop#pop" attribute="Element Tag" char=">" endRegion="Element" /> | ||
203 | <RegExpr context="#stay" attribute="Error" String="\S" /> | 330 | <RegExpr context="#stay" attribute="Error" String="\S" /> | ||
204 | </context> | 331 | </context> | ||
205 | <context name="ComponentTagEnd" attribute="Normal Text" lineEndContext="#stay"> | 332 | <context name="ComponentTagEnd" attribute="Normal Text" lineEndContext="#stay"> | ||
206 | <DetectChar context="#pop#pop" attribute="Component Tag" char=">" endRegion="ComponentElement" /> | 333 | <DetectChar context="#pop#pop" attribute="Component Tag" char=">" endRegion="ComponentElement" /> | ||
207 | <RegExpr context="#stay" attribute="Error" String="\S" /> | 334 | <RegExpr context="#stay" attribute="Error" String="\S" /> | ||
208 | </context> | 335 | </context> | ||
209 | 336 | | |||
337 | <!-- Tag attribute --> | ||||
210 | <context name="Attribute" attribute="Normal Text" lineEndContext="#stay"> | 338 | <context name="Attribute" attribute="Normal Text" lineEndContext="#stay"> | ||
339 | <RegExpr context="#pop" attribute="Error" String="\=(?=\s*/?>)" /> | ||||
211 | <DetectChar context="#pop!Value" attribute="Symbol" char="=" /> | 340 | <DetectChar context="#pop!Value" attribute="Symbol" char="=" /> | ||
212 | <Detect2Chars context="#pop" attribute="Normal Text" char="/" char1=">" lookAhead="true" /> | 341 | <IncludeRules context="FindEndTag" /> | ||
213 | <DetectChar context="#pop" attribute="Normal Text" char=">" lookAhead="true" /> | 342 | <DetectChar context="#pop" char="{" lookAhead="true" /> <!-- EvaluatedCode --> | ||
214 | <IncludeRules context="AllComments" /> | 343 | <IncludeRules context="AllComments" /> | ||
215 | <RegExpr context="#stay" attribute="Attribute" String="\b&name;" /> | 344 | <RegExpr context="#stay" attribute="Attribute" String="&nameWithBound;" /> | ||
216 | <RegExpr context="#stay" attribute="Error" String="\S+&name;" /> | 345 | <RegExpr context="#stay" attribute="Error" String="\S+&name;" /> | ||
217 | <RegExpr context="#stay" attribute="Error" String="\S" /> | 346 | <RegExpr context="#stay" attribute="Error" String="\S" /> | ||
218 | </context> | 347 | </context> | ||
219 | 348 | | |||
220 | <context name="Value" attribute="Normal Text" lineEndContext="#stay"> | 349 | <context name="Value" attribute="Normal Text" lineEndContext="#stay"> | ||
221 | <DetectChar context="#pop!ValueDQ" attribute="Value" char=""" /> | 350 | <DetectChar context="#pop!ValueDQ" attribute="Value" char=""" /> | ||
222 | <DetectChar context="#pop!ValueSQ" attribute="Value" char="'" /> | 351 | <DetectChar context="#pop!ValueSQ" attribute="Value" char="'" /> | ||
223 | <RegExpr context="#pop!EvaluatedCode-BeforeTag" attribute="Code Brackets" String="\{\s*(?=&tag;|/\*)" beginRegion="Code" /> | 352 | <DetectChar context="#pop" char="{" lookAhead="true" /> <!-- EvaluatedCode --> | ||
224 | <DetectChar context="#pop!EvaluatedCode" attribute="Code Brackets" char="{" beginRegion="Code" /> | 353 | <IncludeRules context="FindEndTag" /> | ||
225 | <IncludeRules context="AllComments" /> | 354 | <IncludeRules context="AllComments" /> | ||
226 | <RegExpr context="#stay" attribute="Error" String="\S" /> | 355 | <RegExpr context="#stay" attribute="Error" String="\S" /> | ||
227 | </context> | 356 | </context> | ||
228 | <context name="ValueDQ" attribute="Value" lineEndContext="#stay"> | 357 | <context name="ValueDQ" attribute="Value" lineEndContext="#stay"> | ||
229 | <DetectChar context="#pop" attribute="Value" char=""" /> | 358 | <DetectChar context="#pop" attribute="Value" char=""" /> | ||
230 | <IncludeRules context="FindEntityRefs" /> | 359 | <IncludeRules context="FindEntityRefs" /> | ||
231 | </context> | 360 | </context> | ||
232 | <context name="ValueSQ" attribute="Value" lineEndContext="#stay"> | 361 | <context name="ValueSQ" attribute="Value" lineEndContext="#stay"> | ||
233 | <DetectChar context="#pop" attribute="Value" char="'" /> | 362 | <DetectChar context="#pop" attribute="Value" char="'" /> | ||
234 | <IncludeRules context="FindEntityRefs" /> | 363 | <IncludeRules context="FindEntityRefs" /> | ||
235 | </context> | 364 | </context> | ||
365 | | ||||
366 | <context name="FindEndTag" attribute="Normal Text" lineEndContext="#stay"> | ||||
367 | <Detect2Chars context="#pop" char="/" char1=">" lookAhead="true" /> | ||||
368 | <DetectChar context="#pop" char=">" lookAhead="true" /> | ||||
369 | </context> | ||||
370 | | ||||
371 | <context name="FindEvaluatedCode" attribute="Normal Text" lineEndContext="#stay"> | ||||
372 | <RegExpr context="EvaluatedCode-BeforeTag" attribute="Code Brackets" String="\{\s*(?=&tag;|/\*)" beginRegion="Code" /> | ||||
373 | <DetectChar context="EvaluatedCode" attribute="Code Brackets" char="{" beginRegion="Code" /> | ||||
374 | </context> | ||||
236 | <context name="EvaluatedCode" attribute="Normal Text" lineEndContext="#stay"> | 375 | <context name="EvaluatedCode" attribute="Normal Text" lineEndContext="#stay"> | ||
237 | <DetectChar context="#pop" attribute="Code Brackets" char="}" endRegion="Code" /> | 376 | <DetectChar context="#pop" attribute="Code Brackets" char="}" endRegion="Code" /> | ||
238 | <IncludeRules context="Normal" /> | 377 | <IncludeRules context="Normal" /> | ||
239 | </context> | 378 | </context> | ||
240 | 379 | | |||
241 | <context name="AllComments" attribute="Normal Text" lineEndContext="#stay"> | 380 | <context name="AllComments" attribute="Normal Text" lineEndContext="#stay"> | ||
242 | <!-- TypeScript uses this for comments --> | 381 | <!-- TypeScript uses this for comments --> | ||
243 | <IncludeRules context="FindComments##JavaScript" /> | 382 | <IncludeRules context="FindComments##JavaScript" /> | ||
Show All 16 Lines | 387 | <itemDatas> | |||
260 | 399 | | |||
261 | <!-- itemDatas in TypeScript XML file --> | 400 | <!-- itemDatas in TypeScript XML file --> | ||
262 | <itemData name="Symbol" defStyleNum="dsOperator" /> | 401 | <itemData name="Symbol" defStyleNum="dsOperator" /> | ||
263 | <itemData name="ControlFlow" defStyleNum="dsControlFlow" spellChecking="false" /> | 402 | <itemData name="ControlFlow" defStyleNum="dsControlFlow" spellChecking="false" /> | ||
264 | <itemData name="Reserved" defStyleNum="dsKeyword" italic="true" spellChecking="false" /> | 403 | <itemData name="Reserved" defStyleNum="dsKeyword" italic="true" spellChecking="false" /> | ||
265 | <itemData name="Module" defStyleNum="dsImport" spellChecking="false" /> | 404 | <itemData name="Module" defStyleNum="dsImport" spellChecking="false" /> | ||
266 | <itemData name="Template" defStyleNum="dsVerbatimString" /> | 405 | <itemData name="Template" defStyleNum="dsVerbatimString" /> | ||
267 | <itemData name="Substitution" defStyleNum="dsSpecialChar" spellChecking="false" /> | 406 | <itemData name="Substitution" defStyleNum="dsSpecialChar" spellChecking="false" /> | ||
407 | <itemData name="Special Operators" defStyleNum="dsKeyword" spellChecking="false" /> | ||||
268 | </itemDatas> | 408 | </itemDatas> | ||
269 | 409 | | |||
270 | </highlighting> | 410 | </highlighting> | ||
271 | 411 | | |||
272 | <general> | 412 | <general> | ||
273 | <keywords casesensitive="1" /> | 413 | <keywords casesensitive="1" /> | ||
274 | <comments> | 414 | <comments> | ||
275 | <comment name="singleLine" start="//" /> | 415 | <comment name="singleLine" start="//" /> | ||
276 | <comment name="multiLine" start="/*" end="*/" /> | 416 | <comment name="multiLine" start="/*" end="*/" /> | ||
277 | </comments> | 417 | </comments> | ||
278 | </general> | 418 | </general> | ||
279 | 419 | | |||
280 | </language> | 420 | </language> | ||
281 | <!-- kate: replace-tabs off; tab-width 3; indent-width 3; remove-trailing-spaces mod; dynamic-word-wrap off; --> | 421 | <!-- kate: replace-tabs off; tab-width 3; indent-width 3; remove-trailing-spaces mod; dynamic-word-wrap off; --> |