Changeset View
Changeset View
Standalone View
Standalone View
data/syntax/mustache.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 name "[A-Za-z_:][\w.:_-]*"> | 4 | <!ENTITY name "[A-Za-z_:][\w.:_-]*"> | ||
5 | <!ENTITY attributeName "(\s|^)[A-Za-z_:\*#\(\[][\)\]\w\.:_-]*"> | 5 | <!ENTITY attributeName "(?:\s|^)[A-Za-z_:\*#\(\[][\)\]\w\.:_-]*"> | ||
6 | <!ENTITY entref "&(#[0-9]+|#[xX][0-9A-Fa-f]+|&name;);"> | 6 | <!ENTITY entref "&(?:#[0-9]+|#[xX][0-9A-Fa-f]+|&name;);"> | ||
7 | <!ENTITY tag "<\s*(&name;|>)"> | 7 | <!ENTITY tag "<\s*(?:&name;|>)"> | ||
8 | <!-- Handlebars identifier --> | 8 | <!-- Handlebars identifier --> | ||
9 | <!ENTITY identifier "([a-zA-Z_$:\?]|[^[:ascii:]])([\w$:\?\-]|[^[:ascii:]])*"> | 9 | <!ENTITY identifier "(?:[a-zA-Z_$:\?]|[^[:ascii:]])(?:[\w$:\?\-]|[^[:ascii:]])*"> | ||
10 | ]> | 10 | ]> | ||
11 | 11 | | |||
12 | <!-- | 12 | <!-- | ||
13 | Syntax Highlighting Defintion of | 13 | Syntax Highlighting Defintion of | ||
14 | Mustache / Handlebars / Ractive templates for Kate. | 14 | Mustache / Handlebars / Ractive templates for Kate. | ||
15 | ================================================================ | 15 | ================================================================ | ||
16 | This file is part of the KDE's KSyntaxHighlighting framework. | 16 | This file is part of the KDE's KSyntaxHighlighting framework. | ||
17 | 17 | | |||
Show All 13 Lines | |||||
31 | This highlighter doesn't offer support for TypeScript and JSX | 31 | This highlighter doesn't offer support for TypeScript and JSX | ||
32 | in the <script> tag. | 32 | in the <script> tag. | ||
33 | 33 | | |||
34 | TODO: This code can be generated by a script, in the same way | 34 | TODO: This code can be generated by a script, in the same way | ||
35 | as the PHP highlight, injecting the "MustacheVariables" context | 35 | as the PHP highlight, injecting the "MustacheVariables" context | ||
36 | (via IncludeRules) in the HTML highlighter. | 36 | (via IncludeRules) in the HTML highlighter. | ||
37 | 37 | | |||
38 | Change log: | 38 | Change log: | ||
39 | * v3 [2019-10-03]: Minor fixes. | ||||
39 | * v2 [2019-02-24]: Also highlight template files (HTML). | 40 | * v2 [2019-02-24]: Also highlight template files (HTML). | ||
40 | Improve support for Handlebars. | 41 | Improve support for Handlebars. | ||
41 | * v1 [2019-02-10]: Initial version | 42 | * v1 [2019-02-10]: Initial version | ||
42 | --> | 43 | --> | ||
43 | 44 | | |||
44 | <language name="Mustache/Handlebars (HTML)" version="2" kateversion="5.0" | 45 | <language name="Mustache/Handlebars (HTML)" version="3" kateversion="5.44" | ||
45 | section="Markup" priority="1" mimetype="" | 46 | section="Markup" priority="1" mimetype="" | ||
46 | extensions="*.mustache;*.handlebars;*.hbs;*.ractive;*.hogan;*.hulk;*.html.mst;*.html.mu;*.html.rac" | 47 | extensions="*.mustache;*.handlebars;*.hbs;*.ractive;*.hogan;*.hulk;*.html.mst;*.html.mu;*.html.rac" | ||
47 | author="Nibaldo González (nibgonz@gmail.com), based on the HTML highlighter by Wilbert Berendsen (wilbert@kde.nl)" | 48 | author="Nibaldo González (nibgonz@gmail.com), based on the HTML highlighter by Wilbert Berendsen (wilbert@kde.nl)" | ||
48 | license="MIT"> | 49 | license="MIT"> | ||
49 | 50 | | |||
50 | <highlighting> | 51 | <highlighting> | ||
51 | 52 | | |||
52 | <contexts> | 53 | <contexts> | ||
Show All 27 Lines | |||||
80 | </context> | 81 | </context> | ||
81 | <context name="StartMustacheVariable" attribute="Normal Text" lineEndContext="#stay"> | 82 | <context name="StartMustacheVariable" attribute="Normal Text" lineEndContext="#stay"> | ||
82 | <!-- Escaped --> | 83 | <!-- Escaped --> | ||
83 | <RegExpr context="#pop!MustacheRawBlockContent" attribute="Mustache Block" String="\{{4}[^/].*\}{4}" minimal="true" beginRegion="HandlebarsRawBlock" /> | 84 | <RegExpr context="#pop!MustacheRawBlockContent" attribute="Mustache Block" String="\{{4}[^/].*\}{4}" minimal="true" beginRegion="HandlebarsRawBlock" /> | ||
84 | <!-- Sections --> | 85 | <!-- Sections --> | ||
85 | <!-- For helpers (not included because it's redundant): | 86 | <!-- For helpers (not included because it's redundant): | ||
86 | Start: \{\{~?#?\s*(?=(if|unless|with|link\-to|each(\-in)?)\b) | 87 | Start: \{\{~?#?\s*(?=(if|unless|with|link\-to|each(\-in)?)\b) | ||
87 | End: \{\{~?/\s*(?=(if|unless|with|link\-to|each(\-in)?)\b) --> | 88 | End: \{\{~?/\s*(?=(if|unless|with|link\-to|each(\-in)?)\b) --> | ||
88 | <RegExpr context="#pop!MustacheVariableBlock" attribute="Mustache Block" String="\{\{~?\s*else(\s+(if|unless|with|link\-to|each(\-in)?))?\b" /> | 89 | <RegExpr context="#pop!MustacheVariableBlock" attribute="Mustache Block" String="\{\{~?\s*else(?:\s+(?:if|unless|with|link\-to|each(?:\-in)?))?\b" /> | ||
89 | <RegExpr context="#pop!MustacheVariableBlock" attribute="Mustache Block" String="\{\{~?[#\^][>\*]?\s*&identifier;\b" beginRegion="MustacheBlock" /> | 90 | <RegExpr context="#pop!MustacheVariableBlock" attribute="Mustache Block" String="\{\{~?[#\^][>\*]?\s*&identifier;\b" beginRegion="MustacheBlock" /> | ||
90 | <RegExpr context="#pop" attribute="Mustache Block" String="\{\{~?/\s*&identifier;\s*\}\}" endRegion="MustacheBlock" /> | 91 | <RegExpr context="#pop" attribute="Mustache Block" String="\{\{~?/\s*&identifier;\s*\}\}" endRegion="MustacheBlock" /> | ||
91 | <RegExpr context="#pop!MustacheVariableBlockEndFolding" attribute="Mustache Block" String="\{\{~?/\s*&identifier;\b" /> | 92 | <RegExpr context="#pop!MustacheVariableBlockEndFolding" attribute="Mustache Block" String="\{\{~?/\s*&identifier;\b" /> | ||
92 | <RegExpr context="#pop!MustacheVariableBlock" attribute="Mustache Block" String="\{\{~?[#\^/]" /> | 93 | <RegExpr context="#pop!MustacheVariableBlock" attribute="Mustache Block" String="\{\{~?[#\^/]" /> | ||
93 | <!-- Comments --> | 94 | <!-- Comments --> | ||
94 | <StringDetect context="#pop!MustacheBlockComment" attribute="Comment" String="{{!--" beginRegion="MustacheBlockComment" /> <!-- Handlebars --> | 95 | <StringDetect context="#pop!MustacheBlockComment" attribute="Comment" String="{{!--" beginRegion="MustacheBlockComment" /> <!-- Handlebars --> | ||
95 | <StringDetect context="#pop!MustacheInlineComment" attribute="Comment" String="{{!" beginRegion="MustacheInlineComment" /> | 96 | <StringDetect context="#pop!MustacheInlineComment" attribute="Comment" String="{{!" beginRegion="MustacheInlineComment" /> | ||
96 | <!-- Variables --> | 97 | <!-- Variables --> | ||
97 | <StringDetect context="#pop!MustachePartial" attribute="Mustache Variable" String="{{<" /> | 98 | <StringDetect context="#pop!MustachePartial" attribute="Mustache Variable" String="{{<" /> | ||
98 | <StringDetect context="#pop!MustachePartial" attribute="Mustache Variable" String="{{>" /> | 99 | <StringDetect context="#pop!MustachePartial" attribute="Mustache Variable" String="{{>" /> | ||
99 | <StringDetect context="#pop!MustacheMarkerSet" attribute="Mustache Variable" String="{{=" /> | 100 | <StringDetect context="#pop!MustacheMarkerSet" attribute="Mustache Variable" String="{{=" /> | ||
100 | <StringDetect context="#pop!MustacheVariable" attribute="Mustache Variable" String="{{$" /> | 101 | <StringDetect context="#pop!MustacheVariable" attribute="Mustache Variable" String="{{$" /> | ||
101 | <RegExpr context="#pop!MustacheVariableUnescape" attribute="Mustache Variable Unescape" String="\{\{\{\s*(log|link)\b" /> | 102 | <RegExpr context="#pop!MustacheVariableUnescape" attribute="Mustache Variable Unescape" String="\{\{\{\s*(?:log|link)\b" /> | ||
102 | <RegExpr context="#pop!MustacheVariable" attribute="Mustache Variable" String="\{\{\s*(log|link)\b" /> | 103 | <RegExpr context="#pop!MustacheVariable" attribute="Mustache Variable" String="\{\{\s*(?:log|link)\b" /> | ||
103 | 104 | | |||
104 | <StringDetect context="#pop!MustacheVariableUnescape" attribute="Mustache Variable Unescape" String="{{{" /> | 105 | <StringDetect context="#pop!MustacheVariableUnescape" attribute="Mustache Variable Unescape" String="{{{" /> | ||
105 | <Detect2Chars context="#pop!MustacheVariable" attribute="Mustache Variable" char="{" char1="{" /> | 106 | <Detect2Chars context="#pop!MustacheVariable" attribute="Mustache Variable" char="{" char1="{" /> | ||
106 | </context> | 107 | </context> | ||
107 | 108 | | |||
108 | <context name="MustacheRawBlockContent" attribute="Normal Text" lineEndContext="#stay"> | 109 | <context name="MustacheRawBlockContent" attribute="Normal Text" lineEndContext="#stay"> | ||
109 | <RegExpr context="#pop" attribute="Mustache Block" String="\{{4}/.*\}{4}" minimal="true" endRegion="HandlebarsRawBlock" /> | 110 | <RegExpr context="#pop" attribute="Mustache Block" String="\{{4}/.*\}{4}" minimal="true" endRegion="HandlebarsRawBlock" /> | ||
110 | </context> | 111 | </context> | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 202 | <context name="FindElementTagEnd" attribute="Normal Text" lineEndContext="#stay"> | |||
209 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</article" insensitive="true" endRegion="article" /> | 210 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</article" insensitive="true" endRegion="article" /> | ||
210 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</aside" insensitive="true" endRegion="aside" /> | 211 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</aside" insensitive="true" endRegion="aside" /> | ||
211 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</details" insensitive="true" endRegion="details" /> | 212 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</details" insensitive="true" endRegion="details" /> | ||
212 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</figure" insensitive="true" endRegion="figure" /> | 213 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</figure" insensitive="true" endRegion="figure" /> | ||
213 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</footer" insensitive="true" endRegion="footer" /> | 214 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</footer" insensitive="true" endRegion="footer" /> | ||
214 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</header" insensitive="true" endRegion="header" /> | 215 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</header" insensitive="true" endRegion="header" /> | ||
215 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</main" insensitive="true" endRegion="main" /> | 216 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</main" insensitive="true" endRegion="main" /> | ||
216 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</nav" insensitive="true" endRegion="nav" /> | 217 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</nav" insensitive="true" endRegion="nav" /> | ||
217 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</sectiond" insensitive="true" endRegion="section" /> | 218 | <WordDetect context="ElementTagEnd" attribute="Element Tag" String="</section" insensitive="true" endRegion="section" /> | ||
218 | 219 | | |||
219 | <RegExpr context="#stay" attribute="Element Tag" String="</\s*>" /> | 220 | <RegExpr context="#stay" attribute="Element Tag" String="</\s*>" /> | ||
220 | <RegExpr context="ElementTagEnd" attribute="Element Tag" String="</\s*&name;" /> | 221 | <RegExpr context="ElementTagEnd" attribute="Element Tag" String="</\s*&name;" /> | ||
221 | </context> | 222 | </context> | ||
222 | <context name="ElementTagEnd" attribute="Normal Text" lineEndContext="#stay"> | 223 | <context name="ElementTagEnd" attribute="Normal Text" lineEndContext="#stay"> | ||
223 | <DetectChar context="#pop" attribute="Element Tag" char=">" /> | 224 | <DetectChar context="#pop" attribute="Element Tag" char=">" /> | ||
224 | <IncludeRules context="MustacheVariables" /> | 225 | <IncludeRules context="MustacheVariables" /> | ||
225 | <RegExpr context="#stay" attribute="Error" String="\S" /> | 226 | <RegExpr context="#stay" attribute="Error" String="\S" /> | ||
Show All 40 Lines | |||||
266 | <!-- NOTE: This contexts are duplicated from 'html.xml', adding the Mustache variables --> | 267 | <!-- NOTE: This contexts are duplicated from 'html.xml', adding the Mustache variables --> | ||
267 | 268 | | |||
268 | <context name="FindComments" attribute="Normal Text" lineEndContext="#stay"> | 269 | <context name="FindComments" attribute="Normal Text" lineEndContext="#stay"> | ||
269 | <StringDetect context="Comment" attribute="Comment" String="<!--" beginRegion="Comment" /> | 270 | <StringDetect context="Comment" attribute="Comment" String="<!--" beginRegion="Comment" /> | ||
270 | </context> | 271 | </context> | ||
271 | <context name="Comment" attribute="Comment" lineEndContext="#stay"> | 272 | <context name="Comment" attribute="Comment" lineEndContext="#stay"> | ||
272 | <DetectSpaces/> | 273 | <DetectSpaces/> | ||
273 | <StringDetect context="#pop" attribute="Comment" String="-->" endRegion="Comment" /> | 274 | <StringDetect context="#pop" attribute="Comment" String="-->" endRegion="Comment" /> | ||
274 | <RegExpr context="#stay" attribute="Error" String="-(-(?!->))+" /> | 275 | <RegExpr context="#stay" attribute="Error" String="-(?:-(?!->))+" /> | ||
275 | <IncludeRules context="MustacheVariables" /> | 276 | <IncludeRules context="MustacheVariables" /> | ||
276 | <IncludeRules context="##Alerts" /> | 277 | <IncludeRules context="##Alerts" /> | ||
277 | </context> | 278 | </context> | ||
278 | 279 | | |||
279 | <context name="FindPEntityRefs" attribute="Normal Text" lineEndContext="#stay"> | 280 | <context name="FindPEntityRefs" attribute="Normal Text" lineEndContext="#stay"> | ||
280 | <RegExpr attribute="EntityRef" context="#stay" String="&entref;" /> | 281 | <RegExpr attribute="EntityRef" context="#stay" String="&entref;" /> | ||
281 | <RegExpr attribute="PEntityRef" context="#stay" String="%&name;;" /> | 282 | <RegExpr attribute="PEntityRef" context="#stay" String="%&name;;" /> | ||
282 | <AnyChar attribute="Error" context="#stay" String="&%" /> | 283 | <AnyChar attribute="Error" context="#stay" String="&%" /> | ||
283 | </context> | 284 | </context> | ||
284 | 285 | | |||
285 | <context name="FindDTDRules" attribute="Normal Text" lineEndContext="#stay"> | 286 | <context name="FindDTDRules" attribute="Normal Text" lineEndContext="#stay"> | ||
286 | <RegExpr context="Doctype Markupdecl" attribute="Doctype" String="<!(ELEMENT|ENTITY|ATTLIST|NOTATION)\b" /> | 287 | <RegExpr context="Doctype Markupdecl" attribute="Doctype" String="<!(?:ELEMENT|ENTITY|ATTLIST|NOTATION)\b" /> | ||
287 | </context> | 288 | </context> | ||
288 | <context name="FindPI" attribute="Normal Text" lineEndContext="#stay"> | 289 | <context name="FindPI" attribute="Normal Text" lineEndContext="#stay"> | ||
289 | <RegExpr context="PI" attribute="Processing Instruction" String="<\?[\w:-]*" beginRegion="pi" /> | 290 | <RegExpr context="PI" attribute="Processing Instruction" String="<\?[\w:-]*" beginRegion="pi" /> | ||
290 | </context> | 291 | </context> | ||
291 | 292 | | |||
292 | <context name="CDATA" attribute="Normal Text" lineEndContext="#stay"> | 293 | <context name="CDATA" attribute="Normal Text" lineEndContext="#stay"> | ||
293 | <IncludeRules context="MustacheVariables" /> | 294 | <IncludeRules context="MustacheVariables" /> | ||
294 | <StringDetect context="#pop" attribute="CDATA" String="]]>" endRegion="cdata" /> | 295 | <StringDetect context="#pop" attribute="CDATA" String="]]>" endRegion="cdata" /> | ||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |