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