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