All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " mediawiki.vim (formerly named Wikipedia.vim)
4 " Language: MediaWiki, http://www.mediawiki.org/
5 " Maintainer: This syntax file needs a maintainer in order to ship
6 " with Vim. Please contact [[User:Unforgettableid]] if you want
8 " Home: http://en.wikipedia.org/wiki/Wikipedia:Text_editor_support#Vim
9 " Last Change: 2011 Sep 19
10 " Credits: [[User:Aepd87]], [[User:Danny373]], [[User:Ingo Karkat]], et al.
12 " Published on Wikipedia in 2003-04 and declared authorless.
14 " Based on the HTML syntax file. Probably too closely based, in fact.
15 " There may well be name collisions everywhere, but ignorance is bliss,
18 " To do: plug-in support for downloading and uploading to the server.
20 if !exists("main_syntax")
23 elseif exists("b:current_syntax")
26 let main_syntax = "html"
34 " Mark illegal characters
35 sy match htmlError "[<>&]"
38 sy region htmlString contained start=+"+ end=+"+ contains=htmlSpecialChar,@htmlPreproc
39 sy region htmlString contained start=+'+ end=+'+ contains=htmlSpecialChar,@htmlPreproc
40 sy match htmlValue contained "=[\t ]*[^'" \t>][^ \t>]*"hs=s+1 contains=@htmlPreproc
41 sy region htmlEndTag start=+</+ end=+>+ contains=htmlTagN,htmlTagError
42 sy region htmlTag start=+<[^/]+ end=+>+ contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster
43 sy match htmlTagN contained +<\s*[-a-zA-Z0-9]\++hs=s+1 contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster
44 sy match htmlTagN contained +</\s*[-a-zA-Z0-9]\++hs=s+2 contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster
45 sy match htmlTagError contained "[^>]<"ms=s+1
47 " Allowed HTML tag names
48 sy keyword htmlTagName contained big blockquote br caption center cite code
49 sy keyword htmlTagName contained dd del div dl dt font hr ins li
50 sy keyword htmlTagName contained ol p pre rb rp rt ruby s small span strike sub
51 sy keyword htmlTagName contained sup table td th tr tt ul var
52 sy match htmlTagName contained "\<\(b\|i\|u\|h[1-6]\|em\|strong\)\>"
53 " Allowed Wiki tag names
54 sy keyword htmlTagName contained math nowiki references source syntaxhighlight
57 sy keyword htmlArg contained align lang dir width height nowrap bgcolor clear
58 sy keyword htmlArg contained noshade cite datetime size face color type start
59 sy keyword htmlArg contained value compact summary border frame rules
60 sy keyword htmlArg contained cellspacing cellpadding valign char charoff
61 sy keyword htmlArg contained colgroup col span abbr axis headers scope rowspan
62 sy keyword htmlArg contained colspan id class name style title
65 sy match htmlSpecialChar "&#\=[0-9A-Za-z]\{1,8};"
68 sy region htmlComment start=+<!+ end=+>+ contains=htmlCommentPart,htmlCommentError
69 sy match htmlCommentError contained "[^><!]"
70 sy region htmlCommentPart contained start=+--+ end=+--\s*+ contains=@htmlPreProc
71 sy region htmlComment start=+<!DOCTYPE+ keepend end=+>+
73 if !exists("html_no_rendering")
74 sy cluster htmlTop contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLink,@htmlPreproc
76 sy region htmlBold start="<b\>" end="</b>"me=e-4 contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic
77 sy region htmlBold start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic
78 sy region htmlBoldUnderline contained start="<u\>" end="</u>"me=e-4 contains=@htmlTop,htmlBoldUnderlineItalic
79 sy region htmlBoldItalic contained start="<i\>" end="</i>"me=e-4 contains=@htmlTop,htmlBoldItalicUnderline
80 sy region htmlBoldItalic contained start="<em\>" end="</em>"me=e-5 contains=@htmlTop,htmlBoldItalicUnderline
81 sy region htmlBoldUnderlineItalic contained start="<i\>" end="</i>"me=e-4 contains=@htmlTop
82 sy region htmlBoldUnderlineItalic contained start="<em\>" end="</em>"me=e-5 contains=@htmlTop
83 sy region htmlBoldItalicUnderline contained start="<u\>" end="</u>"me=e-4 contains=@htmlTop,htmlBoldUnderlineItalic
85 sy region htmlUnderline start="<u\>" end="</u>"me=e-4 contains=@htmlTop,htmlUnderlineBold,htmlUnderlineItalic
86 sy region htmlUnderlineBold contained start="<b\>" end="</b>"me=e-4 contains=@htmlTop,htmlUnderlineBoldItalic
87 sy region htmlUnderlineBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlUnderlineBoldItalic
88 sy region htmlUnderlineItalic contained start="<i\>" end="</i>"me=e-4 contains=@htmlTop,htmlUnderlineItalicBold
89 sy region htmlUnderlineItalic contained start="<em\>" end="</em>"me=e-5 contains=@htmlTop,htmlUnderlineItalicBold
90 sy region htmlUnderlineItalicBold contained start="<b\>" end="</b>"me=e-4 contains=@htmlTop
91 sy region htmlUnderlineItalicBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop
92 sy region htmlUnderlineBoldItalic contained start="<i\>" end="</i>"me=e-4 contains=@htmlTop
93 sy region htmlUnderlineBoldItalic contained start="<em\>" end="</em>"me=e-5 contains=@htmlTop
95 sy region htmlItalic start="<i\>" end="</i>"me=e-4 contains=@htmlTop,htmlItalicBold,htmlItalicUnderline
96 sy region htmlItalic start="<em\>" end="</em>"me=e-5 contains=@htmlTop
97 sy region htmlItalicBold contained start="<b\>" end="</b>"me=e-4 contains=@htmlTop,htmlItalicBoldUnderline
98 sy region htmlItalicBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlItalicBoldUnderline
99 sy region htmlItalicBoldUnderline contained start="<u\>" end="</u>"me=e-4 contains=@htmlTop
100 sy region htmlItalicUnderline contained start="<u\>" end="</u>"me=e-4 contains=@htmlTop,htmlItalicUnderlineBold
101 sy region htmlItalicUnderlineBold contained start="<b\>" end="</b>"me=e-4 contains=@htmlTop
102 sy region htmlItalicUnderlineBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop
104 sy region htmlH1 start="<h1\>" end="</h1>"me=e-5 contains=@htmlTop
105 sy region htmlH2 start="<h2\>" end="</h2>"me=e-5 contains=@htmlTop
106 sy region htmlH3 start="<h3\>" end="</h3>"me=e-5 contains=@htmlTop
107 sy region htmlH4 start="<h4\>" end="</h4>"me=e-5 contains=@htmlTop
108 sy region htmlH5 start="<h5\>" end="</h5>"me=e-5 contains=@htmlTop
109 sy region htmlH6 start="<h6\>" end="</h6>"me=e-5 contains=@htmlTop
113 " No htmlTop and wikiPre inside HTML preformatted areas, because
114 " MediaWiki renders everything in there literally (HTML tags and
115 " entities, too): <pre> tags work as the combination of <nowiki> and
116 " the standard HTML <pre> tag: the content will preformatted, and it
117 " will not be parsed, but shown as in the wikitext source.
119 " With wikiPre, indented lines would be rendered differently from
121 sy match htmlPreTag /<pre>/ contains=htmlTag
122 sy match htmlPreEndTag /<\/pre>/ contains=htmlEndTag
123 sy match wikiNowikiTag /<nowiki>/ contains=htmlTag
124 sy match wikiNowikiEndTag /<\/nowiki>/ contains=htmlEndTag
125 sy match wikiSourceTag /<source\s\+[^>]\+>/ contains=htmlTag
126 sy match wikiSourceEndTag /<\/source>/ contains=htmlEndTag
127 sy match wikiSyntaxHLTag /<syntaxhighlight\s\+[^>]\+>/ contains=htmlTag
128 sy match wikiSyntaxHLEndTag /<\/syntaxhighlight>/ contains=htmlEndTag
130 " Note: Cannot use 'start="<pre>"rs=e', so still have the <pre> tag
131 " highlighted correctly via separate sy-match. Unfortunately, this will
132 " also highlight <pre> tags inside the preformatted region.
133 sy region htmlPre start="<pre>" end="<\/pre>"me=e-6 contains=htmlPreTag
134 sy region wikiNowiki start="<nowiki>" end="<\/nowiki>"me=e-9 contains=wikiNowikiTag
135 sy region wikiSource start="<source\s\+[^>]\+>" keepend end="<\/source>"me=e-9 contains=wikiSourceTag
136 sy region wikiSyntaxHL start="<syntaxhighlight\s\+[^>]\+>" keepend end="<\/syntaxhighlight>"me=e-18 contains=wikiSyntaxHLTag
138 sy include @TeX syntax/tex.vim
139 sy region wikiTeX matchgroup=htmlTag start="<math>" end="<\/math>" contains=@texMathZoneGroup,wikiNowiki,wikiNowikiEndTag
140 sy region wikiRef matchgroup=htmlTag start="<ref>" end="<\/ref>" contains=wikiNowiki,wikiNowikiEndTag
142 sy cluster wikiTop contains=@Spell,wikiLink,wikiNowiki,wikiNowikiEndTag
144 sy region wikiItalic start=+'\@<!'''\@!+ end=+''+ oneline contains=@wikiTop,wikiItalicBold
145 sy region wikiBold start=+'''+ end=+'''+ oneline contains=@wikiTop,wikiBoldItalic
146 sy region wikiBoldAndItalic start=+'''''+ end=+'''''+ oneline contains=@wikiTop
148 sy region wikiBoldItalic contained start=+'\@<!'''\@!+ end=+''+ oneline contains=@wikiTop
149 sy region wikiItalicBold contained start=+'''+ end=+'''+ oneline contains=@wikiTop
151 sy region wikiH1 start="^=" end="=" oneline contains=@wikiTop
152 sy region wikiH2 start="^==" end="==" oneline contains=@wikiTop
153 sy region wikiH3 start="^===" end="===" oneline contains=@wikiTop
154 sy region wikiH4 start="^====" end="====" oneline contains=@wikiTop
155 sy region wikiH5 start="^=====" end="=====" oneline contains=@wikiTop
156 sy region wikiH6 start="^======" end="======" oneline contains=@wikiTop
158 sy region wikiLink start="\[\[" end="\]\]\(s\|'s\|es\|ing\|\)" oneline contains=wikiLink,wikiNowiki,wikiNowikiEndTag
160 sy region wikiLink start="\[http:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
161 sy region wikiLink start="\[https:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
162 sy region wikiLink start="\[ftp:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
163 sy region wikiLink start="\[gopher:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
164 sy region wikiLink start="\[news:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
165 sy region wikiLink start="\[mailto:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
167 sy region wikiTemplate start="{{" end="}}" contains=wikiNowiki,wikiNowikiEndTag
169 sy match wikiParaFormatChar /^[\:|\*|;|#]\+/
170 sy match wikiParaFormatChar /^-----*/
171 sy match wikiPre /^\ .*$/ contains=wikiNowiki,wikiNowikiEndTag
177 command! -nargs=+ HtmlHiLink hi link <args>
179 command! -nargs=+ HtmlHiLink hi def link <args>
182 if version >= 508 || !exists("did_html_syn_inits")
183 HtmlHiLink htmlTag Function
184 HtmlHiLink htmlEndTag Identifier
185 HtmlHiLink htmlArg Type
186 HtmlHiLink htmlTagName htmlStatement
187 HtmlHiLink htmlSpecialTagName Exception
188 HtmlHiLink htmlValue String
189 HtmlHiLink htmlSpecialChar Special
191 if !exists("html_no_rendering")
192 HtmlHiLink htmlTitle Title
193 HtmlHiLink htmlH1 htmlTitle
194 HtmlHiLink htmlH2 htmlTitle
195 HtmlHiLink htmlH3 htmlTitle
196 HtmlHiLink htmlH4 htmlTitle
197 HtmlHiLink htmlH5 htmlTitle
198 HtmlHiLink htmlH6 htmlTitle
200 HtmlHiLink htmlPreProc PreProc
201 HtmlHiLink htmlHead htmlPreProc
202 HtmlHiLink htmlPreProcAttrName htmlPreProc
203 HtmlHiLink htmlPreStmt htmlPreProc
205 HtmlHiLink htmlSpecial Special
206 HtmlHiLink htmlCssDefinition htmlSpecial
207 HtmlHiLink htmlEvent htmlSpecial
208 HtmlHiLink htmlSpecialChar htmlSpecial
210 HtmlHiLink htmlComment Comment
211 HtmlHiLink htmlCommentPart htmlComment
212 HtmlHiLink htmlCssStyleComment htmlComment
214 HtmlHiLink htmlString String
215 HtmlHiLink htmlPreAttr htmlString
216 HtmlHiLink htmlValue htmlString
218 HtmlHiLink htmlError Error
219 HtmlHiLink htmlBadArg htmlError
220 HtmlHiLink htmlBadTag htmlError
221 HtmlHiLink htmlCommentError htmlError
222 HtmlHiLink htmlPreError htmlError
223 HtmlHiLink htmlPreProcAttrError htmlError
224 HtmlHiLink htmlTagError htmlError
226 HtmlHiLink htmlStatement Statement
228 HtmlHiLink htmlConstant Constant
230 HtmlHiLink htmlBoldItalicUnderline htmlBoldUnderlineItalic
231 HtmlHiLink htmlUnderlineItalicBold htmlBoldUnderlineItalic
232 HtmlHiLink htmlUnderlineBoldItalic htmlBoldUnderlineItalic
233 HtmlHiLink htmlItalicBoldUnderline htmlBoldUnderlineItalic
234 HtmlHiLink htmlItalicUnderlineBold htmlBoldUnderlineItalic
236 HtmlHiLink htmlItalicBold htmlBoldItalic
237 HtmlHiLink htmlItalicUnderline htmlUnderlineItalic
238 HtmlHiLink htmlUnderlineBold htmlBoldUnderline
240 HtmlHiLink htmlLink Underlined
242 if !exists("html_my_rendering")
243 hi def htmlBold term=bold cterm=bold gui=bold
244 hi def htmlBoldUnderline term=bold,underline cterm=bold,underline gui=bold,underline
245 hi def htmlBoldItalic term=bold,italic cterm=bold,italic gui=bold,italic
246 hi def htmlBoldUnderlineItalic term=bold,italic,underline cterm=bold,italic,underline gui=bold,italic,underline
247 hi def htmlUnderline term=underline cterm=underline gui=underline
248 hi def htmlUnderlineItalic term=italic,underline cterm=italic,underline gui=italic,underline
249 hi def htmlItalic term=italic cterm=italic gui=italic
252 endif " !exists("html_no_rendering")
255 let did_html_syn_inits = 1
258 endif " version >= 508 || !exists("did_html_syn_inits")
262 HtmlHiLink wikiItalic htmlItalic
263 HtmlHiLink wikiBold htmlBold
264 HtmlHiLink wikiBoldItalic htmlBoldItalic
265 HtmlHiLink wikiItalicBold htmlBoldItalic
266 HtmlHiLink wikiBoldAndItalic htmlBoldItalic
268 HtmlHiLink wikiH1 htmlTitle
269 HtmlHiLink wikiH2 htmlTitle
270 HtmlHiLink wikiH3 htmlTitle
271 HtmlHiLink wikiH4 htmlTitle
272 HtmlHiLink wikiH5 htmlTitle
273 HtmlHiLink wikiH6 htmlTitle
275 HtmlHiLink wikiLink htmlLink
276 HtmlHiLink wikiTemplate htmlSpecial
277 HtmlHiLink wikiParaFormatChar htmlSpecial
278 HtmlHiLink wikiPre htmlConstant
279 HtmlHiLink wikiRef htmlComment
281 HtmlHiLink wikiSource wikiPre
282 HtmlHiLink wikiSyntaxHL wikiPre
285 let b:current_syntax = "html"
287 delcommand HtmlHiLink
289 if main_syntax == "html"
293 " vim: set et sts=2 sw=2: