diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 1063649..4e8a51e 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -7,9 +7,25 @@ if exists("b:current_syntax") finish endif +if !exists('main_syntax') + let main_syntax = 'markdown' +endif + runtime! syntax/html.vim unlet! b:current_syntax +if !exists('g:markdown_fenced_languages') + let g:markdown_fenced_languages = [] +endif +for s:type in map(copy(g:markdown_fenced_languages),'matchstr(v:val,"[^=]*$")') + if s:type =~ '\.' + let b:{matchstr(s:type,'[^.]*')}_subtype = matchstr(s:type,'\.\zs.*') + endif + exe 'syn include @markdownHighlight'.substitute(s:type,'\.','','g').' syntax/'.matchstr(s:type,'[^.]*').'.vim' + unlet! b:current_syntax +endfor +unlet! s:type + syn sync minlines=10 syn case ignore @@ -68,6 +84,13 @@ syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepe syn region markdownCode matchgroup=markdownCodeDelimiter start="`` \=" end=" \=``" keepend contains=markdownLineStart syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*\zs```\s*\w*\ze\s*$" end="^```\ze\s*$" keepend +if main_syntax ==# 'markdown' + for s:type in g:markdown_fenced_languages + exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*\zs```'.matchstr(s:type,'[^=]*').'$" end="^```\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') + endfor + unlet! s:type +endif + syn match markdownEscape "\\[][\\`*_{}()#+.!-]" syn match markdownError "\w\@<=_\w\@="