Warning, /frameworks/syntax-highlighting/data/syntax/typescript-react.xml is written in an unsupported language. File is not indexed.
0001 <?xml version="1.0" encoding="UTF-8"?>
0002 <!DOCTYPE language
0003 [
0004 <!ENTITY simpleName "(?:[a-z][a-z\d]*:)?[a-z][a-z\d]*">
0005 <!ENTITY baseName "[a-zA-Z_\$[:^ascii:]](?:[\w\$\-\.[:^ascii:]]*[\w\$[:^ascii:]])?">
0006 <!ENTITY name "(?:&baseName;:)?&baseName;">
0007 <!ENTITY baseNameWithBound "(?:\b[a-zA-Z_\$]|[^[:ascii:]])(?:[\w\$\-\.[:^ascii:]]*[\w\$[:^ascii:]])?">
0008 <!ENTITY nameWithBound "(?:&baseNameWithBound;:)?&baseNameWithBound;"> <!-- Use this instead of "\b&name;" -->
0009
0010 <!ENTITY simpleTag "<\s*&simpleName;"> <!-- Element tag -->
0011 <!ENTITY tag "<\s*(?:&name;|>)">
0012 <!ENTITY entref "&(?:[a-zA-Z\d]+|#\d+|#x[a-fA-F\d]+);">
0013 <!ENTITY mlComment "/\*(?:[^\*]|\*+[^/\*])*\*+/">
0014 <!ENTITY endTagName "[\s<>]|/[>/\*]|$"> <!-- Delimiter of end of Tag name -->
0015
0016 <!ENTITY identifier "[a-zA-Z_$[:^ascii:]][\w$[:^ascii:]]*">
0017 <!ENTITY objectOp "[\?!]?">
0018 <!ENTITY endLine "\s*(?:$|//|(?:/\*.*\*/\s*)+(?:$|//))">
0019
0020 <!ENTITY codeContent ""(?:[^"]|\\.)*"|'(?:[^']|\\.)*'|`(?:[^`]|\\.)`|/\*.*\*/|/(?:[^/\\\[]|\\.|\[(?:[^\]\\]|\\.)+\])+/">
0021 <!ENTITY conditionalExpression "\?(?=\s*(?:(?:[^/"'`\s\?:\.;,\=\}\]\)]|&codeContent;)(?:[^/"'`]|&codeContent;)*)?&identifier;\s*(?:/\*.*\*/\s*)*:|(?:&&|\|\||\s*(?:/\*.*\*/\s*)*&identifier;)?&endLine;)">
0022
0023 <!-- Because TSX cannot have "cast" expression, we can say "<T extends" starts the type parameter of arrow
0024 See: https://github.com/microsoft/TypeScript-TmLanguage/commit/11b1a4f8dc3a3eaa4df71e8cc1ad6f01a688961d#diff-d5222b162266b45fd998419db416fddd -->
0025 <!ENTITY typesAngleBracket1 "<(?=\s*&identifier;\s+extends\s*[^\=>])">
0026 <!-- Invalid Tag, do not highlight tags in these cases:
0027 * "?" or "," after tag name:
0028 <Tag ? ...
0029 <Tag< ? ...
0030 <Tag /* comment */ ? ...
0031 * Invalid delimiter after comment (without spaces):
0032 <Tag/* comment */#
0033 -->
0034 <!ENTITY typesAngleBracket2 "<(?=\s*&name;(?:(<(?:\s*&mlComment;)*)?(?:\s*&mlComment;)*\s*[\?,]|(?:&mlComment;)+(?!&endTagName;|&baseName;|\{)))">
0035 ]>
0036
0037 <!--
0038 ====================================================================
0039
0040 This file is part of the KDE's KSyntaxHighlighting framework.
0041
0042 Copyright 2018-2020 Nibaldo González S. (nibgonz@gmail.com)
0043
0044 This Source Code Form is subject to the terms of the MIT License.
0045 If a copy of the license was not distributed with this file,
0046 You can obtain one at: https://opensource.org/licenses/MIT
0047
0048 ====================================================================
0049
0050 This file is an extension of the TypeScript highlighter
0051 (typescript.xml, Version 7 and higher).
0052 IMPORTANT: Keep sync with "javascript-react.xml".
0053
0054 Based on the XML syntax highlighting (v7), by Wilbert Berendsen
0055 (wilbert@kde.nl), and the TypeScript React grammar files,
0056 available at: https://github.com/Microsoft/TypeScript-TmLanguage
0057
0058 Change log:
0059 * v10 [2020-06-03]: Add folding in templates.
0060 * v9 [2020-02-23]: Adapt to version 9 of "typescript.xml".
0061 * v8 [2019-11-21]: Tag detection is more stricter.
0062 * v7 [2019-11-19]: Rename definition "TypeScript React" to "TypeScript React (TSX)".
0063 * v6 [2019-10-01]: Highlight "<T extends" as a type assertion, not as a Tag.
0064 * v5 [2019-08-30]: Adapt to version 5 of "typescript.xml".
0065 * v4 [2019-07-16]: Adapt to version 4 of "typescript.xml".
0066 * v3 [2019-02-20]: Don't highlight tags within declarations of
0067 types, variables, classes and interfaces.
0068 Fixes tags after substitutions in templates.
0069 Adapt to version 3 of "typescript.xml".
0070 * v2 [2018-12-30]: Adapt to version 2 of "typescript.xml".
0071 Allow type assertion in the tag name.
0072 Allow tags after the keywords "await" & "yield".
0073 Allow empty tags and non-ASCII tag name & attributes.
0074 * v1 [2018-11-18]: Initial version
0075 -->
0076
0077 <language name="TypeScript React (TSX)" version="11" kateversion="5.53" section="Scripts" indenter="cstyle"
0078 priority="9" extensions="*.tsx" mimetype="text/tsx;text/x-tsx;application/tsx;application/x-tsx;"
0079 author="Nibaldo González (nibgonz@gmail.com)" license="MIT">
0080
0081 <highlighting>
0082
0083 <contexts>
0084
0085 <context name="Shebang" attribute="Normal Text" lineEndContext="#pop!Normal" lineEmptyContext="#pop!Normal" fallthrough="true" fallthroughContext="#pop!Normal">
0086 <Detect2Chars context="ShebangLine" attribute="Comment" char="#" char1="!" column="0" />
0087 </context>
0088 <context name="ShebangLine" attribute="Comment" lineEndContext="#pop#pop!Normal" />
0089
0090 <context name="Normal" attribute="Normal Text" lineEndContext="#stay">
0091 <IncludeRules context="React" />
0092 <IncludeRules context="Normal##TypeScript" />
0093 </context>
0094
0095 <!-- TypeScript -->
0096
0097 <!-- Overwrite rules of 'typescript.xml'. These rules send to contexts
0098 that contain: <IncludeRules context="Normal"/> in the TypeScript XML file.
0099 NOTE: After the keyword "type" tags will not be highlighted ("TypeDeclaration" context). -->
0100 <context name="OverwriteTypeScript" attribute="Normal Text" lineEndContext="#stay">
0101 <DetectChar context="Template" attribute="Template" char="`" beginRegion="Template" />
0102 <DetectChar context="Object" attribute="Normal Text" char="{" beginRegion="Brace" />
0103 <DetectChar context="#stay" attribute="Normal Text" char="[" beginRegion="List" />
0104 <DetectChar context="NoRegExp" attribute="Normal Text" char="]" endRegion="List" />
0105 <DetectChar context="Types" attribute="Symbol" char=":" />
0106 <RegExpr context="TypesAngleBracket" attribute="Symbol" String="<(?=(?:&identifier;|[\[\{\(<]).*>)" />
0107 </context>
0108
0109 <context name="Object" attribute="Normal Text" lineEndContext="#stay">
0110 <DetectChar context="#pop" attribute="Normal Text" char="}" endRegion="Brace" />
0111 <RegExpr context="TypesNewLine" attribute="Symbol" String=":(?=&endLine;)" minimal="true" />
0112 <IncludeRules context="React" />
0113 <IncludeRules context="Object##TypeScript" />
0114 </context>
0115 <context name="Template" attribute="Template" lineEndContext="#stay">
0116 <DetectChar context="RegExpAfterString##JavaScript" attribute="Template" char="`" endRegion="Template" />
0117 <!-- Find tags and send to the "Substitution" context -->
0118 <Detect2Chars context="Substitution-BeforeTag" attribute="Substitution" char="$" char1="{" />
0119 <IncludeRules context="Template##TypeScript" />
0120 </context>
0121 <context name="Substitution" attribute="Normal Text" lineEndContext="#stay">
0122 <DetectChar context="#pop" attribute="Substitution" char="}" />
0123 <IncludeRules context="React" />
0124 <IncludeRules context="Substitution##TypeScript" />
0125 </context>
0126
0127 <!-- NOTE: Contexts completely overwritten! -->
0128
0129 <context name="NoRegExp" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop">
0130 <IncludeRules context="NoRegExp##TypeScript" />
0131 </context>
0132
0133 <context name="ConditionalExpression" attribute="Normal Text" lineEndContext="#stay">
0134 <DetectChar context="#pop!ValidTag" attribute="Symbol" char=":" />
0135 <IncludeRules context="ConditionalExpressionEnd##TypeScript" />
0136 <IncludeRules context="FindConditionalExpressionBrackets" />
0137 <!-- React -->
0138 <IncludeRules context="NoStartConditionalExpression" />
0139 <IncludeRules context="React" />
0140 <!-- ConditionalExpression##TypeScript -->
0141 <IncludeRules context="Normal-ParametersOverridden##TypeScript" />
0142 </context>
0143 <context name="FindConditionalExpressionBrackets" attribute="Normal Text" lineEndContext="#stay">
0144 <DetectChar context="ConditionalExpressionRoundBracket-BeforeTag" attribute="Normal Text" char="(" />
0145 <DetectChar context="ConditionalExpressionSquareBracket-BeforeTag" attribute="Symbol" char="[" beginRegion="List" />
0146 </context>
0147 <context name="ConditionalExpressionRoundBracket" attribute="Normal Text" lineEndContext="#stay">
0148 <DetectChar context="#pop!NoRegExp" attribute="Normal Text" char=")" />
0149 <IncludeRules context="FindConditionalExpressionBrackets" />
0150 <IncludeRules context="React" />
0151 <IncludeRules context="Normal" />
0152 </context>
0153 <context name="ConditionalExpressionSquareBracket" attribute="Normal Text" lineEndContext="#stay">
0154 <DetectChar context="#pop!NoRegExp" attribute="Symbol" char="]" endRegion="List" />
0155 <IncludeRules context="FindConditionalExpressionBrackets" />
0156 <IncludeRules context="React" />
0157 <IncludeRules context="Normal" />
0158 </context>
0159 <context name="NoStartConditionalExpression" attribute="Normal Text" lineEndContext="#stay">
0160 <RegExpr context="ValidTag" attribute="Symbol" String="\?\s*(?=&tag;|/\*)" />
0161 <DetectChar context="#stay" attribute="Symbol" char="?" />
0162 </context>
0163
0164 <context name="Types" attribute="Normal Text" lineEndContext="#pop">
0165 <IncludeRules context="FixPopLineEndContext##TypeScript" />
0166 <IncludeRules context="TypesCommon" />
0167 </context>
0168 <context name="TypesCommon" attribute="Normal Text" lineEndContext="#pop">
0169 <DetectSpaces />
0170 <IncludeRules context="TypesEnd##TypeScript" />
0171 <RegExpr context="#pop!TypesNewLine" attribute="Symbol" String="[\|&](?=&endLine;)" minimal="true" />
0172 <!-- React -->
0173 <IncludeRules context="TypesFindBrackets" />
0174 <IncludeRules context="NoStartConditionalExpression" />
0175 <IncludeRules context="React" />
0176 <!-- TypesCommon##TypeScript -->
0177 <IncludeRules context="DefaultTypes##TypeScript" />
0178 <IncludeRules context="Normal-ParametersOverridden##TypeScript" />
0179 </context>
0180 <context name="TypesNewLine" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!TypesCommon">
0181 <IncludeRules context="TypesNewLine##TypeScript" />
0182 </context>
0183
0184 <!-- Overwrite TypesFindBrackets##TypeScript (place before "React").
0185 Since there may be tags after "[", "{" or "(". -->
0186 <context name="TypesFindBrackets" attribute="Normal Text" lineEndContext="#stay">
0187 <DetectChar context="TypesSquareBracket-BeforeTag" attribute="Normal Text" char="[" beginRegion="List" />
0188 <DetectChar context="TypesCurlyBracket-BeforeTag" attribute="Normal Text" char="{" beginRegion="Brace" />
0189 <DetectChar context="TypesRoundBracket-BeforeTag" attribute="Normal Text" char="(" />
0190 </context>
0191 <context name="TypesSquareBracket" attribute="Normal Text" lineEndContext="#stay">
0192 <DetectChar context="#pop!NoRegExp" attribute="Normal Text" char="]" endRegion="List" />
0193 <!-- React -->
0194 <IncludeRules context="TypesFindBrackets" />
0195 <IncludeRules context="NoStartConditionalExpression" />
0196 <IncludeRules context="React" />
0197 <!-- TypesSquareBracket##TypeScript -->
0198 <IncludeRules context="DefaultTypes##TypeScript" />
0199 <IncludeRules context="Normal##TypeScript" />
0200 </context>
0201 <context name="TypesCurlyBracket" attribute="Normal Text" lineEndContext="#pop!Object">
0202 <DetectChar context="#pop" attribute="Normal Text" char="}" endRegion="Brace" />
0203 <!-- FixPopLineEndContext##TypeScript -->
0204 <RegExpr context="#pop!Object" String="\S" firstNonSpace="true" lookAhead="true" />
0205 <!-- React -->
0206 <IncludeRules context="TypesFindBrackets" />
0207 <IncludeRules context="NoStartConditionalExpression" />
0208 <IncludeRules context="React" />
0209 <!-- TypesCurlyBracket##TypeScript -->
0210 <IncludeRules context="DefaultTypes##TypeScript" />
0211 <IncludeRules context="Object##TypeScript" />
0212 </context>
0213 <context name="TypesRoundBracket" attribute="Normal Text" lineEndContext="#pop">
0214 <DetectChar context="#pop!NoRegExp" attribute="Normal Text" char=")" />
0215 <IncludeRules context="FixPopLineEndContext##TypeScript" />
0216 <!-- React -->
0217 <IncludeRules context="TypesFindBrackets" />
0218 <IncludeRules context="NoStartConditionalExpression" />
0219 <IncludeRules context="React" />
0220 <!-- TypesRoundBracket##TypeScript -->
0221 <IncludeRules context="DefaultTypes##TypeScript" />
0222 <IncludeRules context="Normal##TypeScript" />
0223 </context>
0224 <context name="TypesAngleBracket" attribute="Normal Text" lineEndContext="#pop">
0225 <RegExpr context="#pop!ValidTag" attribute="Symbol" String=">\s*(?=&tag;|/\*)" />
0226 <DetectChar context="#pop" attribute="Symbol" char=">" />
0227 <IncludeRules context="TypesAngleBracketEnd##TypeScript" />
0228 <IncludeRules context="FixPopLineEndContext##TypeScript" />
0229 <!-- React! -->
0230 <IncludeRules context="TypesFindBrackets" />
0231 <IncludeRules context="NoStartConditionalExpression" />
0232 <IncludeRules context="React" />
0233 <!-- TypesAngleBracket##TypeScript -->
0234 <IncludeRules context="DefaultTypes##TypeScript" />
0235 <IncludeRules context="Normal##TypeScript" />
0236 </context>
0237
0238 <!-- Do not highlight tags in some special contexts -->
0239 <context name="FindDeclarationsWithNoTags" attribute="Normal Text" lineEndContext="#stay">
0240 <WordDetect context="InterfaceDeclaration" attribute="Reserved" String="interface" />
0241 <WordDetect context="ClassDeclaration" attribute="Reserved" String="class" />
0242 <WordDetect context="VarDeclaration" attribute="Reserved" String="let" />
0243 <WordDetect context="VarDeclaration" attribute="Keyword" String="var" />
0244 <WordDetect context="VarDeclaration" attribute="Keyword" String="const" />
0245 </context>
0246 <!-- Do not highlight tags after ":" in variable declarations -->
0247 <context name="VarDeclaration" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop">
0248 <DetectSpaces />
0249 <RegExpr context="#pop!VarDeclTypesNewLine" attribute="Symbol" String=":(?=&endLine;)" minimal="true" />
0250 <DetectChar context="#pop!VarDeclTypes" attribute="Symbol" char=":" />
0251 <RegExpr context="#stay" attribute="Normal Text" String="&identifier;(?=\s*&objectOp;\s*:)" />
0252 <AnyChar context="#stay" attribute="Symbol" String="?!" /> <!-- &objectOp; -->
0253 <IncludeRules context="AllComments" />
0254 </context>
0255 <context name="VarDeclTypes" attribute="Normal Text" lineEndContext="#pop">
0256 <IncludeRules context="Types##TypeScript" />
0257 </context>
0258 <context name="VarDeclTypesNewLine" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!VarDeclTypesCommon">
0259 <DetectSpaces />
0260 <IncludeRules context="AllComments" />
0261 </context>
0262 <context name="VarDeclTypesCommon" attribute="Normal Text" lineEndContext="#pop">
0263 <IncludeRules context="TypesCommon##TypeScript" />
0264 </context>
0265 <!-- Do not highlight tags in interface declarations -->
0266 <context name="InterfaceDeclaration" attribute="Normal Text" lineEndContext="#stay">
0267 <DetectChar context="#pop!InterfaceContentDeclaration" attribute="Normal Text" char="{" beginRegion="Brace" />
0268 <DetectChar context="#pop" char="}" lookAhead="true" />
0269 <IncludeRules context="Normal##TypeScript" />
0270 </context>
0271 <context name="InterfaceContentDeclaration" attribute="Normal Text" lineEndContext="#stay">
0272 <DetectChar context="#pop" attribute="Normal Text" char="}" endRegion="Brace" />
0273 <IncludeRules context="Object##TypeScript" />
0274 </context>
0275 <!-- Do not highlight tags in class declarations -->
0276 <context name="ClassDeclaration" attribute="Normal Text" lineEndContext="#stay">
0277 <DetectChar context="#pop!ClassDeclarationContent" attribute="Normal Text" char="{" beginRegion="Brace" />
0278 <DetectChar context="#pop" char="}" lookAhead="true" />
0279 <IncludeRules context="Normal##TypeScript" />
0280 </context>
0281 <context name="ClassDeclarationContent" attribute="Normal Text" lineEndContext="#stay">
0282 <DetectChar context="#pop" attribute="Normal Text" char="}" endRegion="Brace" />
0283 <RegExpr context="VarDeclTypesNewLine" attribute="Symbol" String=":(?=&endLine;)" minimal="true" />
0284 <DetectChar context="VarDeclTypes" attribute="Symbol" char=":" />
0285 <IncludeRules context="Object" />
0286 </context>
0287
0288 <!-- ReactJS -->
0289
0290 <!-- Tags highlighting -->
0291 <context name="React" attribute="Normal Text" lineEndContext="#stay">
0292 <!-- Tag in new line -->
0293 <RegExpr context="ValidTag" attribute="Normal Text" String="&tag;" firstNonSpace="true" lookAhead="true" />
0294 <!-- Highlight tags only after some keywords -->
0295 <RegExpr context="ValidTag" attribute="ControlFlow" String="\b(?:return|await)\s*(?=&tag;|/\*)" />
0296 <RegExpr context="ValidTag" attribute="Module" String="\b(?:default)\s*(?=&tag;|/\*)" />
0297 <RegExpr context="ValidTag" attribute="Reserved" String="\b(?:yield)\s*(?=&tag;|/\*)" />
0298
0299 <!-- Characters before a valid tag -->
0300 <RegExpr context="ValidTag" attribute="Special Operators" String="\=>\s*(?=&tag;|/\*)" />
0301 <RegExpr context="ValidTag" attribute="Symbol" String="(?:[,\=>\*]|&&|\|\||\?\?)\s*(?=&tag;|/\*)" />
0302 <RegExpr context="ValidTag" attribute="Normal Text" String="\[\s*(?=&tag;|/\*)" beginRegion="List" />
0303 <RegExpr context="ValidTag" attribute="Normal Text" String="\(\s*(?=&tag;|/\*)" />
0304 <!-- The "Object-BeforeTag" context looks for a valid Tag and then sends the "Object" context -->
0305 <RegExpr context="Object-BeforeTag" attribute="Normal Text" String="\{\s*(?=&tag;|/\*)" beginRegion="Brace" />
0306 <RegExpr context="Types-BeforeTag" attribute="Symbol" String=":\s*(?=&tag;|/\*)" />
0307
0308 <RegExpr context="ConditionalExpression-BeforeTag" attribute="Symbol" String="&conditionalExpression;" minimal="true" />
0309 <RegExpr context="ValidTag" attribute="Symbol" String="\?\s*(?=&tag;|/\*)|<\s*>\s*(?=&tag;|/\*)" />
0310
0311 <!-- Tag after a comment on a new line -->
0312 <Detect2Chars context="ValidTag" attribute="Comment" char="/" char1="*" firstNonSpace="true" lookAhead="true" />
0313
0314 <!-- Overwrite TypeScript rules to highlight tags within some contexts -->
0315 <IncludeRules context="FindDeclarationsWithNoTags" />
0316 <IncludeRules context="OverwriteTypeScript" />
0317 </context>
0318
0319 <!-- Detect tags before starting a context -->
0320 <context name="Object-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!Object">
0321 <IncludeRules context="ValidTag" />
0322 </context>
0323 <context name="Substitution-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!Substitution">
0324 <IncludeRules context="ValidTag" />
0325 </context>
0326 <context name="EvaluatedCode-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!EvaluatedCode">
0327 <IncludeRules context="ValidTag" />
0328 </context>
0329
0330 <context name="Types-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!Types">
0331 <Detect2Chars context="#pop" attribute="Comment" char="/" char1="/" lookAhead="true" />
0332 <IncludeRules context="ValidTag" />
0333 </context>
0334 <context name="TypesSquareBracket-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!TypesSquareBracket">
0335 <IncludeRules context="ValidTag" />
0336 </context>
0337 <context name="TypesCurlyBracket-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!TypesCurlyBracket">
0338 <Detect2Chars context="#pop!Object" attribute="Comment" char="/" char1="/" lookAhead="true" />
0339 <IncludeRules context="ValidTag" />
0340 </context>
0341 <context name="TypesRoundBracket-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!TypesRoundBracket">
0342 <Detect2Chars context="#pop" attribute="Comment" char="/" char1="/" lookAhead="true" />
0343 <IncludeRules context="ValidTag" />
0344 </context>
0345
0346 <context name="ConditionalExpression-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!ConditionalExpression">
0347 <IncludeRules context="ValidTag" />
0348 </context>
0349 <context name="ConditionalExpressionRoundBracket-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!ConditionalExpressionRoundBracket">
0350 <IncludeRules context="ValidTag" />
0351 </context>
0352 <context name="ConditionalExpressionSquareBracket-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!ConditionalExpressionSquareBracket">
0353 <IncludeRules context="ValidTag" />
0354 </context>
0355
0356 <!-- TAGS:
0357 NOTE & TODO: The following code is common for 'javascript-react.xml' and 'typescript-react.xml'
0358 and is replicated in both files. Look for some way to avoid having repeated code, for example,
0359 with a common XML file or with a generator script. The only drawback is that the
0360 "EvaluatedCode" context includes "Normal". -->
0361
0362 <!-- Highlight nested tags with comments in between.
0363 NOTE: The highlighting of Tags after a multiline comment does not work with: lineEndContext="#pop" -->
0364 <context name="ValidTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop">
0365 <RegExpr context="#stay" attribute="Normal Text" String="\s+(?=<|/\*)" />
0366 <IncludeRules context="FindTags" />
0367 <IncludeRules context="AllComments" />
0368 </context>
0369
0370 <!-- Start tag.
0371 There are two contexts to find Tags:
0372 * FindTags: For Tags within TypeScript code; invalid name tags aren't highlighted.
0373 * FindTagsInTagContent: For Tag within another tag; highlight any Tag.
0374 Tags with invalid names are highlighted as "Error".
0375 -->
0376 <context name="FindTags" attribute="Normal Text" lineEndContext="#stay">
0377 <RegExpr context="#pop!TypesAngleBracket" attribute="Symbol" String="&typesAngleBracket1;|&typesAngleBracket2;" />
0378 <!-- Empty tag (element) -->
0379 <RegExpr context="ElementTagContent" attribute="Element Tag" String="<\s*>" beginRegion="Element" />
0380 <!-- Detect Tags -->
0381 <RegExpr context="ElementTagFindType" attribute="Element Tag" String="&simpleTag;(?=&endTagName;)" beginRegion="Element" />
0382 <RegExpr context="ComponentTagFindType" attribute="Component Tag" String="&tag;(?=&endTagName;)" beginRegion="ComponentElement" />
0383 <!-- If a valid Tag was not detected -->
0384 <DetectChar context="#pop!TypesAngleBracket" attribute="Symbol" char="<" />
0385 </context>
0386
0387 <context name="FindTagsInTagContent" attribute="Normal Text" lineEndContext="#stay">
0388 <!-- Empty tag (element) -->
0389 <RegExpr context="ElementTagContent" attribute="Element Tag" String="<\s*>" beginRegion="Element" />
0390 <!-- Detect non-ASCII character in the tag name (component). This prevents highlighting as Element,
0391 tag names that don't start with a non-ASCII character. -->
0392 <RegExpr context="ComponentTagNonASCII" attribute="Component Tag" String="<\s*(?=(?:[a-z][a-z\d]*:)?(?:[a-z][a-z\d]*)?[^[:ascii:]])" beginRegion="ComponentElement" /> <!-- &simpleName; -->
0393 <!-- Element & component tags -->
0394 <RegExpr context="ElementTagFindType" attribute="Element Tag" String="&simpleTag;(?=[^\w\$\-\.:]|$|[\-\.]+(?:[^\w\$\-\.]|$)|:(?:[^a-zA-Z_\$]|$))" beginRegion="Element" />
0395 <RegExpr context="ComponentTagFindType" attribute="Component Tag" String="&tag;" beginRegion="ComponentElement" />
0396 </context>
0397 <!-- Highlight tag name with non-ASCII characters -->
0398 <context name="ComponentTagNonASCII" attribute="Normal Text" lineEndContext="#pop!ComponentTag" fallthrough="true" fallthroughContext="#pop!ComponentTag">
0399 <RegExpr context="#pop!ComponentTagFindType" attribute="Component Tag" String="&name;" />
0400 </context>
0401
0402 <context name="FindEntityRefs" attribute="Normal Text" lineEndContext="#stay">
0403 <RegExpr context="#stay" attribute="EntityRef" String="&entref;" />
0404 </context>
0405
0406 <!-- Type after the tag name. Ex: <C<number> /> -->
0407 <context name="ComponentTagFindType" attribute="Normal Text" lineEndContext="#pop!ComponentTag" fallthrough="true" fallthroughContext="#pop!ComponentTag">
0408 <DetectChar context="#pop!TypeInsideTag" attribute="Symbol" char="<" />
0409 </context>
0410 <context name="ElementTagFindType" attribute="Normal Text" lineEndContext="#pop!ElementTag" fallthrough="true" fallthroughContext="#pop!ElementTag">
0411 <DetectChar context="#pop!TypeInsideTag" attribute="Symbol" char="<" />
0412 </context>
0413
0414 <!-- Type assertion after the tag name -->
0415 <context name="TypeInsideTag" attribute="Component Tag" lineEndContext="#stay">
0416 <DetectChar context="#pop!ComponentTag" attribute="Symbol" char=">" />
0417 <IncludeRules context="DefaultTypeInsideTag" />
0418 </context>
0419 <context name="DefaultTypeInsideTag" attribute="Component Tag" lineEndContext="#stay">
0420 <DetectChar context="TypeInsideTag-AngleBracket" attribute="Symbol" char="<" />
0421 <DetectChar context="TypeInsideTag-CurlyBracket" attribute="Symbol" char="{" />
0422 <DetectChar context="TypeInsideTag-SquareBracket" attribute="Symbol" char="[" />
0423 <DetectChar context="TypeInsideTag-RoundBracket" attribute="Symbol" char="(" />
0424 <IncludeRules context="AllComments" />
0425 </context>
0426 <context name="TypeInsideTag-AngleBracket" attribute="Component Tag" lineEndContext="#stay">
0427 <DetectChar context="#pop" attribute="Symbol" char=">" />
0428 <IncludeRules context="DefaultTypeInsideTag" />
0429 </context>
0430 <context name="TypeInsideTag-CurlyBracket" attribute="Component Tag" lineEndContext="#stay">
0431 <DetectChar context="#pop" attribute="Symbol" char="}" />
0432 <IncludeRules context="DefaultTypeInsideTag" />
0433 </context>
0434 <context name="TypeInsideTag-SquareBracket" attribute="Component Tag" lineEndContext="#stay">
0435 <DetectChar context="#pop!NoRegExp" attribute="Symbol" char="]" />
0436 <IncludeRules context="DefaultTypeInsideTag" />
0437 </context>
0438 <context name="TypeInsideTag-RoundBracket" attribute="Component Tag" lineEndContext="#stay">
0439 <DetectChar context="#pop!NoRegExp" attribute="Symbol" char=")" />
0440 <IncludeRules context="DefaultTypeInsideTag" />
0441 </context>
0442
0443 <!-- Inside the tag -->
0444 <context name="ElementTag" attribute="Normal Text" lineEndContext="#stay">
0445 <Detect2Chars context="#pop" attribute="Element Tag" char="/" char1=">" endRegion="Element" />
0446 <DetectChar context="#pop!ElementTagContent" attribute="Element Tag" char=">" />
0447 <IncludeRules context="DefaultTag" />
0448 </context>
0449 <context name="ComponentTag" attribute="Normal Text" lineEndContext="#stay">
0450 <Detect2Chars context="#pop" attribute="Component Tag" char="/" char1=">" endRegion="ComponentElement" />
0451 <DetectChar context="#pop!ComponentTagContent" attribute="Component Tag" char=">" />
0452 <IncludeRules context="DefaultTag" />
0453 </context>
0454 <context name="DefaultTag" attribute="Normal Text" lineEndContext="#stay">
0455 <RegExpr context="Attribute" attribute="Attribute" String="&nameWithBound;" />
0456 <IncludeRules context="FindEvaluatedCode" />
0457 <IncludeRules context="AllComments" />
0458 <RegExpr context="#stay" attribute="Error" String="\S+&name;|\S" />
0459 </context>
0460
0461 <!-- Tag content: <Tag> content </Tag> -->
0462 <context name="ElementTagContent" attribute="Tag Content Text" lineEndContext="#stay">
0463 <RegExpr context="#pop" attribute="Element Tag" String="</\s*>" endRegion="Element" />
0464 <!-- With component tag (error) -->
0465 <RegExpr context="ElementTagEnd" attribute="Element Tag" String="</\s*&simpleName;|</\s*(?=[A-Z_\$])" />
0466 <IncludeRules context="DefaultTagContent" />
0467 </context>
0468 <context name="ComponentTagContent" attribute="Tag Content Text" lineEndContext="#stay">
0469 <RegExpr context="#pop" attribute="Component Tag" String="</\s*>" endRegion="ComponentElement" />
0470 <RegExpr context="ComponentTagEnd" attribute="Component Tag" String="</\s*&name;" />
0471 <IncludeRules context="DefaultTagContent" />
0472 </context>
0473 <context name="DefaultTagContent" attribute="Tag Content Text" lineEndContext="#stay">
0474 <IncludeRules context="FindTagsInTagContent" />
0475 <IncludeRules context="FindEntityRefs" />
0476 <IncludeRules context="FindEvaluatedCode" />
0477 <DetectChar context="#stay" attribute="Error" char="<" />
0478 </context>
0479
0480 <context name="ElementTagEnd" attribute="Normal Text" lineEndContext="#stay">
0481 <DetectChar context="#pop#pop" attribute="Element Tag" char=">" endRegion="Element" />
0482 <RegExpr context="#stay" attribute="Error" String="\S" />
0483 </context>
0484 <context name="ComponentTagEnd" attribute="Normal Text" lineEndContext="#stay">
0485 <DetectChar context="#pop#pop" attribute="Component Tag" char=">" endRegion="ComponentElement" />
0486 <RegExpr context="#stay" attribute="Error" String="\S" />
0487 </context>
0488
0489 <!-- Tag attribute -->
0490 <context name="Attribute" attribute="Normal Text" lineEndContext="#stay">
0491 <RegExpr context="#pop" attribute="Error" String="\=(?=\s*/?>)" />
0492 <DetectChar context="#pop!Value" attribute="Symbol" char="=" />
0493 <IncludeRules context="FindEndTag" />
0494 <DetectChar context="#pop" char="{" lookAhead="true" /> <!-- EvaluatedCode -->
0495 <IncludeRules context="AllComments" />
0496 <RegExpr context="#stay" attribute="Attribute" String="&nameWithBound;" />
0497 <RegExpr context="#stay" attribute="Error" String="\S+&name;|\S" />
0498 </context>
0499
0500 <context name="Value" attribute="Normal Text" lineEndContext="#stay">
0501 <DetectChar context="#pop!ValueDQ" attribute="Value" char=""" />
0502 <DetectChar context="#pop!ValueSQ" attribute="Value" char="'" />
0503 <DetectChar context="#pop" char="{" lookAhead="true" /> <!-- EvaluatedCode -->
0504 <IncludeRules context="FindEndTag" />
0505 <IncludeRules context="AllComments" />
0506 <RegExpr context="#stay" attribute="Error" String="\S" />
0507 </context>
0508 <context name="ValueDQ" attribute="Value" lineEndContext="#stay">
0509 <DetectChar context="#pop" attribute="Value" char=""" />
0510 <IncludeRules context="FindEntityRefs" />
0511 </context>
0512 <context name="ValueSQ" attribute="Value" lineEndContext="#stay">
0513 <DetectChar context="#pop" attribute="Value" char="'" />
0514 <IncludeRules context="FindEntityRefs" />
0515 </context>
0516
0517 <context name="FindEndTag" attribute="Normal Text" lineEndContext="#stay">
0518 <Detect2Chars context="#pop" char="/" char1=">" lookAhead="true" />
0519 <DetectChar context="#pop" char=">" lookAhead="true" />
0520 </context>
0521
0522 <context name="FindEvaluatedCode" attribute="Normal Text" lineEndContext="#stay">
0523 <!-- Find tags and send to the "EvaluatedCode" context -->
0524 <DetectChar context="EvaluatedCode-BeforeTag" attribute="Code Brackets" char="{" beginRegion="Code" />
0525 </context>
0526 <context name="EvaluatedCode" attribute="Normal Text" lineEndContext="#stay">
0527 <DetectChar context="#pop" attribute="Code Brackets" char="}" endRegion="Code" />
0528 <IncludeRules context="Normal" />
0529 </context>
0530
0531 <context name="AllComments" attribute="Normal Text" lineEndContext="#stay">
0532 <!-- TypeScript uses this for comments -->
0533 <IncludeRules context="FindComments##JavaScript" />
0534 </context>
0535
0536 </contexts>
0537
0538 <itemDatas>
0539 <itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false" />
0540 <itemData name="Comment" defStyleNum="dsComment" />
0541
0542 <itemData name="Tag Content Text" defStyleNum="dsNormal" />
0543 <itemData name="Element Tag" defStyleNum="dsKeyword" spellChecking="false" />
0544 <itemData name="Component Tag" defStyleNum="dsFunction" bold="1" spellChecking="false" />
0545 <itemData name="Attribute" defStyleNum="dsOthers" spellChecking="false" />
0546 <itemData name="Value" defStyleNum="dsString" spellChecking="false" />
0547 <itemData name="EntityRef" defStyleNum="dsDecVal" spellChecking="false" />
0548 <itemData name="Code Brackets" defStyleNum="dsVariable" spellChecking="false" />
0549 <itemData name="Error" defStyleNum="dsError" spellChecking="false" />
0550
0551 <!-- itemDatas in TypeScript XML file -->
0552 <itemData name="Symbol" defStyleNum="dsOperator" />
0553 <itemData name="ControlFlow" defStyleNum="dsControlFlow" spellChecking="false" />
0554 <itemData name="Reserved" defStyleNum="dsKeyword" italic="true" spellChecking="false" />
0555 <itemData name="Keyword" defStyleNum="dsKeyword" spellChecking="false" />
0556 <itemData name="Module" defStyleNum="dsImport" spellChecking="false" />
0557 <itemData name="Template" defStyleNum="dsVerbatimString" />
0558 <itemData name="Substitution" defStyleNum="dsSpecialChar" spellChecking="false" />
0559 <itemData name="Special Operators" defStyleNum="dsKeyword" spellChecking="false" />
0560 </itemDatas>
0561
0562 </highlighting>
0563
0564 <general>
0565 <keywords casesensitive="1" />
0566 <comments>
0567 <comment name="singleLine" start="//" />
0568 <comment name="multiLine" start="/*" end="*/" />
0569 </comments>
0570 </general>
0571
0572 </language>
0573 <!-- kate: replace-tabs off; tab-width 3; indent-width 3; remove-trailing-spaces mod; dynamic-word-wrap off; -->