X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/e3bbd8b78aa50235dbb87a515f0fb0384621447d..091091fdf8f1f7f42bf1a183eab100f923928841:/syntax/mkd.vim?ds=sidebyside diff --git a/syntax/mkd.vim b/syntax/mkd.vim index 7b9e61f..60a675d 100644 --- a/syntax/mkd.vim +++ b/syntax/mkd.vim @@ -2,11 +2,7 @@ " Language: Markdown " Maintainer: Ben Williams " URL: http://plasticboy.com/markdown-vim-mode/ -" Version: 9 -" Last Change: 2009 May 18 " Remark: Uses HTML syntax file -" Remark: I don't do anything with angle brackets (<>) because that would too easily -" easily conflict with HTML syntax " TODO: Handle stuff contained within stuff (e.g. headings within blockquotes) @@ -15,7 +11,10 @@ if version < 600 so :p:h/html.vim else runtime! syntax/html.vim - unlet b:current_syntax + + if exists('b:current_syntax') + unlet b:current_syntax + endif endif if version < 600 @@ -36,24 +35,28 @@ syn case ignore syn sync linebreaks=1 "additions to HTML groups -syn region htmlItalic start="\(^\|\s\)\@<=\*" end="\*\($\|\s\)\@=" keepend -syn region htmlItalic start="\(^\|\s\)\@<=_" end="_\($\|\s\)\@=" keepend -syn region htmlBold start="\(^\|\s\)\@<=\*\*" end="\*\*\($\|\s\)\@=" keepend -syn region htmlBold start="\(^\|\s\)\@<=__" end="__\($\|\s\)\@=" keepend -syn region htmlBoldItalic start="\(^\|\s\)\@<=\*\*\*" end="\*\*\*\($\|\s\)\@=" keepend -syn region htmlBoldItalic start="\(^\|\s\)\@<=___" end="___\($\|\s\)\@=" keepend +syn region htmlItalic start="\\\@ ]*>\)\@=" end=">" + " Link definitions: [id]: URL (Optional Title) -" TODO handle automatic links without colliding with htmlTag () syn region mkdLinkDef matchgroup=mkdDelimiter start="^ \{,3}\zs\[" end="]:" oneline nextgroup=mkdLinkDefTarget skipwhite syn region mkdLinkDefTarget start="<\?\zs\S" excludenl end="\ze[>[:space:]\n]" contained nextgroup=mkdLinkTitle,mkdLinkDef skipwhite skipnl oneline syn region mkdLinkTitle matchgroup=mkdDelimiter start=+"+ end=+"+ contained @@ -66,15 +69,20 @@ syn match mkdLineBreak / \+$/ syn region mkdBlockquote start=/^\s*>/ end=/$/ contains=mkdLineBreak,mkdLineContinue,@Spell syn region mkdCode start=/\(\([^\\]\|^\)\\\)\@]*>" end="" syn region mkdCode start="]*>" end="" -syn match mkdCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ +syn region mkdFootnote start="\[^" end="\]" +syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/ +syn match mkdIndentCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ contained syn match mkdListItem "^\s*[-*+]\s\+" syn match mkdListItem "^\s*\d\+\.\s\+" +syn region mkdNonListItemBlock start="\n\(\_^\_$\|\s\{4,}[^ ]\|\t+[^\t]\)\@!" end="^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=" contains=@mkdNonListItem,@Spell syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*$/ syn match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-$/ -syn match mkdRule /^\s+_\s\{0,1}_\s\{0,1}_$/ +syn match mkdRule /^\s*_\s\{0,1}_\s\{0,1}_$/ syn match mkdRule /^\s*-\{3,}$/ syn match mkdRule /^\s*\*\{3,5}$/ @@ -88,9 +96,24 @@ syn region htmlH6 start="^\s*######" end="\($\|#\+\)" contain syn match htmlH1 /^.\+\n=\+$/ contains=@Spell syn match htmlH2 /^.\+\n-\+$/ contains=@Spell +if get(g:, 'vim_markdown_math', 0) + syn region mkdMath matchgroup=mkdDelimiter start="\\\@ + let b:current_syntax = "mkd" delcommand HtmlHiLink