summaryrefslogtreecommitdiffstats
path: root/kate/data/template-toolkit.xml
blob: 2bc1735e6237ba8397fdb44f03e6ae393b3b2abd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd"
          [
          <!ENTITY var1    "\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff\.\-]*(\[[a-zA-Z0-9_]*\])*">
          <!ENTITY varwithbraces "\$\{[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff\.\-]*(\[[a-zA-Z0-9_]*\])*\}">
]>
<!--
    Copyright (C) 2007 Красимир Беров <[email protected]>
    Put this file in your ~/.trinity/share/apps/katepart/syntax,
    then restart Кate/KDevelop/Quanta... whatever using katepart.
    That's it. You have Template Toolkit Syntax highliting.
    Enjoy!!!
    
    -->
    <!--
    Changelog :)
    0.02 Added highliting for interpolated variables
        -->
<language version="0.03-2" kateversion="2.3"
          author="Красимир Беров ([email protected])" license="Artistic"
          name="TT2" section="Markup" extensions="*.tt*;" casesensitive="true">
<highlighting>
    <list name="control structures">
        <!-- Template directives -->
        <item>SET</item>
        <item>GET</item>
        <item>CALL</item>
        <item>DEFAULT</item>
        <item>IF</item>
        <item>ELSIF</item>
        <item>ELSE</item>
        <item>UNLESS</item>
        <item>LAST</item>
        <item>NEXT</item>
        <item>FOR</item>
        <item>FOREACH</item>
        <item>WHILE</item>
        <item>SWITCH</item>
        <item>CASE</item>
        <item>PROCESS</item>
        <item>INCLUDE</item>
        <item>INSERT</item>
        <item>WRAPPER</item>
        <item>BLOCK</item>
        <item>MACRO</item>
        <item>END</item>
        <item>USE</item>
        <item>IN</item>
        <item>FILTER</item>
        <item>TRY</item>
        <item>THROW</item>
        <item>CATCH</item>
        <item>FINAL</item>
        <item>META</item>
        <item>TAGS</item>
        <item>DEBUG</item>
        <item>PERL</item>
    </list>
    <list name="keywords">
        <!-- Compile Time Constant Folding -->
        <item>constants</item>
        <!-- Special Variables -->
        <item>template</item>
        <item>component</item>
        <item>loop</item>
        <item>error</item>
        <item>content</item>
    </list>
    <list name="items">
        <!-- VMethods -->
        <!-- Scalar Virtual Methods -->
        <item>defined</item>
        <item>length</item>
        <item>repeat</item>
        <item>replace</item>
        <item>match</item>
        <item>search</item>
        <item>split</item>
        <item>chunk</item>
        <item>list</item>
        <item>hash</item>
        <item>size</item>
        <!-- Hash Virtual Methods -->
        <item>keys</item>
        <item>values</item>
        <item>each</item>
        <item>sort</item>
        <item>nsort</item>
        <item>import</item>
        <item>defined</item>
        <item>exists</item>
        <item>item</item>
        <!-- List Virtual Methods -->
        <item>first</item>
        <item>last</item>
        <item>max</item>
        <item>reverse</item>
        <item>join</item>
        <item>grep</item>
        
        <item>unshift</item>
        <item>push</item>
        <item>shift</item>
        <item>pop</item>
        <item>unique</item>
        <item>merge</item>
        <item>slice</item>
        <item>splice</item>
        <item>count</item>
        <!-- Standard filters -->
        <item>format</item>
        <item>upper</item>
        <item>lower</item>
        <item>ucfirst</item>
        <item>lcfirst</item>
        <item>trim</item>
        <item>collapse</item>
        <item>html</item>
        <item>html_entity</item>
        <item>html_para</item>
        <item>html_break</item>
        <item>html_para_break</item>
        <item>html_line_break</item>
        <item>uri</item>
        <item>url</item>
        <item>indent</item>
        <item>truncate</item>
        <item>repeat</item>
        <item>remove</item>
        <item>replace</item>
        <item>redirect</item>
        <item>eval</item>
        <item>evaltt</item>
        <item>perl</item>
        <item>evalperl</item>
        <item>stdout</item>
        <item>stderr</item>
        <item>null</item>
        <item>latex</item>
    </list>    
    <list name="operators">
        <item> = </item>
        <item> != </item>
        <item> ~= </item>
        <item> += </item>
        <item> -= </item>
        <item> *= </item>
        <item> /= </item>
        <item> **= </item>
        <item> |= </item>
        <item> ||= </item>
        <item> &amp;= </item>
        <item> &amp;&amp;= </item>
        <item> ?= </item>
        <item> + </item>
        <item> - </item>
        <item> * </item>
        <!-- <item> / </item>//-->
        <item> % </item>
        <item> || </item>
        <item> &amp;&amp; </item>
        <item> | </item>
        <item> &amp; </item>
        <item> &lt; </item>
        <item> &lt;&lt; </item>
        <item> &gt; </item>
        <item> &gt;&gt; </item>
        <item> ^ </item>
        <item> -&gt; </item>
        <item> =&gt; </item>
        <item> . </item>
        <item> , </item>
        <item> ; </item>
        <item> :: </item>
        <item> \ </item>
        <item> and </item>
        <item> or </item>
        <item> not </item>
        <item> eq </item>
        <item> ne </item>
    </list>

    <contexts>
        <context name="nosource" attribute="Normal Text" lineEndContext="#stay">
            <StringDetect attribute="Keyword" context="tt2source" String="[%" />
            <RegExpr attribute="HTML Tag" context="scripts" String="&lt;\s*script(\s|&gt;)" insensitive="true" />
            <RegExpr attribute="HTML Tag" context="htmltag" String="&lt;\s*\/?\s*[a-zA-Z_:][a-zA-Z0-9._:-]*" />
            <StringDetect attribute="HTML Comment" context="htmlcomment" String="&lt;!--" />
            <!-- Interpolated variables -->
            <RegExpr attribute="Variable" context="#stay" String="&var1;" />
            <RegExpr attribute="Variable" context="#stay" String="&varwithbraces;" />
        </context>
        
        <context name="tt2source" attribute="TT2 Text" lineEndContext="#stay">
            <StringDetect attribute="Keyword" context="#pop" String="%]" />
            <DetectChar attribute="Comment" context="tt2_onelinecomment" char="#" />
            <DetectChar attribute="String" context="doublequotestring" char="&quot;" />
            <DetectChar attribute="String" context="singlequotestring" char="&#39;" />
            <DetectChar attribute="Keyword" context="#stay" char="&amp;" />
            <keyword attribute="Operator" context="#stay" String="operators" />
            <keyword attribute="Function" context="#stay" String="functions" />
            <RegExpr attribute="String" context="" String="" />
            <RegExpr attribute="String" context="#stay" String="[0123456789]*\.\.\.[0123456789]*" />
            <HlCOct attribute="Octal" context="#stay" />
            <HlCHex attribute="Hex" context="#stay" />
            <Float attribute="Float" context="#stay" />
            <Int attribute="Decimal" context="#stay" />
            <AnyChar attribute="Other" context="#stay" String=";()}{:,[]" />
            <keyword attribute="Other" context="#stay" String="Others" />
            
            <RegExpr attribute="Control Structures" context="#stay" String="\bELSIF\b" insensitive="false" beginRegion="iffi1" endRegion="iffi1"/>
            <RegExpr attribute="Control Structures" context="#stay" String="\bELSE\b" insensitive="false" beginRegion="iffi1" endRegion="iffi1"/>
            <RegExpr attribute="Control Structures" context="#stay" String="\bIF\b" insensitive="false" beginRegion="iffi1"/>
            <RegExpr attribute="Control Structures" context="#stay" String="\bEND\b" insensitive="false" endRegion="iffi1"/>

            <RegExpr attribute="Control Structures" context="#stay" String="\bFOREACH\b" insensitive="false" beginRegion="foreachblock"/>
            <RegExpr attribute="Control Structures" context="#stay" String="\bEND\b" insensitive="false" endRegion="foreachblock"/>

            
            <keyword attribute="Keyword" context="#stay" String="keywords" />
            <keyword attribute="Control Structures" context="#stay" String="control structures" />
            <keyword attribute="Function" context="#stay" String="functions" />
        </context>
        <context name="tt2_onelinecomment" attribute="Comment" lineEndContext="#pop">
            <StringDetect attribute="Keyword" context="#pop#pop" String="%]" />
        </context>
        <context name="doublequotestring" attribute="String" lineEndContext="#stay">
            <Detect2Chars attribute="Escape Code" context="#stay" char="&quot;" char1="&quot;" />
            <RegExpr attribute="Escape Code" context="#stay" String="\\[0-7]{1,3}" />
            <RegExpr attribute="Escape Code" context="#stay" String="\\x[0-9A-Fa-f]{1,2}" />
            <DetectChar attribute="String" context="#pop" char="&quot;" />
            <!-- Interpolated variables -->
            <RegExpr attribute="Variable" context="#stay" String="&var1;" />
            <RegExpr attribute="Variable" context="#stay" String="&varwithbraces;" />
        </context>
        <context name="singlequotestring" attribute="String" lineEndContext="#stay">
            <Detect2Chars attribute="Escape Code" context="#stay" char="'" char1="'"/>
            <DetectChar attribute="String" context="#pop" char="'" />
        </context>
        <context name="htmltag" attribute="Identifier" lineEndContext="#stay">
            <Detect2Chars attribute="HTML Tag" context="#pop" char="/" char1="&gt;" />
            <DetectChar attribute="HTML Tag" context="#pop" char="&gt;"/>
            <StringDetect attribute="Keyword" context="tt2source" String="[%" />
            <StringDetect attribute="Keyword" context="tt2source" String="[%" />
            <RegExpr attribute="Identifier" context="identifiers" String="\s*=\s*"/>

        </context>
        <context name="htmlcomment" attribute="HTML Comment" lineEndContext="#stay">
            <StringDetect attribute="Keyword" context="tt2source" String="[%" />
            <StringDetect attribute="Keyword" context="tt2source" String="[%" />
            <StringDetect attribute="HTML Comment" context="#pop" String="--&gt;" />
            <RegExpr attribute="Normal Text" context="identifiers" String="\s*=\s*"/>
        </context>
        <context name="identifiers" attribute="Identifier" lineEndContext="#stay">
            <RegExpr attribute="String" context="#pop" String="\s*#?[a-zA-Z0-9]*" />
            <DetectChar attribute="Types" context="types1" char="'" />
            <DetectChar attribute="Types" context="types2" char="&quot;" />
        </context>
        
        <context name="types1" attribute="Types" lineEndContext="#stay">
            <StringDetect attribute="Keyword" context="tt2source" String="[%" />
            <StringDetect attribute="Keyword" context="tt2source" String="[%" />
            <DetectChar attribute="Types" context="#pop#pop" char="'" />
        </context>
        
        <context name="types2" attribute="Types" lineEndContext="#stay">
            <StringDetect attribute="Keyword" context="tt2source" String="[%" />
            <StringDetect attribute="Keyword" context="tt2source" String="[%" />
            <DetectChar attribute="Types" context="#pop#pop" char="&quot;" />
        </context>
        
        <context name="scripts" attribute="Normal Text" lineEndContext="#stay">
            <Detect2Chars attribute="Comment" context="scripts_onelinecomment" char="/" char1="/" />
            <Detect2Chars attribute="Comment" context="twolinecomment" char="/" char1="*" />
            <keyword attribute="Control Structures" context="#stay" String="control structures" />
            <keyword attribute="Keyword" context="#stay" String="keywords" />
            <keyword attribute="Function" context="#stay" String="functions" />
            <StringDetect attribute="Keyword" context="tt2source" String="[%"/>
            <RegExpr attribute="HTML Tag" context="#pop" String="&lt;\s*\/\s*script\s*&gt;" insensitive="true" />
            
            <DetectChar attribute="String" context="doublequotestring" char="&quot;" />
            <DetectChar attribute="String" context="singlequotestring" char="&#39;" />
            <HlCOct attribute="Octal" context="#stay" />
            <HlCHex attribute="Hex" context="#stay" />
            <Float attribute="Float" context="#stay" />
            <Int attribute="Decimal" context="#stay" />
            <DetectChar attribute="Normal Text" context="#stay" char="{" beginRegion="Brace1" />
            <DetectChar attribute="Normal Text" context="#stay" char="}" endRegion="Brace1" />
            <AnyChar attribute="Other" context="#stay" String=";()}{:,[]" />
            <keyword attribute="Other" context="#stay" String="Others" />
        </context>
        <context name="scripts_onelinecomment" attribute="Comment" lineEndContext="#pop">
            <RegExpr attribute="HTML Tag" context="#pop#pop" String="&lt;\s*\/\s*script\s*&gt;" insensitive="true" />
        </context>
        <context name="twolinecomment" attribute="Comment" lineEndContext="#stay">
            <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="Comment" />
        </context>
        
    </contexts>
            
    <itemDatas>
        <itemData name="Normal Text" defStyleNum="dsNormal" />
        <itemData name="TT2 Text" defStyleNum="dsNormal" />
        <itemData name="Keyword" defStyleNum="dsKeyword" />
        <itemData name="Function" defStyleNum="dsKeyword" color="#0000FF" selColor="#00ffff" bold="0" italic="0"/>
        <itemData name="Decimal" defStyleNum="dsDecVal" />
        <itemData name="Octal" defStyleNum="dsBaseN" />
        <itemData name="Hex" defStyleNum="dsBaseN" />
        <itemData name="Float" defStyleNum="dsFloat" />
        <itemData name="String" defStyleNum="dsString" color="#FF6C6C" selColor="#FF6C6C" bold="0" italic="0" />
        <itemData name="Comment" defStyleNum="dsComment" />
        <itemData name="Variable" defStyleNum="dsKeyword" color="#5555FF" selColor="#ffffff" bold="1" italic="0" />
        <itemData name="Control Structures" defStyleNum="dsKeyword" color="#0000dd" selColor="#ffffff" bold="1" italic="0" />
        <itemData name="Backslash Code" defStyleNum="dsKeyword" color="#0F0F8F" selColor="#ffffff" bold="1" italic="0" />
        <itemData name="Other" defStyleNum="dsOthers" />
        <itemData name="Operator" defStyleNum="dsKeyword" color="#008000"/>
      <itemData name="HTML Tag" defStyleNum="dsKeyword" color="#0F0000" selColor="#ffffff" bold="1" italic="0" />
        <itemData name="HTML Comment" defStyleNum="dsComment" />
        <itemData name="Identifier" defStyleNum="dsOthers" />
        <itemData name="Types" defStyleNum="dsDataType" />
    </itemDatas>
</highlighting>
<general>
    <comments>
        <comment name="multiLine" start="&lt;!--" end="--&gt;" />
        <comment name="singleLine" start="#" />
        <comment name="multiLine" start="[%#" end="%]"/>
    </comments>
    <keywords casesensitive="1" />
  </general>
</language>