Changeset View
Changeset View
Standalone View
Standalone View
data/syntax/javascript-react.xml
- This file was copied to data/syntax/typescript-react.xml.
Show All 17 Lines | 12 | ==================================================================== | |||
---|---|---|---|---|---|
18 | This Source Code Form is subject to the terms of the MIT License. | 18 | 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, | 19 | If a copy of the license was not distributed with this file, | ||
20 | You can obtain one at: https://opensource.org/licenses/MIT | 20 | You can obtain one at: https://opensource.org/licenses/MIT | ||
21 | 21 | | |||
22 | ==================================================================== | 22 | ==================================================================== | ||
23 | 23 | | |||
24 | This file is an extension of the JavaScript highlighter | 24 | This file is an extension of the JavaScript highlighter | ||
25 | (javascript.xml). | 25 | (javascript.xml). | ||
26 | IMPORTANT: Keep sync with "typescript-react.xml". | ||||
27 | | ||||
26 | Based on the XML syntax highlighting (v7), by Wilbert Berendsen | 28 | Based on the XML syntax highlighting (v7), by Wilbert Berendsen | ||
27 | (wilbert@kde.nl), and the TypeScript React grammar files, | 29 | (wilbert@kde.nl), and the TypeScript React grammar files, | ||
28 | available at: https://github.com/Microsoft/TypeScript-TmLanguage | 30 | available at: https://github.com/Microsoft/TypeScript-TmLanguage | ||
29 | 31 | | |||
30 | Change log: | 32 | Change log: | ||
33 | * v3 [2018-11-18]: Fix Doxygen comments & shebang. Remove TS extension. | ||||
31 | * v2 [2018-08-18]: Remove "Conditional Expression" context. | 34 | * v2 [2018-08-18]: Remove "Conditional Expression" context. | ||
32 | * v1 [2018-06-20]: Initial version | 35 | * v1 [2018-06-20]: Initial version | ||
33 | --> | 36 | --> | ||
34 | 37 | | |||
35 | <!-- NOTE: TSX extension of TypeScript React is included --> | 38 | <language name="JavaScript React" version="3" kateversion="5.0" section="Scripts" indenter="cstyle" | ||
36 | <language name="JavaScript React" version="2" kateversion="5.0" section="Scripts" indenter="cstyle" | 39 | priority="8" extensions="*.jsx" mimetype="text/jsx;text/x-jsx;application/jsx;application/x-jsx;" | ||
37 | priority="6" extensions="*.jsx;*.tsx" mimetype="text/jsx;text/x-jsx;application/jsx;application/x-jsx;" | | |||
38 | author="Nibaldo González (nibgonz@gmail.com)" license="MIT"> | 40 | author="Nibaldo González (nibgonz@gmail.com)" license="MIT"> | ||
39 | 41 | | |||
40 | <highlighting> | 42 | <highlighting> | ||
41 | 43 | | |||
42 | <contexts> | 44 | <contexts> | ||
43 | 45 | | |||
44 | <context name="Shebang" attribute="Normal Text" lineEndContext="#pop!Normal" fallthrough="true" fallthroughContext="#pop!Normal"> | 46 | <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" /> | 47 | <Detect2Chars context="ShebangLine" attribute="Comment" char="#" char1="!" column="0" /> | ||
46 | </context> | 48 | </context> | ||
47 | <context name="ShebangLine" attribute="Comment" lineEndContext="#pop#pop!Normal" /> | 49 | <context name="ShebangLine" attribute="Comment" lineEndContext="#pop#pop!Normal" /> | ||
48 | 50 | | |||
49 | <context name="Normal" attribute="Normal Text" lineEndContext="#stay"> | 51 | <context name="Normal" attribute="Normal Text" lineEndContext="#stay"> | ||
50 | <IncludeRules context="React" /> | 52 | <IncludeRules context="React" /> | ||
51 | <IncludeRules context="Normal##JavaScript" /> | 53 | <IncludeRules context="Normal##JavaScript" /> | ||
52 | </context> | 54 | </context> | ||
53 | 55 | | |||
54 | <!-- JavaScript --> | 56 | <!-- JavaScript --> | ||
55 | 57 | | |||
56 | <!-- NOTE: Keep synchronized with 'javascript.xml'! | 58 | <!-- Overwrite rules of 'javascript.xml'. These rules send to contexts | ||
57 | Overwrite rules of 'javascript.xml'. These rules send to contexts | | |||
58 | that contain: <IncludeRules context="Normal"/> in the JavaScript XML file. --> | 59 | that contain: <IncludeRules context="Normal"/> in the JavaScript XML file. --> | ||
59 | <context name="OverwriteJavascript" attribute="Normal Text" lineEndContext="#stay"> | 60 | <context name="OverwriteJavaScript" attribute="Normal Text" lineEndContext="#stay"> | ||
60 | <DetectChar context="Template" attribute="Template" char="`" /> | 61 | <DetectChar context="Template" attribute="Template" char="`" /> | ||
61 | <DetectChar context="Object" attribute="Symbol" char="{" beginRegion="Brace" /> | 62 | <DetectChar context="Object" attribute="Symbol" char="{" beginRegion="Brace" /> | ||
62 | <DetectChar context="#stay" attribute="Symbol" char="?" /> | 63 | <DetectChar context="#stay" attribute="Symbol" char="?" /> | ||
63 | </context> | 64 | </context> | ||
64 | <context name="Object" attribute="Normal Text" lineEndContext="#stay"> | 65 | <context name="Object" attribute="Normal Text" lineEndContext="#stay"> | ||
65 | <IncludeRules context="React" /> | | |||
66 | <DetectChar context="#pop" attribute="Symbol" char="}" endRegion="Brace" /> | 66 | <DetectChar context="#pop" attribute="Symbol" char="}" endRegion="Brace" /> | ||
67 | <IncludeRules context="React" /> | ||||
67 | <IncludeRules context="Object##JavaScript" /> | 68 | <IncludeRules context="Object##JavaScript" /> | ||
68 | </context> | 69 | </context> | ||
69 | <context name="Template" attribute="Template" lineEndContext="#stay"> | 70 | <context name="Template" attribute="Template" lineEndContext="#stay"> | ||
70 | <DetectChar context="#pop" attribute="Template" char="`" /> | 71 | <DetectChar context="#pop" attribute="Template" char="`" /> | ||
71 | <Detect2Chars context="Substitution" attribute="Substitution" char="$" char1="{" /> | 72 | <Detect2Chars context="Substitution" attribute="Substitution" char="$" char1="{" /> | ||
72 | <IncludeRules context="Template##JavaScript" /> | 73 | <IncludeRules context="Template##JavaScript" /> | ||
73 | </context> | 74 | </context> | ||
74 | <context name="Substitution" attribute="Normal Text" lineEndContext="#stay"> | 75 | <context name="Substitution" attribute="Normal Text" lineEndContext="#stay"> | ||
75 | <IncludeRules context="React" /> | | |||
76 | <DetectChar context="#pop" attribute="Substitution" char="}" /> | 76 | <DetectChar context="#pop" attribute="Substitution" char="}" /> | ||
77 | <IncludeRules context="React" /> | ||||
77 | <IncludeRules context="Substitution##JavaScript" /> | 78 | <IncludeRules context="Substitution##JavaScript" /> | ||
78 | </context> | 79 | </context> | ||
79 | 80 | | |||
80 | <!-- ReactJS --> | 81 | <!-- ReactJS --> | ||
81 | 82 | | |||
83 | <!-- Tags highlighting --> | ||||
82 | <context name="React" attribute="Normal Text" lineEndContext="#stay"> | 84 | <context name="React" attribute="Normal Text" lineEndContext="#stay"> | ||
83 | <!-- Characters before a valid tag. Keep synchronized with 'javascript.xml'! --> | 85 | <!-- Tag in new line --> | ||
84 | <RegExpr context="ValidTag" attribute="Normal Text" String="&tag;" firstNonSpace="true" lookAhead="true" /> | 86 | <RegExpr context="ValidTag" attribute="Normal Text" String="&tag;" firstNonSpace="true" lookAhead="true" /> | ||
87 | <!-- Highlight tags only after some keywords --> | ||||
85 | <RegExpr context="ValidTag" attribute="ControlFlow" String="\b(return)\s*(?=&tag;|/\*)" /> | 88 | <RegExpr context="ValidTag" attribute="ControlFlow" String="\b(return)\s*(?=&tag;|/\*)" /> | ||
86 | <RegExpr context="ValidTag" attribute="Module" String="\b(default)\s*(?=&tag;|/\*)" /> | 89 | <RegExpr context="ValidTag" attribute="Module" String="\b(default)\s*(?=&tag;|/\*)" /> | ||
90 | | ||||
91 | <!-- Characters before a valid tag --> | ||||
87 | <RegExpr context="ValidTag" attribute="Symbol" String="([,\=>:\*\?]|&&|\|\|)\s*(?=&tag;|/\*)" /> | 92 | <RegExpr context="ValidTag" attribute="Symbol" String="([,\=>:\*\?]|&&|\|\|)\s*(?=&tag;|/\*)" /> | ||
88 | <RegExpr context="ValidTag" attribute="Normal Text" String="[\(\[]\s*(?=&tag;|/\*)" /> | 93 | <RegExpr context="ValidTag" attribute="Normal Text" String="[\(\[]\s*(?=&tag;|/\*)" /> | ||
89 | | ||||
90 | <!-- The "Object-BeforeTag" context looks for a valid Tag and then sends the "Object" context --> | 94 | <!-- The "Object-BeforeTag" context looks for a valid Tag and then sends the "Object" context --> | ||
91 | <RegExpr context="Object-BeforeTag" attribute="Symbol" String="\{\s*(?=&tag;|/\*)" beginRegion="Brace" /> | 95 | <RegExpr context="Object-BeforeTag" attribute="Symbol" String="\{\s*(?=&tag;|/\*)" beginRegion="Brace" /> | ||
96 | | ||||
97 | <!-- Tag after a comment on a new line --> | ||||
92 | <Detect2Chars context="ValidTag" attribute="Comment" char="/" char1="*" firstNonSpace="true" lookAhead="true" /> | 98 | <Detect2Chars context="ValidTag" attribute="Comment" char="/" char1="*" firstNonSpace="true" lookAhead="true" /> | ||
93 | 99 | | |||
94 | <IncludeRules context="OverwriteJavascript" /> | 100 | <!-- Overwrite JavaScript rules to highlight tags within some contexts --> | ||
95 | <IncludeRules context="AllComments" /> | 101 | <IncludeRules context="OverwriteJavaScript" /> | ||
96 | </context> | 102 | </context> | ||
97 | 103 | | |||
98 | <!-- NOTE: The highlighting of Tags after a multiline comment does not work with: lineEndContext="#pop" --> | 104 | <!-- Highlight nested tags with comments in between. | ||
105 | NOTE: The highlighting of Tags after a multiline comment does not work with: lineEndContext="#pop" --> | ||||
99 | <context name="ValidTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop"> | 106 | <context name="ValidTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop"> | ||
100 | <RegExpr context="#stay" attribute="Normal Text" String="\s+(?=<|/\*)" /> | 107 | <RegExpr context="#stay" attribute="Normal Text" String="\s+(?=<|/\*)" /> | ||
101 | <IncludeRules context="FindTags" /> | 108 | <IncludeRules context="FindTags" /> | ||
102 | <Detect2Chars context="MultiInlineComment" attribute="Comment" char="/" char1="*" beginRegion="Comment" /> | 109 | <!-- Doxygen & Multi-line comments! --> | ||
110 | <Detect2Chars context="#pop" attribute="Comment" char="/" char1="/" lookAhead="true" /> | ||||
111 | <IncludeRules context="AllComments" /> | ||||
103 | </context> | 112 | </context> | ||
104 | <context name="Object-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!Object"> | 113 | <context name="Object-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!Object"> | ||
105 | <IncludeRules context="ValidTag" /> | 114 | <IncludeRules context="ValidTag" /> | ||
106 | </context> | 115 | </context> | ||
107 | <context name="EvaluatedCode-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!EvaluatedCode"> | 116 | <context name="EvaluatedCode-BeforeTag" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop!EvaluatedCode"> | ||
108 | <IncludeRules context="ValidTag" /> | 117 | <IncludeRules context="ValidTag" /> | ||
109 | </context> | 118 | </context> | ||
110 | 119 | | |||
120 | <!-- Start tag --> | ||||
111 | <context name="FindTags" attribute="Normal Text" lineEndContext="#stay"> | 121 | <context name="FindTags" attribute="Normal Text" lineEndContext="#stay"> | ||
112 | <RegExpr context="ElementTag" attribute="Element Tag" String="&simpleTag;(?=[^\w\$\-\.:]|$|[\-\.]+([^\w\$\-\.]|$)|:([^a-zA-Z_\$]|$))" beginRegion="Element" /> | 122 | <RegExpr context="ElementTag" attribute="Element Tag" String="&simpleTag;(?=[^\w\$\-\.:]|$|[\-\.]+([^\w\$\-\.]|$)|:([^a-zA-Z_\$]|$))" beginRegion="Element" /> | ||
113 | <RegExpr context="ComponentTag" attribute="Component Tag" String="&tag;" beginRegion="ComponentElement" /> | 123 | <RegExpr context="ComponentTag" attribute="Component Tag" String="&tag;" beginRegion="ComponentElement" /> | ||
114 | </context> | 124 | </context> | ||
115 | <context name="FindEntityRefs" attribute="Normal Text" lineEndContext="#stay"> | 125 | <context name="FindEntityRefs" attribute="Normal Text" lineEndContext="#stay"> | ||
116 | <RegExpr context="#stay" attribute="EntityRef" String="&entref;" /> | 126 | <RegExpr context="#stay" attribute="EntityRef" String="&entref;" /> | ||
117 | </context> | 127 | </context> | ||
118 | 128 | | |||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 194 | <context name="ValueSQ" attribute="Value" lineEndContext="#stay"> | |||
186 | <IncludeRules context="FindEntityRefs" /> | 196 | <IncludeRules context="FindEntityRefs" /> | ||
187 | </context> | 197 | </context> | ||
188 | <context name="EvaluatedCode" attribute="Normal Text" lineEndContext="#stay"> | 198 | <context name="EvaluatedCode" attribute="Normal Text" lineEndContext="#stay"> | ||
189 | <DetectChar context="#pop" attribute="Code Brackets" char="}" endRegion="Code" /> | 199 | <DetectChar context="#pop" attribute="Code Brackets" char="}" endRegion="Code" /> | ||
190 | <IncludeRules context="Normal" /> | 200 | <IncludeRules context="Normal" /> | ||
191 | </context> | 201 | </context> | ||
192 | 202 | | |||
193 | <context name="AllComments" attribute="Normal Text" lineEndContext="#stay"> | 203 | <context name="AllComments" attribute="Normal Text" lineEndContext="#stay"> | ||
194 | <Detect2Chars context="SingleLineComment" attribute="Comment" char="/" char1="/" /> | 204 | <IncludeRules context="FindComments##JavaScript" /> | ||
195 | <Detect2Chars context="MultiInlineComment" attribute="Comment" char="/" char1="*" beginRegion="Comment" /> | | |||
196 | </context> | | |||
197 | <context name="SingleLineComment" attribute="Comment" lineEndContext="#pop"> | | |||
198 | <IncludeRules context="##Alerts" /> | | |||
199 | <IncludeRules context="##Modelines" /> | | |||
200 | <RegExpr context="SingleLineCommentURL" attribute="Comment URL" String="\bhttps?://(?=[^\s<>"'`])" /> | | |||
201 | <IncludeRules context="DefaultComment" /> | | |||
202 | </context> | | |||
203 | <context name="MultiInlineComment" attribute="Comment" lineEndContext="#stay"> | | |||
204 | <Detect2Chars context="#pop" attribute="Comment" char="*" char1="/" endRegion="Comment" /> | | |||
205 | <IncludeRules context="##Alerts" /> | | |||
206 | <IncludeRules context="##Modelines" /> | | |||
207 | <RegExpr context="MultiInlineCommentURL" attribute="Comment URL" String="\bhttps?://(?=[^\s<>"'`])" /> | | |||
208 | <IncludeRules context="DefaultComment" /> | | |||
209 | </context> | | |||
210 | <context name="DefaultComment" attribute="Comment" lineEndContext="#stay"> | | |||
211 | <RegExpr context="#stay" attribute="Comment URL" String="(([^<>\(\)\[\]\\\.,;:\s@"]+(\.[^<>\(\)\[\]\\\.,;:\s@"]+)*)|("[^"]+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}])|(([a-zA-Z\-\d]+\.)+[a-zA-Z]{2,}))\b" /> <!-- Detect e-mail (Source: http://emailregex.com) --> | | |||
212 | </context> | | |||
213 | <context name="SingleLineCommentURL" attribute="Comment URL" lineEndContext="#pop#pop"> | | |||
214 | <DetectSpaces context="#pop" attribute="Comment" lookAhead="true" /> | | |||
215 | <AnyChar context="#pop" attribute="Comment" String="<>"'`" lookAhead="true" /> | | |||
216 | <RegExpr context="#pop" attribute="Comment" String="[\}\)\]\.,;\|]+([\s<>"'`]|$)" lookAhead="true" /> | | |||
217 | </context> | | |||
218 | <context name="MultiInlineCommentURL" attribute="Comment URL" lineEndContext="#pop"> | | |||
219 | <Detect2Chars context="#pop" attribute="Comment" char="*" char1="/" lookAhead="true" /> | | |||
220 | <RegExpr context="#pop" attribute="Comment" String="[\}\)\]\.,;\|]+\*/" lookAhead="true" /> | | |||
221 | <IncludeRules context="SingleLineCommentURL" /> | | |||
222 | </context> | 205 | </context> | ||
223 | 206 | | |||
224 | </contexts> | 207 | </contexts> | ||
225 | 208 | | |||
226 | <itemDatas> | 209 | <itemDatas> | ||
227 | <itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false" /> | 210 | <itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false" /> | ||
228 | <itemData name="Comment" defStyleNum="dsComment" /> | 211 | <itemData name="Comment" defStyleNum="dsComment" /> | ||
229 | 212 | | |||
230 | <itemData name="Tag Content Text" defStyleNum="dsNormal" /> | 213 | <itemData name="Tag Content Text" defStyleNum="dsNormal" /> | ||
231 | <itemData name="Element Tag" defStyleNum="dsKeyword" spellChecking="false" /> | 214 | <itemData name="Element Tag" defStyleNum="dsKeyword" spellChecking="false" /> | ||
232 | <itemData name="Component Tag" defStyleNum="dsFunction" bold="1" spellChecking="false" /> | 215 | <itemData name="Component Tag" defStyleNum="dsFunction" bold="1" spellChecking="false" /> | ||
233 | <itemData name="Attribute" defStyleNum="dsOthers" spellChecking="false" /> | 216 | <itemData name="Attribute" defStyleNum="dsOthers" spellChecking="false" /> | ||
234 | <itemData name="Value" defStyleNum="dsString" spellChecking="false" /> | 217 | <itemData name="Value" defStyleNum="dsString" spellChecking="false" /> | ||
235 | <itemData name="EntityRef" defStyleNum="dsDecVal" spellChecking="false" /> | 218 | <itemData name="EntityRef" defStyleNum="dsDecVal" spellChecking="false" /> | ||
236 | <itemData name="Code Brackets" defStyleNum="dsVariable" spellChecking="false" /> | 219 | <itemData name="Code Brackets" defStyleNum="dsVariable" spellChecking="false" /> | ||
237 | <itemData name="Error" defStyleNum="dsError" spellChecking="false" /> | 220 | <itemData name="Error" defStyleNum="dsError" spellChecking="false" /> | ||
238 | <itemData name="Comment URL" defStyleNum="dsComment" underline="1" spellChecking="false" /> | | |||
239 | 221 | | |||
240 | <!-- itemDatas in JavaScript XML file --> | 222 | <!-- itemDatas in JavaScript XML file --> | ||
241 | <itemData name="Symbol" defStyleNum="dsOperator" /> | 223 | <itemData name="Symbol" defStyleNum="dsOperator" /> | ||
242 | <itemData name="ControlFlow" defStyleNum="dsControlFlow" spellChecking="false" /> | 224 | <itemData name="ControlFlow" defStyleNum="dsControlFlow" spellChecking="false" /> | ||
243 | <itemData name="Module" defStyleNum="dsImport" spellChecking="false" /> | 225 | <itemData name="Module" defStyleNum="dsImport" spellChecking="false" /> | ||
244 | <itemData name="Template" defStyleNum="dsVerbatimString" /> | 226 | <itemData name="Template" defStyleNum="dsVerbatimString" /> | ||
245 | <itemData name="Substitution" defStyleNum="dsSpecialChar" spellChecking="false" /> | 227 | <itemData name="Substitution" defStyleNum="dsSpecialChar" spellChecking="false" /> | ||
246 | </itemDatas> | 228 | </itemDatas> | ||
Show All 13 Lines |