Skip to content

Commit

Permalink
Merge pull request #3 from ipkiss42/syntax_improvements
Browse files Browse the repository at this point in the history
Syntax improvements
  • Loading branch information
chikamichi committed Nov 30, 2013
2 parents 1dcde45 + 3c114ca commit a69e8f1
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions syntax/mediawiki.vim
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ endif
"
" With wikiPre, indented lines would be rendered differently from
" unindented lines.
sy match htmlPreTag /<pre>/ contains=htmlTag
sy match htmlPreTag /<pre\>[^>]*>/ contains=htmlTag
sy match htmlPreEndTag /<\/pre>/ contains=htmlEndTag
sy match wikiNowikiTag /<nowiki>/ contains=htmlTag
sy match wikiNowikiEndTag /<\/nowiki>/ contains=htmlEndTag
Expand All @@ -130,7 +130,7 @@ sy match wikiSyntaxHLEndTag /<\/syntaxhighlight>/ contains=htmlEndTag
" Note: Cannot use 'start="<pre>"rs=e', so still have the <pre> tag
" highlighted correctly via separate sy-match. Unfortunately, this will
" also highlight <pre> tags inside the preformatted region.
sy region htmlPre start="<pre>" end="<\/pre>"me=e-6 contains=htmlPreTag
sy region htmlPre start="<pre\>[^>]*>" end="<\/pre>"me=e-6 contains=htmlPreTag
sy region wikiNowiki start="<nowiki>" end="<\/nowiki>"me=e-9 contains=wikiNowikiTag
sy region wikiSource start="<source\s\+[^>]\+>" keepend end="<\/source>"me=e-9 contains=wikiSourceTag
sy region wikiSyntaxHL start="<syntaxhighlight\s\+[^>]\+>" keepend end="<\/syntaxhighlight>"me=e-18 contains=wikiSyntaxHLTag
Expand All @@ -139,6 +139,28 @@ sy include @TeX syntax/tex.vim
sy region wikiTeX matchgroup=htmlTag start="<math>" end="<\/math>" contains=@texMathZoneGroup,wikiNowiki,wikiNowikiEndTag
sy region wikiRef matchgroup=htmlTag start="<ref>" end="<\/ref>" contains=wikiNowiki,wikiNowikiEndTag

sy cluster wikiText contains=wikiLink,wikiTemplate,wikiNowiki,wikiNowikiEndTag,wikiItalic,wikiBold,wikiBoldAndItalic

" Tables
sy cluster wikiTableFormat contains=wikiTemplate,htmlString,htmlArg,htmlValue
sy region wikiTable matchgroup=wikiTableSeparator start="{|" end="|}" contains=wikiTableHeaderLine,wikiTableCaptionLine,wikiTableNewRow,wikiTableHeadingCell,wikiTableNormalCell,@wikiText
sy match wikiTableSeparator /^!/ contained
sy match wikiTableSeparator /^|/ contained
sy match wikiTableSeparator /^|[+-]/ contained
sy match wikiTableSeparator /||/ contained
sy match wikiTableSeparator /!!/ contained
sy match wikiTableFormatEnd /[!|]/ contained
sy match wikiTableHeadingCell /\(^!\|!!\)\([^!|]*|\)\?.*/ contains=wikiTableSeparator,@wikiText,wikiTableHeadingFormat
" Require at least one '=' in the format, to avoid spurious matches (e.g.
" the | in [[foo|bar]] might be taken as the final |, indicating the beginning
" of the cell). The same is done for wikiTableNormalFormat below.
sy match wikiTableHeadingFormat /\%(^!\|!!\)[^!|]\+=[^!|]\+\([!|]\)\(\1\)\@!/me=e-1 contains=@wikiTableFormat,wikiTableSeparator nextgroup=wikiTableFormatEnd
sy match wikiTableNormalCell /\(^|\|||\)\([^|]*|\)\?.*/ contains=wikiTableSeparator,@wikiText,wikiTableNormalFormat
sy match wikiTableNormalFormat /\(^|\|||\)[^|]\+=[^|]\+||\@!/me=e-1 contains=@wikiTableFormat,wikiTableSeparator nextgroup=wikiTableFormatEnd
sy match wikiTableHeaderLine /\(^{|\)\@<=.*$/ contained contains=@wikiTableFormat
sy match wikiTableCaptionLine /^|+.*$/ contained contains=wikiTableSeparator,@wikiText
sy match wikiTableNewRow /^|-.*$/ contained contains=wikiTableSeparator,@wikiTableFormat

sy cluster wikiTop contains=@Spell,wikiLink,wikiNowiki,wikiNowikiEndTag

sy region wikiItalic start=+'\@<!'''\@!+ end=+''+ oneline contains=@wikiTop,wikiItalicBold
Expand All @@ -157,14 +179,17 @@ sy region wikiH6 start="^======" end="======" oneline contains=@wikiTop

sy region wikiLink start="\[\[" end="\]\]\(s\|'s\|es\|ing\|\)" oneline contains=wikiLink,wikiNowiki,wikiNowikiEndTag

sy region wikiLink start="https\?://" end="\W*\_s"me=s-1 oneline
sy region wikiLink start="\[http:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
sy region wikiLink start="\[https:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
sy region wikiLink start="\[ftp:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
sy region wikiLink start="\[gopher:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
sy region wikiLink start="\[news:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
sy region wikiLink start="\[mailto:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag

sy region wikiTemplate start="{{" end="}}" contains=wikiNowiki,wikiNowikiEndTag
sy match wikiTemplateName /{{\s*\w\+/hs=s+2 contained
sy region wikiTemplate start="{{" end="}}" keepend extend contains=wikiNowiki,wikiNowikiEndTag,wikiTemplateName,wikiTemplateParam,wikiTemplate,wikiLink
sy region wikiTemplateParam start="{{{\s*\d" end="}}}" extend contains=wikiTemplateName

sy match wikiParaFormatChar /^[\:|\*|;|#]\+/
sy match wikiParaFormatChar /^-----*/
Expand Down Expand Up @@ -274,13 +299,20 @@ HtmlHiLink wikiH6 htmlTitle

HtmlHiLink wikiLink htmlLink
HtmlHiLink wikiTemplate htmlSpecial
HtmlHiLink wikiTemplateParam htmlSpecial
HtmlHiLink wikiTemplateName Type
HtmlHiLink wikiParaFormatChar htmlSpecial
HtmlHiLink wikiPre htmlConstant
HtmlHiLink wikiRef htmlComment

HtmlHiLink htmlPre wikiPre
HtmlHiLink wikiSource wikiPre
HtmlHiLink wikiSyntaxHL wikiPre

HtmlHiLink wikiTableSeparator Statement
HtmlHiLink wikiTableFormatEnd wikiTableSeparator
HtmlHiLink wikiTableHeadingCell htmlBold


let b:current_syntax = "html"

Expand Down

0 comments on commit a69e8f1

Please sign in to comment.