2
;; Copyright (c) 2002 by The XFree86 Project, Inc.
4
;; Permission is hereby granted, free of charge, to any person obtaining a
5
;; copy of this software and associated documentation files (the "Software"),
6
;; to deal in the Software without restriction, including without limitation
7
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
;; and/or sell copies of the Software, and to permit persons to whom the
9
;; Software is furnished to do so, subject to the following conditions:
11
;; The above copyright notice and this permission notice shall be included in
12
;; all copies or substantial portions of the Software.
14
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
;; Except as contained in this notice, the name of the XFree86 Project shall
23
;; not be used in advertising or otherwise to promote the sale, use or other
24
;; dealings in this Software without prior written authorization from the
27
;; Author: Paulo C�sar Pereira de Andrade
30
;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/html.lsp,v 1.3 2002/10/06 17:11:48 paulo Exp $
37
This is not a validation tool for html.
39
It is possible to, using macros generate all combinations of text attributes,
40
to properly handle <b>...<i>...</i>...</b> etc, as well as generating macros
41
to automatically closing tags, but for now this file was built to work as an
42
experience with the syntax highlight code.
45
(defsynprop *prop-html-default*
47
:font "-*-lucida-medium-r-*-*-14-*-*-*-*-*-*-1"
50
(defsynprop *prop-html-bold*
52
:font "-*-lucida-bold-r-*-*-14-*-*-*-*-*-*-1"
55
(defsynprop *prop-html-italic*
57
:font "-*-lucida-medium-i-*-*-14-*-*-*-*-*-*-1"
60
(defsynprop *prop-html-pre*
62
:font "-*-courier-medium-r-*-*-14-*-*-*-*-*-*-1"
65
(defsynprop *prop-html-link*
67
:font "-*-lucida-medium-r-*-*-14-*-*-*-*-*-*-1"
71
(defsynprop *prop-html-small*
73
:font "-*-lucida-medium-r-*-*-10-*-*-*-*-*-*-1"
76
(defsynprop *prop-html-big*
78
:font "-*-lucida-medium-r-*-*-20-*-*-*-*-*-*-1"
81
(defsynprop *prop-html-name*
83
:font "-*-lucida-bold-r-*-*-14-*-*-*-*-*-*-1"
85
:background "rgb:e/f/e")
87
(defsynprop *prop-html-h1*
89
:font "-*-lucida-bold-r-*-*-20-*-*-*-*-*-*-1"
92
(defsynprop *prop-html-h2*
94
:font "-*-lucida-bold-r-*-*-17-*-*-*-*-*-*-1"
97
(defsynprop *prop-html-h4*
99
:font "-*-lucida-bold-r-*-*-12-*-*-*-*-*-*-1"
100
:foreground "Gray15")
102
(defsynprop *prop-html-h5*
104
:font "-*-lucida-bold-r-*-*-10-*-*-*-*-*-*-1"
105
:foreground "Gray15")
107
(defsynprop *prop-html-li*
109
:font "-*-lucida-bold-r-*-*-8-*-*-*-*-*-*-1"
110
:foreground "rgb:0/5/0"
113
(defsynprop *prop-html-hr*
115
:font "-*-courier-bold-r-*-*-12-*-*-*-*-*-*-1"
116
:foreground "rgb:0/5/0"
119
(defsynprop *prop-html-title*
121
:font "-*-lucida-medium-r-*-*-14-*-*-*-*-*-*-1"
125
(defsynprop *prop-html-tag*
127
:font "-*-courier-medium-r-*-*-10-*-*-*-*-*-*-1"
128
:foreground "green4")
130
(defsynprop *prop-html-string*
132
:font "-*-lucida-medium-r-*-*-10-*-*-*-*-*-*-1"
133
:foreground "RoyalBlue2")
135
(defsynprop *prop-html-comment*
137
:font "-*-courier-medium-o-*-*-10-*-*-*-*-*-*-1"
138
:foreground "SlateBlue3")
140
(defsynprop *prop-html-entity*
142
:font "-*-lucida-medium-r-*-*-12-*-*-*-*-*-*-1"
145
(defsynprop *prop-html-unknown*
147
:font "-*-courier-bold-r-*-*-10-*-*-*-*-*-*-1"
151
(defmacro html-syntoken (name)
152
`(syntoken (string-concat "<" ,name "\\>")
153
:icase t :contained t
154
:begin (intern (string-concat ,name "$") 'keyword)))
155
(defmacro html-syntable (name property)
157
((label (intern (string-concat ,name "$") 'keyword))
158
(nested-label (intern (string (gensym)) 'keyword)))
159
(syntable label *prop-html-tag* nil
160
(synaugment :generic-tag)
161
(syntoken ">" :nospec t :property *prop-html-tag* :begin nested-label)
162
(syntable nested-label ,property nil
163
(syntoken (string-concat "</" ,name ">")
164
:icase t :nospec t :property *prop-html-tag* :switch -2)
165
(syntoken (string-concat "</" ,name "\\s*$")
166
:icase t :contained t :begin :continued-end-tag)
167
(synaugment :main)))))
170
(defsyntax *html-mode* :main *prop-html-default* nil nil
171
(syntoken "<!--" :nospec t :contained t :begin :comment)
172
(syntable :comment *prop-html-comment* nil
173
(syntoken "-->" :nospec t :switch -1))
174
(syntoken "&([a-zA-Z0-9_.-]+|#\\x\\x?);?" :property *prop-html-entity*)
175
(syntoken "<li>" :nospec t :icase t :property *prop-html-li*)
176
(syntoken "<hr>" :nospec t :icase t :property *prop-html-hr*)
178
(syntoken "<img\\>" :icase t :contained t :begin :tag)
179
(syntoken "<(p|br)>" :icase t :property *prop-html-tag*)
181
;; If in the toplevel, unbalanced!
182
;; XXX When adding new nested tables, don't forget to update this pattern.
186
"b|strong|i|em|address|pre|code|tt|small|big|a|span|div|"
187
"h1|h2|h3|h4|h5|title|font|ol|ul|dl|dt|dd|menu"
189
:icase t :property *prop-html-unknown* :begin :unbalanced)
190
(syntable :unbalanced *prop-html-unknown* nil
191
(syntoken ">" :nospec t :switch :main)
192
(synaugment :generic-tag)
195
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
196
;; XXX ONLY add a rule for "html", "head" and "body" if you want to do a
197
;; more complete check for common errors. If you add those rules, it will
198
;; reparse the entire file at every character typed (unless there are
199
;; errors in which case the parser resets the state).
200
;; For visualization only that would be OK...
201
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||#
204
(html-syntable "b" *prop-html-bold*)
205
(html-syntoken "strong")
206
(html-syntable "strong" *prop-html-bold*)
209
(html-syntable "i" *prop-html-italic*)
211
(html-syntable "em" *prop-html-italic*)
212
(html-syntoken "address")
213
(html-syntable "address" *prop-html-italic*)
215
(html-syntoken "pre")
216
(html-syntable "pre" *prop-html-pre*)
217
(html-syntoken "code")
218
(html-syntable "code" *prop-html-pre*)
220
(html-syntable "tt" *prop-html-pre*)
222
(html-syntoken "small")
223
(html-syntable "small" *prop-html-small*)
225
(html-syntoken "big")
226
(html-syntable "big" *prop-html-big*)
228
;; Cannot hack html-syntoken and html-syntable to handle this,
229
;; as the option to <a may be in the next line.
230
(syntoken "<a\\>" :icase t :contained t :begin :a)
231
(syntable :a *prop-html-tag* nil
233
(syntoken "\\<href\\>" :icase t :begin :a-href)
234
(syntoken "\\<name\\>" :icase t :begin :a-name)
235
(syntoken "<" :nospec t :property *prop-html-unknown* :switch -2)
236
(synaugment :generic-tag)
237
(syntoken ">" :nospec t :begin :a-generic-text)
238
(syntable :a-href *prop-html-tag* nil
239
(syntoken ">" :nospec t :begin :a-href-text)
240
(synaugment :generic-tag)
241
(syntable :a-href-text *prop-html-link* nil
243
:icase t :nospec t :property *prop-html-tag* :switch -3)
244
(syntoken "</a\\s*$" :icase t :begin :continued-nested-end-tag)
248
(syntable :a-name *prop-html-tag* nil
249
(syntoken ">" :nospec t :begin :a-name-text)
250
(synaugment :generic-tag)
251
(syntable :a-name-text *prop-html-name* nil
253
:icase t :nospec t :property *prop-html-tag* :switch -3)
254
(syntoken "</a\\s*$" :icase t :begin :continued-nested-end-tag)
258
(syntable :a-generic-text nil nil
260
:icase t :nospec t :property *prop-html-tag* :switch -2)
261
(syntoken "<a/\\s$" :icase t :begin :continued-end-tag)
266
;; Do nothing, just check start/end tags
268
(html-syntable "ol" nil)
270
(html-syntable "ul" nil)
272
(html-syntable "dl" nil)
273
;; Maybe <dt> and <dd> should be in a special table, to not require
275
;; XXX Maybe should also add a table for <p>.
277
(html-syntable "dt" nil)
279
(html-syntable "dd" nil)
281
(html-syntoken "span")
282
(html-syntable "span" nil)
283
(html-syntoken "div")
284
(html-syntable "div" nil)
285
(html-syntoken "menu")
286
(html-syntable "menu" nil)
289
(html-syntable "h1" *prop-html-h1*)
291
(html-syntable "h2" *prop-html-h2*)
293
(html-syntable "h3" *prop-html-bold*)
295
(html-syntable "h4" *prop-html-h4*)
297
(html-syntable "h5" *prop-html-h5*)
298
(html-syntoken "title")
299
(html-syntable "title" *prop-html-title*)
301
(html-syntoken "font")
302
(html-syntable "font" *prop-control*)
304
(syntoken "<" :nospec t :contained t :begin :tag)
305
(syntable :generic-tag *prop-html-tag* nil
306
(syntoken "\"" :nospec t :contained t :begin :string)
307
(syntoken "<" :nospec t :property *prop-html-unknown*)
309
(syntable :tag *prop-html-tag* nil
310
(syntoken ">" :nospec t :switch -1)
311
(synaugment :generic-tag)
313
;; Tag ended in a newline, common practice...
314
(syntable :continued-end-tag *prop-html-tag* nil
315
(syntoken ">" :nospec t :switch -3)
316
(synaugment :generic-tag)
318
(syntable :continued-nested-end-tag *prop-html-tag* nil
319
(syntoken ">" :nospec t :switch -4)
320
(synaugment :generic-tag)
323
(syntable :string *prop-html-string* nil
325
(syntoken "\"" :nospec t :switch -1)