7
|
1 " Vim syntax file
|
|
2 " Language: HTML
|
|
3 " Maintainer: Claudio Fleiner <claudio@fleiner.com>
|
|
4 " URL: http://www.fleiner.com/vim/syntax/html.vim
|
1125
|
5 " Last Change: 2006 Jun 19
|
7
|
6
|
|
7 " Please check :help html.vim for some comments and a description of the options
|
|
8
|
|
9 " For version 5.x: Clear all syntax items
|
|
10 " For version 6.x: Quit when a syntax file was already loaded
|
|
11 if !exists("main_syntax")
|
|
12 if version < 600
|
|
13 syntax clear
|
|
14 elseif exists("b:current_syntax")
|
|
15 finish
|
|
16 endif
|
|
17 let main_syntax = 'html'
|
|
18 endif
|
|
19
|
|
20 " don't use standard HiLink, it will not work with included syntax files
|
|
21 if version < 508
|
|
22 command! -nargs=+ HtmlHiLink hi link <args>
|
|
23 else
|
|
24 command! -nargs=+ HtmlHiLink hi def link <args>
|
|
25 endif
|
|
26
|
1125
|
27 syntax spell toplevel
|
7
|
28
|
|
29 syn case ignore
|
|
30
|
|
31 " mark illegal characters
|
|
32 syn match htmlError "[<>&]"
|
|
33
|
|
34
|
|
35 " tags
|
|
36 syn region htmlString contained start=+"+ end=+"+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc
|
|
37 syn region htmlString contained start=+'+ end=+'+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc
|
|
38 syn match htmlValue contained "=[\t ]*[^'" \t>][^ \t>]*"hs=s+1 contains=javaScriptExpression,@htmlPreproc
|
829
|
39 syn region htmlEndTag start=+</+ end=+>+ contains=htmlTagN,htmlTagError
|
|
40 syn region htmlTag start=+<[^/]+ end=+>+ contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster
|
7
|
41 syn match htmlTagN contained +<\s*[-a-zA-Z0-9]\++hs=s+1 contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster
|
|
42 syn match htmlTagN contained +</\s*[-a-zA-Z0-9]\++hs=s+2 contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster
|
|
43 syn match htmlTagError contained "[^>]<"ms=s+1
|
|
44
|
|
45
|
|
46 " tag names
|
|
47 syn keyword htmlTagName contained address applet area a base basefont
|
|
48 syn keyword htmlTagName contained big blockquote br caption center
|
|
49 syn keyword htmlTagName contained cite code dd dfn dir div dl dt font
|
|
50 syn keyword htmlTagName contained form hr html img
|
|
51 syn keyword htmlTagName contained input isindex kbd li link map menu
|
|
52 syn keyword htmlTagName contained meta ol option param pre p samp span
|
|
53 syn keyword htmlTagName contained select small strike sub sup
|
|
54 syn keyword htmlTagName contained table td textarea th tr tt ul var xmp
|
|
55 syn match htmlTagName contained "\<\(b\|i\|u\|h[1-6]\|em\|strong\|head\|body\|title\)\>"
|
|
56
|
|
57 " new html 4.0 tags
|
|
58 syn keyword htmlTagName contained abbr acronym bdo button col label
|
|
59 syn keyword htmlTagName contained colgroup del fieldset iframe ins legend
|
|
60 syn keyword htmlTagName contained object optgroup q s tbody tfoot thead
|
|
61
|
|
62 " legal arg names
|
|
63 syn keyword htmlArg contained action
|
|
64 syn keyword htmlArg contained align alink alt archive background bgcolor
|
|
65 syn keyword htmlArg contained border bordercolor cellpadding
|
|
66 syn keyword htmlArg contained cellspacing checked class clear code codebase color
|
|
67 syn keyword htmlArg contained cols colspan content coords enctype face
|
|
68 syn keyword htmlArg contained gutter height hspace id
|
|
69 syn keyword htmlArg contained link lowsrc marginheight
|
|
70 syn keyword htmlArg contained marginwidth maxlength method name prompt
|
|
71 syn keyword htmlArg contained rel rev rows rowspan scrolling selected shape
|
|
72 syn keyword htmlArg contained size src start target text type url
|
|
73 syn keyword htmlArg contained usemap ismap valign value vlink vspace width wrap
|
|
74 syn match htmlArg contained "\<\(http-equiv\|href\|title\)="me=e-1
|
|
75
|
|
76 " Netscape extensions
|
|
77 syn keyword htmlTagName contained frame noframes frameset nobr blink
|
|
78 syn keyword htmlTagName contained layer ilayer nolayer spacer
|
|
79 syn keyword htmlArg contained frameborder noresize pagex pagey above below
|
|
80 syn keyword htmlArg contained left top visibility clip id noshade
|
|
81 syn match htmlArg contained "\<z-index\>"
|
|
82
|
|
83 " Microsoft extensions
|
|
84 syn keyword htmlTagName contained marquee
|
|
85
|
|
86 " html 4.0 arg names
|
|
87 syn match htmlArg contained "\<\(accept-charset\|label\)\>"
|
|
88 syn keyword htmlArg contained abbr accept accesskey axis char charoff charset
|
|
89 syn keyword htmlArg contained cite classid codetype compact data datetime
|
|
90 syn keyword htmlArg contained declare defer dir disabled for frame
|
|
91 syn keyword htmlArg contained headers hreflang lang language longdesc
|
|
92 syn keyword htmlArg contained multiple nohref nowrap object profile readonly
|
|
93 syn keyword htmlArg contained rules scheme scope span standby style
|
|
94 syn keyword htmlArg contained summary tabindex valuetype version
|
|
95
|
|
96 " special characters
|
|
97 syn match htmlSpecialChar "&#\=[0-9A-Za-z]\{1,8};"
|
|
98
|
|
99 " Comments (the real ones or the old netscape ones)
|
|
100 if exists("html_wrong_comments")
|
829
|
101 syn region htmlComment start=+<!--+ end=+--\s*>+
|
7
|
102 else
|
829
|
103 syn region htmlComment start=+<!+ end=+>+ contains=htmlCommentPart,htmlCommentError
|
7
|
104 syn match htmlCommentError contained "[^><!]"
|
|
105 syn region htmlCommentPart contained start=+--+ end=+--\s*+ contains=@htmlPreProc
|
|
106 endif
|
829
|
107 syn region htmlComment start=+<!DOCTYPE+ keepend end=+>+
|
7
|
108
|
|
109 " server-parsed commands
|
|
110 syn region htmlPreProc start=+<!--#+ end=+-->+ contains=htmlPreStmt,htmlPreError,htmlPreAttr
|
|
111 syn match htmlPreStmt contained "<!--#\(config\|echo\|exec\|fsize\|flastmod\|include\|printenv\|set\|if\|elif\|else\|endif\|geoguide\)\>"
|
|
112 syn match htmlPreError contained "<!--#\S*"ms=s+4
|
|
113 syn match htmlPreAttr contained "\w\+=[^"]\S\+" contains=htmlPreProcAttrError,htmlPreProcAttrName
|
|
114 syn region htmlPreAttr contained start=+\w\+="+ skip=+\\\\\|\\"+ end=+"+ contains=htmlPreProcAttrName keepend
|
|
115 syn match htmlPreProcAttrError contained "\w\+="he=e-1
|
|
116 syn match htmlPreProcAttrName contained "\(expr\|errmsg\|sizefmt\|timefmt\|var\|cgi\|cmd\|file\|virtual\|value\)="he=e-1
|
|
117
|
|
118 if !exists("html_no_rendering")
|
|
119 " rendering
|
419
|
120 syn cluster htmlTop contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLink,javaScript,@htmlPreproc
|
7
|
121
|
|
122 syn region htmlBold start="<b\>" end="</b>"me=e-4 contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic
|
|
123 syn region htmlBold start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic
|
|
124 syn region htmlBoldUnderline contained start="<u\>" end="</u>"me=e-4 contains=@htmlTop,htmlBoldUnderlineItalic
|
|
125 syn region htmlBoldItalic contained start="<i\>" end="</i>"me=e-4 contains=@htmlTop,htmlBoldItalicUnderline
|
|
126 syn region htmlBoldItalic contained start="<em\>" end="</em>"me=e-5 contains=@htmlTop,htmlBoldItalicUnderline
|
|
127 syn region htmlBoldUnderlineItalic contained start="<i\>" end="</i>"me=e-4 contains=@htmlTop
|
|
128 syn region htmlBoldUnderlineItalic contained start="<em\>" end="</em>"me=e-5 contains=@htmlTop
|
|
129 syn region htmlBoldItalicUnderline contained start="<u\>" end="</u>"me=e-4 contains=@htmlTop,htmlBoldUnderlineItalic
|
|
130
|
|
131 syn region htmlUnderline start="<u\>" end="</u>"me=e-4 contains=@htmlTop,htmlUnderlineBold,htmlUnderlineItalic
|
|
132 syn region htmlUnderlineBold contained start="<b\>" end="</b>"me=e-4 contains=@htmlTop,htmlUnderlineBoldItalic
|
|
133 syn region htmlUnderlineBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlUnderlineBoldItalic
|
|
134 syn region htmlUnderlineItalic contained start="<i\>" end="</i>"me=e-4 contains=@htmlTop,htmlUnderlineItalicBold
|
|
135 syn region htmlUnderlineItalic contained start="<em\>" end="</em>"me=e-5 contains=@htmlTop,htmlUnderlineItalicBold
|
|
136 syn region htmlUnderlineItalicBold contained start="<b\>" end="</b>"me=e-4 contains=@htmlTop
|
|
137 syn region htmlUnderlineItalicBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop
|
|
138 syn region htmlUnderlineBoldItalic contained start="<i\>" end="</i>"me=e-4 contains=@htmlTop
|
|
139 syn region htmlUnderlineBoldItalic contained start="<em\>" end="</em>"me=e-5 contains=@htmlTop
|
|
140
|
|
141 syn region htmlItalic start="<i\>" end="</i>"me=e-4 contains=@htmlTop,htmlItalicBold,htmlItalicUnderline
|
|
142 syn region htmlItalic start="<em\>" end="</em>"me=e-5 contains=@htmlTop
|
|
143 syn region htmlItalicBold contained start="<b\>" end="</b>"me=e-4 contains=@htmlTop,htmlItalicBoldUnderline
|
|
144 syn region htmlItalicBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlItalicBoldUnderline
|
|
145 syn region htmlItalicBoldUnderline contained start="<u\>" end="</u>"me=e-4 contains=@htmlTop
|
|
146 syn region htmlItalicUnderline contained start="<u\>" end="</u>"me=e-4 contains=@htmlTop,htmlItalicUnderlineBold
|
|
147 syn region htmlItalicUnderlineBold contained start="<b\>" end="</b>"me=e-4 contains=@htmlTop
|
|
148 syn region htmlItalicUnderlineBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop
|
|
149
|
419
|
150 syn region htmlLink start="<a\>\_[^>]*\<href\>" end="</a>"me=e-4 contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,javaScript,@htmlPreproc
|
7
|
151 syn region htmlH1 start="<h1\>" end="</h1>"me=e-5 contains=@htmlTop
|
|
152 syn region htmlH2 start="<h2\>" end="</h2>"me=e-5 contains=@htmlTop
|
|
153 syn region htmlH3 start="<h3\>" end="</h3>"me=e-5 contains=@htmlTop
|
|
154 syn region htmlH4 start="<h4\>" end="</h4>"me=e-5 contains=@htmlTop
|
|
155 syn region htmlH5 start="<h5\>" end="</h5>"me=e-5 contains=@htmlTop
|
|
156 syn region htmlH6 start="<h6\>" end="</h6>"me=e-5 contains=@htmlTop
|
|
157 syn region htmlHead start="<head\>" end="</head>"me=e-7 end="<body\>"me=e-5 end="<h[1-6]\>"me=e-3 contains=htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLink,htmlTitle,javaScript,cssStyle,@htmlPreproc
|
829
|
158 syn region htmlTitle start="<title\>" end="</title>"me=e-8 contains=htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,javaScript,@htmlPreproc
|
7
|
159 endif
|
|
160
|
829
|
161 syn keyword htmlTagName contained noscript
|
7
|
162 syn keyword htmlSpecialTagName contained script style
|
|
163 if main_syntax != 'java' || exists("java_javascript")
|
|
164 " JAVA SCRIPT
|
829
|
165 syn include @htmlJavaScript syntax/javascript.vim
|
7
|
166 unlet b:current_syntax
|
|
167 syn region javaScript start=+<script[^>]*>+ keepend end=+</script>+me=s-1 contains=@htmlJavaScript,htmlCssStyleComment,htmlScriptTag,@htmlPreproc
|
|
168 syn region htmlScriptTag contained start=+<script+ end=+>+ contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
|
|
169 HtmlHiLink htmlScriptTag htmlTag
|
|
170
|
|
171 " html events (i.e. arguments that include javascript commands)
|
|
172 if exists("html_extended_events")
|
829
|
173 syn region htmlEvent contained start=+\<on\a\+\s*=[\t ]*'+ end=+'+ contains=htmlEventSQ
|
|
174 syn region htmlEvent contained start=+\<on\a\+\s*=[\t ]*"+ end=+"+ contains=htmlEventDQ
|
7
|
175 else
|
829
|
176 syn region htmlEvent contained start=+\<on\a\+\s*=[\t ]*'+ end=+'+ keepend contains=htmlEventSQ
|
|
177 syn region htmlEvent contained start=+\<on\a\+\s*=[\t ]*"+ end=+"+ keepend contains=htmlEventDQ
|
7
|
178 endif
|
829
|
179 syn region htmlEventSQ contained start=+'+ms=s+1 end=+'+me=s-1 contains=@htmlJavaScript
|
|
180 syn region htmlEventDQ contained start=+"+ms=s+1 end=+"+me=s-1 contains=@htmlJavaScript
|
7
|
181 HtmlHiLink htmlEventSQ htmlEvent
|
|
182 HtmlHiLink htmlEventDQ htmlEvent
|
|
183
|
|
184 " a javascript expression is used as an arg value
|
|
185 syn region javaScriptExpression contained start=+&{+ keepend end=+};+ contains=@htmlJavaScript,@htmlPreproc
|
|
186 endif
|
|
187
|
|
188 if main_syntax != 'java' || exists("java_vb")
|
|
189 " VB SCRIPT
|
829
|
190 syn include @htmlVbScript syntax/vb.vim
|
7
|
191 unlet b:current_syntax
|
|
192 syn region javaScript start=+<script [^>]*language *=[^>]*vbscript[^>]*>+ keepend end=+</script>+me=s-1 contains=@htmlVbScript,htmlCssStyleComment,htmlScriptTag,@htmlPreproc
|
|
193 endif
|
|
194
|
|
195 syn cluster htmlJavaScript add=@htmlPreproc
|
|
196
|
|
197 if main_syntax != 'java' || exists("java_css")
|
|
198 " embedded style sheets
|
829
|
199 syn keyword htmlArg contained media
|
|
200 syn include @htmlCss syntax/css.vim
|
7
|
201 unlet b:current_syntax
|
|
202 syn region cssStyle start=+<style+ keepend end=+</style>+ contains=@htmlCss,htmlTag,htmlEndTag,htmlCssStyleComment,@htmlPreproc
|
|
203 syn match htmlCssStyleComment contained "\(<!--\|-->\)"
|
|
204 syn region htmlCssDefinition matchgroup=htmlArg start='style="' keepend matchgroup=htmlString end='"' contains=css.*Attr,css.*Prop,cssComment,cssLength,cssColor,cssURL,cssImportant,cssError,cssString,@htmlPreproc
|
|
205 HtmlHiLink htmlStyleArg htmlString
|
|
206 endif
|
|
207
|
|
208 if main_syntax == "html"
|
|
209 " synchronizing (does not always work if a comment includes legal
|
|
210 " html tags, but doing it right would mean to always start
|
|
211 " at the first line, which is too slow)
|
|
212 syn sync match htmlHighlight groupthere NONE "<[/a-zA-Z]"
|
|
213 syn sync match htmlHighlight groupthere javaScript "<script"
|
|
214 syn sync match htmlHighlightSkip "^.*['\"].*$"
|
|
215 syn sync minlines=10
|
|
216 endif
|
|
217
|
|
218 " The default highlighting.
|
|
219 if version >= 508 || !exists("did_html_syn_inits")
|
|
220 if version < 508
|
|
221 let did_html_syn_inits = 1
|
|
222 endif
|
829
|
223 HtmlHiLink htmlTag Function
|
|
224 HtmlHiLink htmlEndTag Identifier
|
|
225 HtmlHiLink htmlArg Type
|
|
226 HtmlHiLink htmlTagName htmlStatement
|
|
227 HtmlHiLink htmlSpecialTagName Exception
|
|
228 HtmlHiLink htmlValue String
|
|
229 HtmlHiLink htmlSpecialChar Special
|
|
230
|
7
|
231 if !exists("html_no_rendering")
|
829
|
232 HtmlHiLink htmlH1 Title
|
|
233 HtmlHiLink htmlH2 htmlH1
|
|
234 HtmlHiLink htmlH3 htmlH2
|
|
235 HtmlHiLink htmlH4 htmlH3
|
|
236 HtmlHiLink htmlH5 htmlH4
|
|
237 HtmlHiLink htmlH6 htmlH5
|
|
238 HtmlHiLink htmlHead PreProc
|
|
239 HtmlHiLink htmlTitle Title
|
|
240 HtmlHiLink htmlBoldItalicUnderline htmlBoldUnderlineItalic
|
|
241 HtmlHiLink htmlUnderlineBold htmlBoldUnderline
|
|
242 HtmlHiLink htmlUnderlineItalicBold htmlBoldUnderlineItalic
|
|
243 HtmlHiLink htmlUnderlineBoldItalic htmlBoldUnderlineItalic
|
|
244 HtmlHiLink htmlItalicUnderline htmlUnderlineItalic
|
|
245 HtmlHiLink htmlItalicBold htmlBoldItalic
|
|
246 HtmlHiLink htmlItalicBoldUnderline htmlBoldUnderlineItalic
|
|
247 HtmlHiLink htmlItalicUnderlineBold htmlBoldUnderlineItalic
|
|
248 HtmlHiLink htmlLink Underlined
|
7
|
249 if !exists("html_my_rendering")
|
829
|
250 hi def htmlBold term=bold cterm=bold gui=bold
|
|
251 hi def htmlBoldUnderline term=bold,underline cterm=bold,underline gui=bold,underline
|
|
252 hi def htmlBoldItalic term=bold,italic cterm=bold,italic gui=bold,italic
|
7
|
253 hi def htmlBoldUnderlineItalic term=bold,italic,underline cterm=bold,italic,underline gui=bold,italic,underline
|
829
|
254 hi def htmlUnderline term=underline cterm=underline gui=underline
|
7
|
255 hi def htmlUnderlineItalic term=italic,underline cterm=italic,underline gui=italic,underline
|
829
|
256 hi def htmlItalic term=italic cterm=italic gui=italic
|
7
|
257 endif
|
|
258 endif
|
829
|
259
|
|
260 HtmlHiLink htmlPreStmt PreProc
|
|
261 HtmlHiLink htmlPreError Error
|
|
262 HtmlHiLink htmlPreProc PreProc
|
|
263 HtmlHiLink htmlPreAttr String
|
7
|
264 HtmlHiLink htmlPreProcAttrName PreProc
|
|
265 HtmlHiLink htmlPreProcAttrError Error
|
829
|
266 HtmlHiLink htmlSpecial Special
|
|
267 HtmlHiLink htmlSpecialChar Special
|
|
268 HtmlHiLink htmlString String
|
|
269 HtmlHiLink htmlStatement Statement
|
|
270 HtmlHiLink htmlComment Comment
|
|
271 HtmlHiLink htmlCommentPart Comment
|
|
272 HtmlHiLink htmlValue String
|
|
273 HtmlHiLink htmlCommentError htmlError
|
|
274 HtmlHiLink htmlTagError htmlError
|
|
275 HtmlHiLink htmlEvent javaScript
|
|
276 HtmlHiLink htmlError Error
|
|
277
|
|
278 HtmlHiLink javaScript Special
|
7
|
279 HtmlHiLink javaScriptExpression javaScript
|
|
280 HtmlHiLink htmlCssStyleComment Comment
|
829
|
281 HtmlHiLink htmlCssDefinition Special
|
7
|
282 endif
|
|
283
|
|
284 delcommand HtmlHiLink
|
|
285
|
|
286 let b:current_syntax = "html"
|
|
287
|
|
288 if main_syntax == 'html'
|
|
289 unlet main_syntax
|
|
290 endif
|
|
291
|
|
292 " vim: ts=8
|