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