robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
61ea466591
master
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" ) 18finish 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+1contains = @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+1contains = htmlTagName , htmlSpecialTagName , @htmlTagNameCluster 34sy match htmlTagN contained +</\s * [ -a-zA-Z0-9 ] \+ +hs= s+2contains = 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" ) 64sy cluster htmlTop contains = @Spell , htmlTag , htmlEndTag , htmlSpecialChar , htmlPreProc , htmlComment , htmlLink , @htmlPreproc 65 66sy region htmlBold start = "<b\> "end = "</b> "me= e-4contains = @htmlTop , htmlBoldUnderline , htmlBoldItalic 67sy region htmlBold start = "<strong\> "end = "</strong> "me= e-9contains = @htmlTop , htmlBoldUnderline , htmlBoldItalic 68sy region htmlBoldUnderline contained start = "<u\> "end = "</u> "me= e-4contains = @htmlTop , htmlBoldUnderlineItalic 69sy region htmlBoldItalic contained start = "<i\> "end = "</i> "me= e-4contains = @htmlTop , htmlBoldItalicUnderline 70sy region htmlBoldItalic contained start = "<em\> "end = "</em> "me= e-5contains = @htmlTop , htmlBoldItalicUnderline 71sy region htmlBoldUnderlineItalic contained start = "<i\> "end = "</i> "me= e-4contains = @htmlTop 72sy region htmlBoldUnderlineItalic contained start = "<em\> "end = "</em> "me= e-5contains = @htmlTop 73sy region htmlBoldItalicUnderline contained start = "<u\> "end = "</u> "me= e-4contains = @htmlTop , htmlBoldUnderlineItalic 74 75sy region htmlUnderline start = "<u\> "end = "</u> "me= e-4contains = @htmlTop , htmlUnderlineBold , htmlUnderlineItalic 76sy region htmlUnderlineBold contained start = "<b\> "end = "</b> "me= e-4contains = @htmlTop , htmlUnderlineBoldItalic 77sy region htmlUnderlineBold contained start = "<strong\> "end = "</strong> "me= e-9contains = @htmlTop , htmlUnderlineBoldItalic 78sy region htmlUnderlineItalic contained start = "<i\> "end = "</i> "me= e-4contains = @htmlTop , htmlUnderlineItalicBold 79sy region htmlUnderlineItalic contained start = "<em\> "end = "</em> "me= e-5contains = @htmlTop , htmlUnderlineItalicBold 80sy region htmlUnderlineItalicBold contained start = "<b\> "end = "</b> "me= e-4contains = @htmlTop 81sy region htmlUnderlineItalicBold contained start = "<strong\> "end = "</strong> "me= e-9contains = @htmlTop 82sy region htmlUnderlineBoldItalic contained start = "<i\> "end = "</i> "me= e-4contains = @htmlTop 83sy region htmlUnderlineBoldItalic contained start = "<em\> "end = "</em> "me= e-5contains = @htmlTop 84 85sy region htmlItalic start = "<i\> "end = "</i> "me= e-4contains = @htmlTop , htmlItalicBold , htmlItalicUnderline 86sy region htmlItalic start = "<em\> "end = "</em> "me= e-5contains = @htmlTop 87sy region htmlItalicBold contained start = "<b\> "end = "</b> "me= e-4contains = @htmlTop , htmlItalicBoldUnderline 88sy region htmlItalicBold contained start = "<strong\> "end = "</strong> "me= e-9contains = @htmlTop , htmlItalicBoldUnderline 89sy region htmlItalicBoldUnderline contained start = "<u\> "end = "</u> "me= e-4contains = @htmlTop 90sy region htmlItalicUnderline contained start = "<u\> "end = "</u> "me= e-4contains = @htmlTop , htmlItalicUnderlineBold 91sy region htmlItalicUnderlineBold contained start = "<b\> "end = "</b> "me= e-4contains = @htmlTop 92sy region htmlItalicUnderlineBold contained start = "<strong\> "end = "</strong> "me= e-9contains = @htmlTop 93 94sy region htmlH1 start = "<h1\> "end = "</h1> "me= e-5contains = @htmlTop 95sy region htmlH2 start = "<h2\> "end = "</h2> "me= e-5contains = @htmlTop 96sy region htmlH3 start = "<h3\> "end = "</h3> "me= e-5contains = @htmlTop 97sy region htmlH4 start = "<h4\> "end = "</h4> "me= e-5contains = @htmlTop 98sy region htmlH5 start = "<h5\> "end = "</h5> "me= e-5contains = @htmlTop 99sy region htmlH6 start = "<h6\> "end = "</h6> "me= e-5contains = @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-6contains = htmlPreTag 124sy region wikiNowiki start = "<nowiki> "end = "<\/nowiki> "me= e-9contains = wikiNowikiTag 125sy region wikiSource start = "<source\s\+ [ ^> ] \+> "keepend end = "<\/source> "me= e-9contains = wikiSourceTag 126sy region wikiSyntaxHL start = "<syntaxhighlight\s\+ [ ^> ] \+> "keepend end = "<\/syntaxhighlight> "me= e-18contains = 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-1contains = @wikiTableFormat , wikiTableSeparator nextgroup = wikiTableFormatEnd 149sy match wikiTableNormalCell /\(^|\|||\)\( [ ^| ] * |\)\?. * /contains = wikiTableSeparator , @wikiText , wikiTableNormalFormat 150sy match wikiTableNormalFormat /\(^|\|||\) [ ^| ] \+= [ ^| ] \+||\@! /me= e-1contains = @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 regionwikiLink start = "\[\[ " end= "\]\]\(s\|'s\|es\|ing\|\)" oneline contains=wikiLink,wikiNowiki,wikiNowikiEndTag 172 173sy region wikiLink start = "https\?:// "end = "\W * \_s "me= s-1oneline 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+2contained 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" ) 200hi def link htmlTitle Title 201hi def link htmlH1 htmlTitle 202hi def link htmlH2 htmlTitle 203hi def link htmlH3 htmlTitle 204hi def link htmlH4 htmlTitle 205hi def link htmlH5 htmlTitle 206hi def link htmlH6 htmlTitle 207 208hi def link htmlPreProc PreProc 209hi def link htmlHead htmlPreProc 210hi def link htmlPreProcAttrName htmlPreProc 211hi def link htmlPreStmt htmlPreProc 212 213hi def link htmlSpecial Special 214hi def link htmlCssDefinition htmlSpecial 215hi def link htmlEvent htmlSpecial 216hi def link htmlSpecialChar htmlSpecial 217 218hi def link htmlComment Comment 219hi def link htmlCommentPart htmlComment 220hi def link htmlCssStyleComment htmlComment 221 222hi def link htmlString String 223hi def link htmlPreAttr htmlString 224hi def link htmlValue htmlString 225 226hi def link htmlError Error 227hi def link htmlBadArg htmlError 228hi def link htmlBadTag htmlError 229hi def link htmlCommentError htmlError 230hi def link htmlPreError htmlError 231hi def link htmlPreProcAttrError htmlError 232hi def link htmlTagError htmlError 233 234hi def link htmlStatement Statement 235 236hi def link htmlConstant Constant 237 238hi def link htmlBoldItalicUnderline htmlBoldUnderlineItalic 239hi def link htmlUnderlineItalicBold htmlBoldUnderlineItalic 240hi def link htmlUnderlineBoldItalic htmlBoldUnderlineItalic 241hi def link htmlItalicBoldUnderline htmlBoldUnderlineItalic 242hi def link htmlItalicUnderlineBold htmlBoldUnderlineItalic 243 244hi def link htmlItalicBold htmlBoldItalic 245hi def link htmlItalicUnderline htmlUnderlineItalic 246hi def link htmlUnderlineBold htmlBoldUnderline 247 248hi def link htmlLink Underlined 249 250if ! exists ( "html_style_rendering" ) 251hi def htmlBold term = bold cterm = bold gui = bold 252hi def htmlBoldUnderline term = bold , underlinecterm = bold , underlinegui = bold , underline 253hi def htmlBoldItalic term = bold , italiccterm = bold , italicgui = bold , italic 254hi def htmlBoldUnderlineItalic term = bold , italic, underlinecterm = bold , italic, underlinegui = bold , italic, underline 255hi def htmlUnderline term = underline cterm = underline gui = underline 256hi def htmlUnderlineItalic term = italic , underlinecterm = italic , underlinegui = italic , underline 257hi def htmlItalic term = italic cterm = italic gui = italic 258endif 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"