robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Christian Clasonvim-patch:9.1.0592: runtime: filetype: Mediawiki files are not recognized61ea466591

master
15.9 KiB292 linesraw
1" mediawiki.vim (formerly named Wikipedia.vim)
2"
3" Vim syntax file
4" Language: MediaWiki
5" Maintainer: Avid Seeker <avidseeker7@protonmail.com>
6" Home: http://en.wikipedia.org/wiki/Wikipedia:Text_editor_support#Vim
7" Last Change: 2024 Jul 14
8" Credits: [[User:Unforgettableid]] [[User:Aepd87]], [[User:Danny373]], [[User:Ingo Karkat]], et al.
9"
10" Published on Wikipedia in 2003-04 and declared authorless.
11"
12" Based on the HTML syntax file. Probably too closely based, in fact.
13" There may well be name collisions everywhere, but ignorance is bliss,
14" so they say.
15"
16
17if exists("b:current_syntax")
18  finish
19endif
20
21syntax case ignore
22syntax spell toplevel
23
24" Mark illegal characters
25sy match htmlError "[<>&]"
26
27" Tags
28sy region  htmlString   contained start=+"+                        end=+"+ contains=htmlSpecialChar,@htmlPreproc
29sy region  htmlString   contained start=+'+                        end=+'+ contains=htmlSpecialChar,@htmlPreproc
30sy match   htmlValue    contained "=[\t ]*[^'" \t>][^ \t>]*"hs=s+1         contains=@htmlPreproc
31sy region  htmlEndTag             start=+</+                       end=+>+ contains=htmlTagN,htmlTagError
32sy region  htmlTag                start=+<[^/]+                    end=+>+ contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster
33sy match   htmlTagN     contained +<\s*[-a-zA-Z0-9]\++hs=s+1               contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster
34sy match   htmlTagN     contained +</\s*[-a-zA-Z0-9]\++hs=s+2              contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster
35sy match   htmlTagError contained "[^>]<"ms=s+1
36
37" Allowed HTML tag names
38sy keyword htmlTagName contained big blockquote br caption center cite code
39sy keyword htmlTagName contained dd del div dl dt font hr ins li
40sy keyword htmlTagName contained ol p pre rb rp rt ruby s small span strike sub
41sy keyword htmlTagName contained sup table td th tr tt ul var
42sy match   htmlTagName contained "\<\(b\|i\|u\|h[1-6]\|em\|strong\)\>"
43" Allowed Wiki tag names
44sy keyword htmlTagName contained math nowiki references source syntaxhighlight
45
46" Allowed arg names
47sy keyword htmlArg contained align lang dir width height nowrap bgcolor clear
48sy keyword htmlArg contained noshade cite datetime size face color type start
49sy keyword htmlArg contained value compact summary border frame rules
50sy keyword htmlArg contained cellspacing cellpadding valign char charoff
51sy keyword htmlArg contained colgroup col span abbr axis headers scope rowspan
52sy keyword htmlArg contained colspan id class name style title
53
54" Special characters
55sy match htmlSpecialChar "&#\=[0-9A-Za-z]\{1,8};"
56
57" Comments
58sy region htmlComment                start=+<!+                end=+>+     contains=htmlCommentPart,htmlCommentError
59sy match  htmlCommentError contained "[^><!]"
60sy region htmlCommentPart  contained start=+--+                end=+--\s*+ contains=@htmlPreProc
61sy region htmlComment                start=+<!DOCTYPE+ keepend end=+>+
62
63if !exists("html_no_rendering")
64  sy cluster htmlTop contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLink,@htmlPreproc
65
66  sy region htmlBold                          start="<b\>"      end="</b>"me=e-4      contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic
67  sy region htmlBold                          start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic
68  sy region htmlBoldUnderline       contained start="<u\>"      end="</u>"me=e-4      contains=@htmlTop,htmlBoldUnderlineItalic
69  sy region htmlBoldItalic          contained start="<i\>"      end="</i>"me=e-4      contains=@htmlTop,htmlBoldItalicUnderline
70  sy region htmlBoldItalic          contained start="<em\>"     end="</em>"me=e-5     contains=@htmlTop,htmlBoldItalicUnderline
71  sy region htmlBoldUnderlineItalic contained start="<i\>"      end="</i>"me=e-4      contains=@htmlTop
72  sy region htmlBoldUnderlineItalic contained start="<em\>"     end="</em>"me=e-5     contains=@htmlTop
73  sy region htmlBoldItalicUnderline contained start="<u\>"      end="</u>"me=e-4      contains=@htmlTop,htmlBoldUnderlineItalic
74
75  sy region htmlUnderline                     start="<u\>"      end="</u>"me=e-4      contains=@htmlTop,htmlUnderlineBold,htmlUnderlineItalic
76  sy region htmlUnderlineBold       contained start="<b\>"      end="</b>"me=e-4      contains=@htmlTop,htmlUnderlineBoldItalic
77  sy region htmlUnderlineBold       contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlUnderlineBoldItalic
78  sy region htmlUnderlineItalic     contained start="<i\>"      end="</i>"me=e-4      contains=@htmlTop,htmlUnderlineItalicBold
79  sy region htmlUnderlineItalic     contained start="<em\>"     end="</em>"me=e-5     contains=@htmlTop,htmlUnderlineItalicBold
80  sy region htmlUnderlineItalicBold contained start="<b\>"      end="</b>"me=e-4      contains=@htmlTop
81  sy region htmlUnderlineItalicBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop
82  sy region htmlUnderlineBoldItalic contained start="<i\>"      end="</i>"me=e-4      contains=@htmlTop
83  sy region htmlUnderlineBoldItalic contained start="<em\>"     end="</em>"me=e-5     contains=@htmlTop
84
85  sy region htmlItalic                        start="<i\>"      end="</i>"me=e-4      contains=@htmlTop,htmlItalicBold,htmlItalicUnderline
86  sy region htmlItalic                        start="<em\>"     end="</em>"me=e-5     contains=@htmlTop
87  sy region htmlItalicBold          contained start="<b\>"      end="</b>"me=e-4      contains=@htmlTop,htmlItalicBoldUnderline
88  sy region htmlItalicBold          contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlItalicBoldUnderline
89  sy region htmlItalicBoldUnderline contained start="<u\>"      end="</u>"me=e-4      contains=@htmlTop
90  sy region htmlItalicUnderline     contained start="<u\>"      end="</u>"me=e-4      contains=@htmlTop,htmlItalicUnderlineBold
91  sy region htmlItalicUnderlineBold contained start="<b\>"      end="</b>"me=e-4      contains=@htmlTop
92  sy region htmlItalicUnderlineBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop
93
94  sy region htmlH1    start="<h1\>"    end="</h1>"me=e-5    contains=@htmlTop
95  sy region htmlH2    start="<h2\>"    end="</h2>"me=e-5    contains=@htmlTop
96  sy region htmlH3    start="<h3\>"    end="</h3>"me=e-5    contains=@htmlTop
97  sy region htmlH4    start="<h4\>"    end="</h4>"me=e-5    contains=@htmlTop
98  sy region htmlH5    start="<h5\>"    end="</h5>"me=e-5    contains=@htmlTop
99  sy region htmlH6    start="<h6\>"    end="</h6>"me=e-5    contains=@htmlTop
100endif
101
102
103" No htmlTop and wikiPre inside HTML preformatted areas, because
104" MediaWiki renders everything in there literally (HTML tags and
105" entities, too): <pre> tags work as the combination of <nowiki> and
106" the standard HTML <pre> tag: the content will preformatted, and it
107" will not be parsed, but shown as in the wikitext source.
108"
109" With wikiPre, indented lines would be rendered differently from
110" unindented lines.
111sy match htmlPreTag       /<pre\>[^>]*>/         contains=htmlTag
112sy match htmlPreEndTag    /<\/pre>/       contains=htmlEndTag
113sy match wikiNowikiTag    /<nowiki>/      contains=htmlTag
114sy match wikiNowikiEndTag /<\/nowiki>/    contains=htmlEndTag
115sy match wikiSourceTag    /<source\s\+[^>]\+>/ contains=htmlTag
116sy match wikiSourceEndTag /<\/source>/    contains=htmlEndTag
117sy match wikiSyntaxHLTag    /<syntaxhighlight\s\+[^>]\+>/ contains=htmlTag
118sy match wikiSyntaxHLEndTag /<\/syntaxhighlight>/    contains=htmlEndTag
119
120" Note: Cannot use 'start="<pre>"rs=e', so still have the <pre> tag
121" highlighted correctly via separate sy-match. Unfortunately, this will
122" also highlight <pre> tags inside the preformatted region.
123sy region htmlPre    start="<pre\>[^>]*>"                 end="<\/pre>"me=e-6    contains=htmlPreTag
124sy region wikiNowiki start="<nowiki>"              end="<\/nowiki>"me=e-9 contains=wikiNowikiTag
125sy region wikiSource start="<source\s\+[^>]\+>"         keepend end="<\/source>"me=e-9 contains=wikiSourceTag
126sy region wikiSyntaxHL start="<syntaxhighlight\s\+[^>]\+>" keepend end="<\/syntaxhighlight>"me=e-18 contains=wikiSyntaxHLTag
127
128sy include @TeX syntax/tex.vim
129unlet b:current_syntax
130sy region wikiTeX matchgroup=htmlTag start="<math>" end="<\/math>"  contains=@texMathZoneGroup,wikiNowiki,wikiNowikiEndTag
131sy region wikiRef matchgroup=htmlTag start="<ref>"  end="<\/ref>"   contains=wikiNowiki,wikiNowikiEndTag
132
133sy cluster wikiText contains=wikiLink,wikiTemplate,wikiNowiki,wikiNowikiEndTag,wikiItalic,wikiBold,wikiBoldAndItalic
134
135" Tables
136sy cluster wikiTableFormat contains=wikiTemplate,htmlString,htmlArg,htmlValue
137sy region wikiTable matchgroup=wikiTableSeparator start="{|" end="|}" contains=wikiTableHeaderLine,wikiTableCaptionLine,wikiTableNewRow,wikiTableHeadingCell,wikiTableNormalCell,@wikiText
138sy match  wikiTableSeparator /^!/ contained
139sy match  wikiTableSeparator /^|/ contained
140sy match  wikiTableSeparator /^|[+-]/ contained
141sy match  wikiTableSeparator /||/ contained
142sy match  wikiTableSeparator /!!/ contained
143sy match  wikiTableFormatEnd /[!|]/ contained
144sy match  wikiTableHeadingCell /\(^!\|!!\)\([^!|]*|\)\?.*/ contains=wikiTableSeparator,@wikiText,wikiTableHeadingFormat
145" Require at least one '=' in the format, to avoid spurious matches (e.g.
146" the | in [[foo|bar]] might be taken as the final |, indicating the beginning
147" of the cell). The same is done for wikiTableNormalFormat below.
148sy match  wikiTableHeadingFormat /\%(^!\|!!\)[^!|]\+=[^!|]\+\([!|]\)\(\1\)\@!/me=e-1 contains=@wikiTableFormat,wikiTableSeparator nextgroup=wikiTableFormatEnd
149sy match  wikiTableNormalCell /\(^|\|||\)\([^|]*|\)\?.*/ contains=wikiTableSeparator,@wikiText,wikiTableNormalFormat
150sy match  wikiTableNormalFormat /\(^|\|||\)[^|]\+=[^|]\+||\@!/me=e-1 contains=@wikiTableFormat,wikiTableSeparator nextgroup=wikiTableFormatEnd
151sy match  wikiTableHeaderLine /\(^{|\)\@<=.*$/ contained contains=@wikiTableFormat
152sy match  wikiTableCaptionLine /^|+.*$/ contained contains=wikiTableSeparator,@wikiText
153sy match  wikiTableNewRow /^|-.*$/ contained contains=wikiTableSeparator,@wikiTableFormat
154
155sy cluster wikiTop contains=@Spell,wikiLink,wikiNowiki,wikiNowikiEndTag
156
157sy region wikiItalic        start=+'\@<!'''\@!+ end=+''+    oneline contains=@wikiTop,wikiItalicBold
158sy region wikiBold          start=+'''+         end=+'''+   oneline contains=@wikiTop,wikiBoldItalic
159sy region wikiBoldAndItalic start=+'''''+       end=+'''''+ oneline contains=@wikiTop
160
161sy region wikiBoldItalic contained start=+'\@<!'''\@!+ end=+''+  oneline contains=@wikiTop
162sy region wikiItalicBold contained start=+'''+         end=+'''+ oneline contains=@wikiTop
163
164sy region wikiH1 start="^="      end="="      oneline contains=@wikiTop
165sy region wikiH2 start="^=="     end="=="     oneline contains=@wikiTop
166sy region wikiH3 start="^==="    end="==="    oneline contains=@wikiTop
167sy region wikiH4 start="^===="   end="===="   oneline contains=@wikiTop
168sy region wikiH5 start="^====="  end="====="  oneline contains=@wikiTop
169sy region wikiH6 start="^======" end="======" oneline contains=@wikiTop
170
171sy region wikiLink start="\[\[" end="\]\]\(s\|'s\|es\|ing\|\)" oneline contains=wikiLink,wikiNowiki,wikiNowikiEndTag
172
173sy region wikiLink start="https\?://" end="\W*\_s"me=s-1 oneline
174sy region wikiLink start="\[http:"   end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
175sy region wikiLink start="\[https:"  end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
176sy region wikiLink start="\[ftp:"    end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
177sy region wikiLink start="\[gopher:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
178sy region wikiLink start="\[news:"   end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
179sy region wikiLink start="\[mailto:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
180
181sy match  wikiTemplateName /{{[^{|}<>\[\]]\+/hs=s+2 contained
182sy region wikiTemplate start="{{" end="}}" keepend extend contains=wikiNowiki,wikiNowikiEndTag,wikiTemplateName,wikiTemplateParam,wikiTemplate,wikiLink
183sy region wikiTemplateParam start="{{{\s*\d" end="}}}" extend contains=wikiTemplateName
184
185sy match wikiParaFormatChar /^[\:|\*|;|#]\+/
186sy match wikiParaFormatChar /^-----*/
187sy match wikiPre            /^\ .*$/         contains=wikiNowiki,wikiNowikiEndTag
188
189" HTML highlighting
190
191hi def link htmlTag            Function
192hi def link htmlEndTag         Identifier
193hi def link htmlArg            Type
194hi def link htmlTagName        htmlStatement
195hi def link htmlSpecialTagName Exception
196hi def link htmlValue          String
197hi def link htmlSpecialChar    Special
198
199if !exists("html_no_rendering")
200  hi def link htmlTitle Title
201  hi def link htmlH1    htmlTitle
202  hi def link htmlH2    htmlTitle
203  hi def link htmlH3    htmlTitle
204  hi def link htmlH4    htmlTitle
205  hi def link htmlH5    htmlTitle
206  hi def link htmlH6    htmlTitle
207
208  hi def link htmlPreProc          PreProc
209  hi def link htmlHead             htmlPreProc
210  hi def link htmlPreProcAttrName  htmlPreProc
211  hi def link htmlPreStmt          htmlPreProc
212
213  hi def link htmlSpecial          Special
214  hi def link htmlCssDefinition    htmlSpecial
215  hi def link htmlEvent            htmlSpecial
216  hi def link htmlSpecialChar      htmlSpecial
217
218  hi def link htmlComment          Comment
219  hi def link htmlCommentPart      htmlComment
220  hi def link htmlCssStyleComment  htmlComment
221
222  hi def link htmlString           String
223  hi def link htmlPreAttr          htmlString
224  hi def link htmlValue            htmlString
225
226  hi def link htmlError            Error
227  hi def link htmlBadArg           htmlError
228  hi def link htmlBadTag           htmlError
229  hi def link htmlCommentError     htmlError
230  hi def link htmlPreError         htmlError
231  hi def link htmlPreProcAttrError htmlError
232  hi def link htmlTagError         htmlError
233
234  hi def link htmlStatement        Statement
235
236  hi def link htmlConstant         Constant
237
238  hi def link htmlBoldItalicUnderline htmlBoldUnderlineItalic
239  hi def link htmlUnderlineItalicBold htmlBoldUnderlineItalic
240  hi def link htmlUnderlineBoldItalic htmlBoldUnderlineItalic
241  hi def link htmlItalicBoldUnderline htmlBoldUnderlineItalic
242  hi def link htmlItalicUnderlineBold htmlBoldUnderlineItalic
243
244  hi def link htmlItalicBold          htmlBoldItalic
245  hi def link htmlItalicUnderline     htmlUnderlineItalic
246  hi def link htmlUnderlineBold       htmlBoldUnderline
247
248  hi def link htmlLink Underlined
249
250  if !exists("html_style_rendering")
251    hi def htmlBold                term=bold                  cterm=bold                  gui=bold
252    hi def htmlBoldUnderline       term=bold,underline        cterm=bold,underline        gui=bold,underline
253    hi def htmlBoldItalic          term=bold,italic           cterm=bold,italic           gui=bold,italic
254    hi def htmlBoldUnderlineItalic term=bold,italic,underline cterm=bold,italic,underline gui=bold,italic,underline
255    hi def htmlUnderline           term=underline             cterm=underline             gui=underline
256    hi def htmlUnderlineItalic     term=italic,underline      cterm=italic,underline      gui=italic,underline
257    hi def htmlItalic              term=italic                cterm=italic                gui=italic
258  endif
259endif
260
261" Wiki highlighting
262
263hi def link wikiItalic        htmlItalic
264hi def link wikiBold          htmlBold
265hi def link wikiBoldItalic    htmlBoldItalic
266hi def link wikiItalicBold    htmlBoldItalic
267hi def link wikiBoldAndItalic htmlBoldItalic
268
269hi def link wikiH1 htmlTitle
270hi def link wikiH2 htmlTitle
271hi def link wikiH3 htmlTitle
272hi def link wikiH4 htmlTitle
273hi def link wikiH5 htmlTitle
274hi def link wikiH6 htmlTitle
275
276hi def link wikiLink           htmlLink
277hi def link wikiTemplate       htmlSpecial
278hi def link wikiTemplateParam  htmlSpecial
279hi def link wikiTemplateName   Type
280hi def link wikiParaFormatChar htmlSpecial
281hi def link wikiPre            htmlConstant
282hi def link wikiRef            htmlComment
283
284hi def link htmlPre            wikiPre
285hi def link wikiSource         wikiPre
286hi def link wikiSyntaxHL       wikiPre
287
288hi def link wikiTableSeparator Statement
289hi def link wikiTableFormatEnd wikiTableSeparator
290hi def link wikiTableHeadingCell htmlBold
291
292let b:current_syntax = "mediawiki"