diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 44187ff..15f865f 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -26,19 +26,21 @@ if !exists('g:markdown_fenced_languages') endif let s:done_include = {} for s:type in map(copy(g:markdown_fenced_languages),'matchstr(v:val,"[^=]*$")') - if has_key(s:done_include, matchstr(s:type,'[^.]*')) + let s:lang = matchstr(s:type,'[^.]*') + if has_key(s:done_include, s:lang) continue endif if s:type =~ '\.' - let b:{matchstr(s:type,'[^.]*')}_subtype = matchstr(s:type,'\.\zs.*') + let b:{s:lang}_subtype = matchstr(s:type,'\.\zs.*') endif syn case match - exe 'syn include @markdownHighlight_'.tr(s:type,'.','_').' syntax/'.matchstr(s:type,'[^.]*').'.vim' + exe 'syn include @markdownHighlight_'.tr(s:type,'.','_').' syntax/'.s:lang.'.vim' unlet! b:current_syntax - let s:done_include[matchstr(s:type,'[^.]*')] = 1 + let s:done_include[s:lang] = 1 endfor unlet! s:type unlet! s:done_include +unlet! s:lang syn spell toplevel if exists('s:foldmethod') && s:foldmethod !=# &l:foldmethod @@ -122,6 +124,8 @@ syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepe syn region markdownCode matchgroup=markdownCodeDelimiter start="`` \=" end=" \=``" keepend contains=markdownLineStart syn region markdownCodeBlock matchgroup=markdownCodeDelimiter start="^\s*\z(`\{3,\}\).*$" end="^\s*\z1\ze\s*$" keepend syn region markdownCodeBlock matchgroup=markdownCodeDelimiter start="^\s*\z(\~\{3,\}\).*$" end="^\s*\z1\ze\s*$" keepend +syn region markdownCodeBlock matchgroup=markdownCodeDelimiter start="\%(^>\s\+\)\@<=\z(`\{3,\}\).*$" end="^>\s\+\zs\z1\ze\s*$" keepend contains=markdownBlockquote +syn region markdownCodeBlock matchgroup=markdownCodeDelimiter start="\%(^>\s\+\)\@<=\z(\~\{3,\}\).*$" end="^>\s\+\zs\z1\ze\s*$" keepend contains=markdownBlockquote syn match markdownFootnote "\[^[^\]]\+\]" syn match markdownFootnoteDefinition "^\[^[^\]]\+\]:" @@ -131,12 +135,20 @@ for s:type in g:markdown_fenced_languages if has_key(s:done_include, matchstr(s:type,'[^.]*')) continue endif - exe 'syn region markdownHighlight_'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*\z(`\{3,\}\)\s*\%({.\{-}\.\)\='.matchstr(s:type,'[^=]*').'}\=\S\@!.*$" end="^\s*\z1\ze\s*$" keepend contains=@markdownHighlight_'.tr(matchstr(s:type,'[^=]*$'),'.','_') . s:concealends - exe 'syn region markdownHighlight_'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*\z(\~\{3,\}\)\s*\%({.\{-}\.\)\='.matchstr(s:type,'[^=]*').'}\=\S\@!.*$" end="^\s*\z1\ze\s*$" keepend contains=@markdownHighlight_'.tr(matchstr(s:type,'[^=]*$'),'.','_') . s:concealends + let s:region = substitute(matchstr(s:type,'[^=]*$'),'\..*','','') + let s:lang = matchstr(s:type,'[^=]*') + let s:include = tr(matchstr(s:type,'[^=]*$'),'.','_') + exe 'syn region markdownHighlight_'.s:region.' matchgroup=markdownCodeDelimiter start="^\s*\z(`\{3,\}\)\s*\%({.\{-}\.\)\='.s:lang.'}\=\S\@!.*$" end="^\s*\z1\ze\s*$" keepend contains=@markdownHighlight_'.s:include.s:concealends + exe 'syn region markdownHighlight_'.s:region.' matchgroup=markdownCodeDelimiter start="^\s*\z(\~\{3,\}\)\s*\%({.\{-}\.\)\='.s:lang.'}\=\S\@!.*$" end="^\s*\z1\ze\s*$" keepend contains=@markdownHighlight_'.s:include.s:concealends + exe 'syn region markdownHighlight_'.s:region.' matchgroup=markdownCodeDelimiter start="^>\s\+\z(`\{3,\}\)\s*\%({.\{-}\.\)\='.s:lang.'}\=\S\@!.*$" end="^>\s\+\z1\ze\s*$" keepend contains=markdownBlockquote,@markdownHighlight_'.s:include.s:concealends + exe 'syn region markdownHighlight_'.s:region.' matchgroup=markdownCodeDelimiter start="^>\s\+\z(\~\{3,\}\)\s*\%({.\{-}\.\)\='.s:lang.'}\=\S\@!.*$" end="^>\s\+\z1\ze\s*$" keepend contains=markdownBlockquote,@markdownHighlight_'.s:include.s:concealends let s:done_include[matchstr(s:type,'[^.]*')] = 1 endfor unlet! s:type unlet! s:done_include +unlet! s:region +unlet! s:lang +unlet! s:include if get(b:, 'markdown_yaml_head', get(g:, 'markdown_yaml_head', main_syntax ==# 'markdown')) syn include @markdownYamlTop syntax/yaml.vim