|
|
|
|
@@ -1,8 +1,8 @@
|
|
|
|
|
" Vim syntax file
|
|
|
|
|
" Language: Markdown
|
|
|
|
|
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
|
|
|
|
" Maintainer: Tim Pope <https://github.com/tpope/vim-markdown>
|
|
|
|
|
" Filenames: *.markdown
|
|
|
|
|
" Last Change: 2019 Dec 05
|
|
|
|
|
" Last Change: 2022 Oct 13
|
|
|
|
|
|
|
|
|
|
if exists("b:current_syntax")
|
|
|
|
|
finish
|
|
|
|
|
@@ -12,6 +12,12 @@ if !exists('main_syntax')
|
|
|
|
|
let main_syntax = 'markdown'
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if has('folding')
|
|
|
|
|
let s:foldmethod = &l:foldmethod
|
|
|
|
|
let s:foldtext = &l:foldtext
|
|
|
|
|
endif
|
|
|
|
|
let s:iskeyword = &l:iskeyword
|
|
|
|
|
|
|
|
|
|
runtime! syntax/html.vim
|
|
|
|
|
unlet! b:current_syntax
|
|
|
|
|
|
|
|
|
|
@@ -26,17 +32,33 @@ 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'
|
|
|
|
|
syn case match
|
|
|
|
|
exe 'syn include @markdownHighlight_'.tr(s:type,'.','_').' syntax/'.matchstr(s:type,'[^.]*').'.vim'
|
|
|
|
|
unlet! b:current_syntax
|
|
|
|
|
let s:done_include[matchstr(s:type,'[^.]*')] = 1
|
|
|
|
|
endfor
|
|
|
|
|
unlet! s:type
|
|
|
|
|
unlet! s:done_include
|
|
|
|
|
|
|
|
|
|
syn spell toplevel
|
|
|
|
|
if exists('s:foldmethod') && s:foldmethod !=# &l:foldmethod
|
|
|
|
|
let &l:foldmethod = s:foldmethod
|
|
|
|
|
unlet s:foldmethod
|
|
|
|
|
endif
|
|
|
|
|
if exists('s:foldtext') && s:foldtext !=# &l:foldtext
|
|
|
|
|
let &l:foldtext = s:foldtext
|
|
|
|
|
unlet s:foldtext
|
|
|
|
|
endif
|
|
|
|
|
if s:iskeyword !=# &l:iskeyword
|
|
|
|
|
let &l:iskeyword = s:iskeyword
|
|
|
|
|
endif
|
|
|
|
|
unlet s:iskeyword
|
|
|
|
|
|
|
|
|
|
if !exists('g:markdown_minlines')
|
|
|
|
|
let g:markdown_minlines = 50
|
|
|
|
|
endif
|
|
|
|
|
execute 'syn sync minlines=' . g:markdown_minlines
|
|
|
|
|
syn sync linebreaks=1
|
|
|
|
|
syn case ignore
|
|
|
|
|
|
|
|
|
|
syn match markdownValid '[<>]\c[a-z/$!]\@!' transparent contains=NONE
|
|
|
|
|
@@ -52,16 +74,16 @@ syn match markdownH2 "^.\+\n-\+$" contained contains=@markdownInline,markdownHea
|
|
|
|
|
|
|
|
|
|
syn match markdownHeadingRule "^[=-]\+$" contained
|
|
|
|
|
|
|
|
|
|
syn region markdownH1 matchgroup=markdownH1Delimiter start="##\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
|
|
|
|
syn region markdownH2 matchgroup=markdownH2Delimiter start="###\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
|
|
|
|
syn region markdownH3 matchgroup=markdownH3Delimiter start="####\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
|
|
|
|
syn region markdownH4 matchgroup=markdownH4Delimiter start="#####\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
|
|
|
|
syn region markdownH5 matchgroup=markdownH5Delimiter start="######\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
|
|
|
|
syn region markdownH6 matchgroup=markdownH6Delimiter start="#######\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
|
|
|
|
syn region markdownH1 matchgroup=markdownH1Delimiter start=" \{,3}#\s" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
|
|
|
|
syn region markdownH2 matchgroup=markdownH2Delimiter start=" \{,3}##\s" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
|
|
|
|
syn region markdownH3 matchgroup=markdownH3Delimiter start=" \{,3}###\s" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
|
|
|
|
syn region markdownH4 matchgroup=markdownH4Delimiter start=" \{,3}####\s" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
|
|
|
|
syn region markdownH5 matchgroup=markdownH5Delimiter start=" \{,3}#####\s" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
|
|
|
|
syn region markdownH6 matchgroup=markdownH6Delimiter start=" \{,3}######\s" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
|
|
|
|
|
|
|
|
|
syn match markdownBlockquote ">\%(\s\|$\)" contained nextgroup=@markdownBlock
|
|
|
|
|
|
|
|
|
|
syn region markdownCodeBlock start=" \|\t" end="$" contained
|
|
|
|
|
syn region markdownCodeBlock start="^\n\( \{4,}\|\t\)" end="^\ze \{,3}\S.*$" keepend
|
|
|
|
|
|
|
|
|
|
" TODO: real nesting
|
|
|
|
|
syn match markdownListMarker "\%(\t\| \{0,4\}\)[-*+]\%(\s\+\S\)\@=" contained
|
|
|
|
|
@@ -79,7 +101,7 @@ syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+"+ end=+
|
|
|
|
|
syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+'+ end=+'+ keepend contained
|
|
|
|
|
syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+(+ end=+)+ keepend contained
|
|
|
|
|
|
|
|
|
|
syn region markdownLinkText matchgroup=markdownLinkTextDelimiter start="!\=\[\%(\%(\_[^][]\|\[\_[^][]*\]\)*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@=" nextgroup=markdownLink,markdownId skipwhite contains=@markdownInline,markdownLineStart
|
|
|
|
|
syn region markdownLinkText matchgroup=markdownLinkTextDelimiter start="!\=\[\%(\_[^][]*\%(\[\_[^][]*\]\_[^][]*\)*]\%([[(]\)\)\@=" end="\]\%([[(]\)\@=" nextgroup=markdownLink,markdownId skipwhite contains=@markdownInline,markdownLineStart
|
|
|
|
|
syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" contains=markdownUrl keepend contained
|
|
|
|
|
syn region markdownId matchgroup=markdownIdDelimiter start="\[" end="\]" keepend contained
|
|
|
|
|
syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline
|
|
|
|
|
@@ -88,31 +110,38 @@ let s:concealends = ''
|
|
|
|
|
if has('conceal') && get(g:, 'markdown_syntax_conceal', 1) == 1
|
|
|
|
|
let s:concealends = ' concealends'
|
|
|
|
|
endif
|
|
|
|
|
exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" skip="\\*" contains=markdownLineStart,@Spell' . s:concealends
|
|
|
|
|
exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\w\@<!_\S\@=" end="\S\@<=_\w\@!" skip="\\_" contains=markdownLineStart,@Spell' . s:concealends
|
|
|
|
|
exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" skip="\\*" contains=markdownLineStart,markdownItalic,@Spell' . s:concealends
|
|
|
|
|
exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\w\@<!__\S\@=" end="\S\@<=__\w\@!" skip="\\_" contains=markdownLineStart,markdownItalic,@Spell' . s:concealends
|
|
|
|
|
exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" skip="\\*" contains=markdownLineStart,@Spell' . s:concealends
|
|
|
|
|
exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\w\@<!___\S\@=" end="\S\@<=___\w\@!" skip="\\_" contains=markdownLineStart,@Spell' . s:concealends
|
|
|
|
|
exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\*\S\@=" end="\S\@<=\*\|^$" skip="\\\*" contains=markdownLineStart,@Spell' . s:concealends
|
|
|
|
|
exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\w\@<!_\S\@=" end="\S\@<=_\w\@!\|^$" skip="\\_" contains=markdownLineStart,@Spell' . s:concealends
|
|
|
|
|
exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\*\*\S\@=" end="\S\@<=\*\*\|^$" skip="\\\*" contains=markdownLineStart,markdownItalic,@Spell' . s:concealends
|
|
|
|
|
exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\w\@<!__\S\@=" end="\S\@<=__\w\@!\|^$" skip="\\_" contains=markdownLineStart,markdownItalic,@Spell' . s:concealends
|
|
|
|
|
exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\*\*\*\S\@=" end="\S\@<=\*\*\*\|^$" skip="\\\*" contains=markdownLineStart,@Spell' . s:concealends
|
|
|
|
|
exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\w\@<!___\S\@=" end="\S\@<=___\w\@!\|^$" skip="\\_" contains=markdownLineStart,@Spell' . s:concealends
|
|
|
|
|
exe 'syn region markdownStrike matchgroup=markdownStrikeDelimiter start="\~\~\S\@=" end="\S\@<=\~\~\|^$" contains=markdownLineStart,@Spell' . s:concealends
|
|
|
|
|
|
|
|
|
|
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*````*.*$" end="^\s*````*\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*\z1\ze\s*$" keepend
|
|
|
|
|
|
|
|
|
|
syn match markdownFootnote "\[^[^\]]\+\]"
|
|
|
|
|
syn match markdownFootnoteDefinition "^\[^[^\]]\+\]:"
|
|
|
|
|
|
|
|
|
|
if main_syntax ==# 'markdown'
|
|
|
|
|
let s:done_include = {}
|
|
|
|
|
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*````*\s*\%({.\{-}\.\)\='.matchstr(s:type,'[^=]*').'}\=\S\@!.*$" end="^\s*````*\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') . s:concealends
|
|
|
|
|
let s:done_include[matchstr(s:type,'[^.]*')] = 1
|
|
|
|
|
endfor
|
|
|
|
|
unlet! s:type
|
|
|
|
|
unlet! s:done_include
|
|
|
|
|
let s:done_include = {}
|
|
|
|
|
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:done_include[matchstr(s:type,'[^.]*')] = 1
|
|
|
|
|
endfor
|
|
|
|
|
unlet! s:type
|
|
|
|
|
unlet! s:done_include
|
|
|
|
|
|
|
|
|
|
if get(b:, 'markdown_yaml_head', get(g:, 'markdown_yaml_head', main_syntax ==# 'markdown'))
|
|
|
|
|
syn include @markdownYamlTop syntax/yaml.vim
|
|
|
|
|
unlet! b:current_syntax
|
|
|
|
|
syn region markdownYamlHead start="\%^---$" end="^\%(---\|\.\.\.\)\s*$" keepend contains=@markdownYamlTop,@Spell
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
syn match markdownEscape "\\[][\\`*_{}()<>#+.!-]"
|
|
|
|
|
@@ -156,6 +185,8 @@ hi def link markdownBold htmlBold
|
|
|
|
|
hi def link markdownBoldDelimiter markdownBold
|
|
|
|
|
hi def link markdownBoldItalic htmlBoldItalic
|
|
|
|
|
hi def link markdownBoldItalicDelimiter markdownBoldItalic
|
|
|
|
|
hi def link markdownStrike htmlStrike
|
|
|
|
|
hi def link markdownStrikeDelimiter markdownStrike
|
|
|
|
|
hi def link markdownCodeDelimiter Delimiter
|
|
|
|
|
|
|
|
|
|
hi def link markdownEscape Special
|
|
|
|
|
|