mirror of
https://github.com/tpope/vim-markdown.git
synced 2025-11-10 19:03:49 -05:00
Highlight GitHub style fenced code blocks
One needs to opt-in to this by specifying which file types should be
highlighted:
let g:markdown_github_languages = ['ruby', 'erb=eruby']
This may not work for all file types.
This commit is contained in:
@@ -7,9 +7,25 @@ if exists("b:current_syntax")
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !exists('main_syntax')
|
||||||
|
let main_syntax = 'markdown'
|
||||||
|
endif
|
||||||
|
|
||||||
runtime! syntax/html.vim
|
runtime! syntax/html.vim
|
||||||
unlet! b:current_syntax
|
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 sync minlines=10
|
||||||
syn case ignore
|
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="`` \=" end=" \=``" keepend contains=markdownLineStart
|
||||||
syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*\zs```\s*\w*\ze\s*$" end="^```\ze\s*$" keepend
|
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 markdownEscape "\\[][\\`*_{}()#+.!-]"
|
||||||
syn match markdownError "\w\@<=_\w\@="
|
syn match markdownError "\w\@<=_\w\@="
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user