Diff of /syntax/xml.jsf.in [000000] .. [409b67] Maximize Restore

  Switch to unified view

a b/syntax/xml.jsf.in
1
# Improved XML highlighter by: Brian Candler <B.Candler@pobox.com>
2
3
# Define no. sync lines
4
# You can say:
5
# -200     means 200 lines
6
# -        means always start parsing from beginning of file when we lose sync
7
#          if nothing is specified, the default is -50
8
9
-
10
11
# Define colors
12
#
13
# bold inverse blink dim underline
14
# white cyan magenta blue yellow green red black
15
# bg_white bg_cyan bg_magenta bg_blue bg_yellow bg_green bg_red bg_black
16
17
# The underlines are here right now just because I want to distinguish which
18
# bits have been coloured (say) CdataStart, CdataBody, CdataEnd. And that's
19
# because I think it may be useful to make that distinction for some people.
20
21
=Idle
22
=Error        red bold
23
=Tag      blue
24
=Attr     cyan
25
=Constant blue bold
26
=EntityRef    magenta
27
=Decl     cyan
28
=CommentStart green
29
=CommentBody  green
30
=CommentEnd   green
31
=PIStart  magenta bold
32
=PIBody       magenta
33
=PIEnd        magenta bold
34
=CdataStart   blue bold
35
=CdataBody    bold
36
=CdataEnd blue bold
37
38
# http://www.w3.org/TR/2004/REC-xml-20040204/
39
#
40
# NOTE: For UNICODE compatibility, the ranges
41
# "A-Za-z_:"      -- first character of Name
42
# "A-Za-z0-9._:-"     -- subsequent characters of Name
43
# ought to be replaced with some appropriate Unicode character classes
44
45
:content Idle
46
  *       content
47
  "<"     tag     recolor=-1
48
  "&"     entityref   recolor=-1
49
50
# > is allowed
51
# ">"     error       noeat recolor=-1
52
53
54
# In several contexts a space is an error, and since a coloured space is
55
# not visible, we colour the next non-space character as well.
56
57
:error Error
58
  *       error_visible   noeat recolor=-1
59
  " \t\r\n"   error
60
61
:error_visible Error
62
  *       content
63
64
# Matched: &
65
66
:entityref EntityRef
67
  *       error       noeat recolor=-1
68
  "A-Za-z0-9._:-" entityref
69
  "#"     entityref
70
  ";"     content
71
72
# Matched: <
73
74
:tag Tag
75
  *       error       noeat recolor=-1
76
  "/"     end_tag
77
  "A-Za-z_:"  start_or_empty_tag
78
  "?"     pi_start    recolor=-2
79
  "!"     decl        recolor=-2 buffer
80
81
# Matched: </
82
83
:end_tag Tag
84
  *       error       noeat recolor=-1
85
  "A-Za-z_:"  end_tag2
86
87
:end_tag2 Tag
88
  *       error       noeat recolor=-1
89
  "A-Za-z0-9._:-" end_tag2
90
  " \t\r\n"   end_tag2_sp recolor=-1
91
  ">"     content
92
93
:end_tag2_sp Idle
94
  *       end_tag3    noeat
95
96
:end_tag3 Tag
97
  *       error       noeat recolor=-1
98
  " \t\r\n"   end_tag3_sp recolor=-1
99
  ">"     content
100
101
:end_tag3_sp Idle
102
  *       end_tag_3   noeat
103
104
# Matched: <tag
105
106
:start_or_empty_tag Tag
107
  *       error       noeat recolor=-1
108
  "A-Za-z0-9._:-" start_or_empty_tag
109
  "/"     empty_tag
110
  " \t\r\n"   start_or_empty_tag_sp   recolor=-1
111
  ">"     content
112
113
:start_or_empty_tag_sp Idle
114
  *       tag_space   noeat
115
116
# Matched: <tag/
117
118
:empty_tag Tag
119
  *       error       noeat recolor=-1
120
  ">"     content
121
122
# Matched: <tag SPACE
123
124
:tag_space Attr
125
  *       error       noeat recolor=-1
126
  " \t\r\n"   tag_space_sp    recolor=-1
127
  "A-Za-z_:"  attr
128
  "/"     empty_tag   recolor=-1
129
  ">"     close_tag   recolor=-1
130
131
:tag_space_sp Idle
132
  *       tag_space   noeat
133
134
# Matched: <tag attr
135
136
:attr Attr
137
  *       error       noeat recolor=-1
138
  "A-Za-z0-9._:-" attr
139
  " \t\r\n"   attr_sp     recolor=-1
140
  "="     string
141
142
:attr_sp Idle
143
  *       attr_before noeat
144
145
:attr_before Attr
146
  *       error       noeat recolor=-1
147
  " \t\r\n"   attr_sp     recolor=-1
148
  "="     string
149
150
# Matched: <tag attr=
151
152
:string Attr
153
  *       error       noeat recolor=-1
154
  " \t\r\n"   string_sp   recolor=-1
155
  "\""        astring     recolor=-1
156
  "'"     bstring     recolor=-1
157
158
:string_sp Idle
159
  *       string      noeat
160
161
# Matched: <tag attr="
162
163
:astring Constant
164
  *       astring
165
  "<"     error       noeat recolor=-1
166
  "&"     achar       recolor=-1
167
  "\""        endstring
168
169
# ">"     error       noeat recolor=-1
170
171
172
:bstring Constant
173
  *       bstring
174
  "<"     error       noeat recolor=-1
175
  "&"     bchar       recolor=-1
176
  "'"     endstring
177
178
# ">"     error       noeat recolor=-1
179
180
181
:achar EntityRef
182
  *       error       noeat recolor=-1
183
  "A-Za-z0-9._:-" achar
184
  "#"     achar
185
  ";"     astring
186
187
:bchar EntityRef
188
  *       error       noeat recolor=-1
189
  "A-Za-z0-9._:-" bchar
190
  "#"     bchar
191
  ";"     bstring
192
193
# Matched: <tag attr="foo"
194
195
:endstring Attr
196
  *       error       noeat recolor=-1
197
  " \t\r\n"   tag_space_sp
198
  "/"     empty_tag   recolor=-1
199
  ">"     close_tag   recolor=-1
200
201
# This state is just to recolor the final ">" at the end of <tag attr="val">
202
203
:close_tag Tag
204
  *       content     noeat
205
206
# Matched: <?
207
208
:pi_start PIStart
209
  *       pi      noeat recolor=-1
210
211
:pi PIBody
212
  *       pi
213
  "?"     pi2
214
215
:pi2 PIBody
216
  *       pi
217
  ">"     pi_end      recolor=-2
218
219
:pi_end PIEnd
220
  *       content     noeat recolor=-1
221
222
# Matched: <!
223
224
:decl Decl
225
  *       decl        strings
226
  "!--"       comment_start   recolor=-5
227
  "![CDATA["  cdata_start recolor=-10
228
done
229
  "<"     decl_nest
230
  ">"     content
231
232
# We allow one level of <...> nesting within declarations
233
234
:decl_nest Decl
235
  *       decl_nest
236
  ">"     decl
237
238
# Matched: <!--
239
240
:comment_start CommentStart
241
  *       comment     noeat
242
243
:comment CommentBody
244
  *       comment
245
  "-"     comment2
246
247
:comment2 CommentBody
248
  *       comment
249
  "-"     comment3
250
251
:comment3 CommentBody
252
  *       comment_error   noeat recolor=-3
253
  ">"     comment_end recolor=-3
254
255
:comment_end CommentEnd
256
  *       content     noeat recolor=-1
257
258
# For compatibility, the string "--" (double-hyphen) MUST NOT occur within
259
# comments. [http://www.w3.org/TR/REC-xml/ section 2.5]
260
261
:comment_error Error
262
  *       comment
263
  "-"     comment_error
264
  ">"     comment_end recolor=-3
265
266
# Matched: <![CDATA[
267
268
:cdata_start CdataStart
269
  *       cdata       noeat
270
271
:cdata CdataBody
272
  *       cdata
273
  "]"     cdata2
274
275
:cdata2 CdataBody
276
  *       cdata
277
  "]"     cdata3
278
279
:cdata3 CdataBody
280
  *       cdata
281
  ">"     cdata_end   recolor=-3
282
283
:cdata_end CdataEnd
284
  *       content     noeat recolor=-1