From 3af074f925c8e72c2970da0d4d490b30cc4cf45a Mon Sep 17 00:00:00 2001 From: Takenoko Date: Sat, 14 May 2016 16:16:22 +0900 Subject: [PATCH 1/6] Add Tex syntax for Marked --- syntax/markdown.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 8c981bb..b82de81 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -36,7 +36,7 @@ syn match markdownValid '&\%(#\=\w*;\)\@!' syn match markdownLineStart "^[<@]\@!" nextgroup=@markdownBlock,htmlSpecialChar syn cluster markdownBlock contains=markdownH1,markdownH2,markdownH3,markdownH4,markdownH5,markdownH6,markdownBlockquote,markdownListMarker,markdownOrderedListMarker,markdownCodeBlock,markdownRule -syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,markdownItalic,markdownBold,markdownCode,markdownEscape,@htmlTop,markdownError +syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,markdownItalic,markdownBold,markdownCode,markdownEscape,@htmlTop,markdownError,markdownHighlighttex syn match markdownH1 "^.\+\n=\+$" contained contains=@markdownInline,markdownHeadingRule,markdownAutomaticLink syn match markdownH2 "^.\+\n-\+$" contained contains=@markdownInline,markdownHeadingRule,markdownAutomaticLink @@ -100,6 +100,11 @@ endif syn match markdownEscape "\\[][\\`*_{}()#+.!-]" syn match markdownError "\w\@<=_\w\@=" +let g:tex_no_error=1 +syn include @markdownHighlighttex syntax/tex.vim +syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\\\\(" end="\\\\)" keepend contains=@markdownHighlighttex +syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\\\\\[" end="\\\\\]" keepend contains=@markdownHighlighttex + hi def link markdownH1 htmlH1 hi def link markdownH2 htmlH2 hi def link markdownH3 htmlH3 From 92e8e95e4aa7ed08ba13d92fdc2cd983c5c40000 Mon Sep 17 00:00:00 2001 From: Takenoko Date: Wed, 24 Aug 2016 10:02:32 +0900 Subject: [PATCH 2/6] Apply Pandoc MathJax rules --- syntax/markdown.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index b82de81..1757d07 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -102,8 +102,10 @@ syn match markdownError "\w\@<=_\w\@=" let g:tex_no_error=1 syn include @markdownHighlighttex syntax/tex.vim -syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\\\\(" end="\\\\)" keepend contains=@markdownHighlighttex +syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\\\\(\ze[^ \n]" end="[^ \n]\zs\\\\)" keepend contains=@markdownHighlighttex syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\\\\\[" end="\\\\\]" keepend contains=@markdownHighlighttex +syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\$\ze[^ \n]" end="[^ \n]\zs\$" keepend contains=@markdownHighlighttex +syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\$\$" end="\$\$" keepend contains=@markdownHighlighttex hi def link markdownH1 htmlH1 hi def link markdownH2 htmlH2 From 4791d4eab6b2b63040f1c80065d9ffd9a07897c6 Mon Sep 17 00:00:00 2001 From: Takenoko Date: Fri, 9 Jun 2017 00:52:15 +0900 Subject: [PATCH 3/6] Fix syntaxes --- syntax/markdown.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 1757d07..107f2ae 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -101,11 +101,11 @@ syn match markdownEscape "\\[][\\`*_{}()#+.!-]" syn match markdownError "\w\@<=_\w\@=" let g:tex_no_error=1 -syn include @markdownHighlighttex syntax/tex.vim -syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\\\\(\ze[^ \n]" end="[^ \n]\zs\\\\)" keepend contains=@markdownHighlighttex -syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\\\\\[" end="\\\\\]" keepend contains=@markdownHighlighttex -syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\$\ze[^ \n]" end="[^ \n]\zs\$" keepend contains=@markdownHighlighttex -syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\$\$" end="\$\$" keepend contains=@markdownHighlighttex +syn include syntax/tex.vim +syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\\\\(\ze[^ \n]" end="[^ \n]\zs\\\\)" keepend contains=@texMathZoneGroup +syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\\\\\[" end="\\\\\]" keepend contains=@texMathZoneGroup +syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\$\ze[^ \n]" end="[^ \n]\zs\$" keepend contains=@texMathZoneGroup +syn region markdownHighlighttex matchgroup=markdownCodeDelimiter start="\$\$" end="\$\$" keepend contains=@texMathZoneGroup hi def link markdownH1 htmlH1 hi def link markdownH2 htmlH2 From b477968892fb72bb062d18129f10bdc8f0c4eb1a Mon Sep 17 00:00:00 2001 From: Takenoko Date: Sat, 10 Jun 2017 01:38:43 +0900 Subject: [PATCH 4/6] Enable it to parse 2 level nested list --- syntax/markdown.vim | 71 +++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 107f2ae..bd6e294 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -30,38 +30,41 @@ unlet! s:type syn sync minlines=10 syn case ignore -syn match markdownValid '[<>]\c[a-z/$!]\@!' -syn match markdownValid '&\%(#\=\w*;\)\@!' +syn match markdownLineBreak " \{2,}$" -syn match markdownLineStart "^[<@]\@!" nextgroup=@markdownBlock,htmlSpecialChar +syn match markdown "^" nextgroup=@markdownBlock +syn cluster markdownBlock contains=markdownParagraph,markdownRule,markdownBlockquote,markdownCodeBlock,@markdownHeading,markdownList +syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,markdownItalic,markdownBold,markdownCode,markdownEscape,@htmlTop,markdownError,markdownHighlighttex,markdownAutomaticLink -syn cluster markdownBlock contains=markdownH1,markdownH2,markdownH3,markdownH4,markdownH5,markdownH6,markdownBlockquote,markdownListMarker,markdownOrderedListMarker,markdownCodeBlock,markdownRule -syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,markdownItalic,markdownBold,markdownCode,markdownEscape,@htmlTop,markdownError,markdownHighlighttex +syn region markdownParagraph start="^ \{0,3}\%(#.\+\)\@!\S" end="^\s*$\|\%(\n \{0,3}\%(#.\+\|>\s*\)\)\@=" keepend contains=@markdownInline contained -syn match markdownH1 "^.\+\n=\+$" contained contains=@markdownInline,markdownHeadingRule,markdownAutomaticLink -syn match markdownH2 "^.\+\n-\+$" contained contains=@markdownInline,markdownHeadingRule,markdownAutomaticLink +syn match markdownRule " \{0,3}\* *\* *\*[ *]*$" contained +syn match markdownRule " \{0,3}- *- *-[ -]*$" contained -syn match markdownHeadingRule "^[=-]\+$" contained +syn region markdownBlockquote matchgroup=markdownBlockquoteDelimiter start=" \{0,3}>\%(\s\|$\)" end="$" contains=@markdownInline contained -syn region markdownH1 matchgroup=markdownHeadingDelimiter start="##\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained -syn region markdownH2 matchgroup=markdownHeadingDelimiter start="###\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained -syn region markdownH3 matchgroup=markdownHeadingDelimiter start="####\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained -syn region markdownH4 matchgroup=markdownHeadingDelimiter start="#####\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained -syn region markdownH5 matchgroup=markdownHeadingDelimiter start="######\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained -syn region markdownH6 matchgroup=markdownHeadingDelimiter start="#######\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained +syn region markdownCodeBlock start=" \{4}" end="$" contained -syn match markdownBlockquote ">\%(\s\|$\)" contained nextgroup=@markdownBlock +syn cluster markdownHeading contains=markdownH1,markdownH2,markdownH3,markdownH4,markdownH5,markdownH6 +syn match markdownH1 "\%(\%(^\s*\n\)\@<=\|\%^\)\s*\S.*\n=\+\s*$" contains=@markdownInline,markdownHeadingRule contained +syn match markdownH2 "\%(\%(^\s*\n\)\@<=\|\%^\)\s*\S.*\n-\+\s*$" contains=@markdownInline,markdownHeadingRule contained +syn match markdownHeadingRule "^[=-]\+\s*$" contained +syn region markdownH1 matchgroup=markdownHeadingDelimiter start="^ \{0,3}##\@!" end="$" keepend oneline contains=@markdownInline contained +syn region markdownH2 matchgroup=markdownHeadingDelimiter start="^ \{0,3}###\@!" end="$" keepend oneline contains=@markdownInline contained +syn region markdownH3 matchgroup=markdownHeadingDelimiter start="^ \{0,3}####\@!" end="$" keepend oneline contains=@markdownInline contained +syn region markdownH4 matchgroup=markdownHeadingDelimiter start="^ \{0,3}#####\@!" end="$" keepend oneline contains=@markdownInline contained +syn region markdownH5 matchgroup=markdownHeadingDelimiter start="^ \{0,3}######\@!" end="$" keepend oneline contains=@markdownInline contained +syn region markdownH6 matchgroup=markdownHeadingDelimiter start="^ \{0,3}#######\@!" end="$" keepend oneline contains=@markdownInline contained -syn region markdownCodeBlock start=" \|\t" end="$" contained +syn region markdownList start="\%(\%(^\s*\n\)\@<=\|\%^\) \{0,3}\%([*+-]\|\d\+\.\)\s\+\S" end="^\s*\%(\n \{0,3}\S\)\@=\n" contained keepend contains=markdownListItemBlockL1 -" TODO: real nesting -syn match markdownListMarker "\%(\t\| \{0,4\}\)[-*+]\%(\s\+\S\)\@=" contained -syn match markdownOrderedListMarker "\%(\t\| \{0,4}\)\<\d\+\.\%(\s\+\S\)\@=" contained +syn region markdownListItemBlockL1 start="^ \{0,3}\%([*+-]\|\d\+\.\)\s\+\S" end="\n\%( \{0,3}\%([*+-]\|\d\+\.\)\s\+\S\)\@=\|^\s*\%(\n \{0,3}\S\)\@=\n" contained keepend contains=markdownListItemL1,markdownListMarkerL1,markdownListItemBlockL2 +syn match markdownListMarkerL1 "\%(^ \{0,3}\)\@<=\%([*+-]\|\d\+\.\)\%(\s\+\S\)\@=" contained +syn match markdownListItemL1 "\%(^ \{0,3}\%([*+-]\|\d\+\.\)\s\+\)\@<=\S.*\%(\n\%( *\%([*+-]\|\d\+\.\)\s\+\S\)\@!\s*\S.*\)*$" contained keepend contains=@markdownInline -syn match markdownRule "\* *\* *\*[ *]*$" contained -syn match markdownRule "- *- *-[ -]*$" contained - -syn match markdownLineBreak " \{2,\}$" +syn region markdownListItemBlockL2 start="^ \{4,7}\%([*+-]\|\d\+\.\)\s\+\S" end="\n\%( \{4,7}\%([*+-]\|\d\+\.\)\s\+\S\)\@=\|^\s*\%(\n \{4,7}\S\)\@=\n" contained keepend contains=markdownListItemL2,markdownListMarkerL2 +syn match markdownListMarkerL2 "\%(^ \{4,7}\)\@<=\%([*+-]\|\d\+\.\)\%(\s\+\S\)\@=" contained +syn match markdownListItemL2 "\%(^ \{4,7}\%([*+-]\|\d\+\.\)\s\+\)\@<=\S.*\%(\n\%( *\%([*+-]\|\d\+\.\)\s\+\S\)\@!\s*\S.*\)*$" contained keepend contains=@markdownInline syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite syn match markdownUrl "\S\+" nextgroup=markdownUrlTitle skipwhite contained @@ -73,15 +76,14 @@ syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+(+ end=+ 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 +syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline contained -let s:concealends = has('conceal') ? ' concealends' : '' -exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart' . s:concealends -exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart' . s:concealends -exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart,markdownItalic' . s:concealends -exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart,markdownItalic' . s:concealends -exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=markdownLineStart' . s:concealends -exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=markdownLineStart' . s:concealends +syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contained contains=markdownLineStart +syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contained contains=markdownLineStart +syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contained contains=markdownLineStart,markdownItalic +syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contained contains=markdownLineStart,markdownItalic +syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contained contains=markdownLineStart +syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contained contains=markdownLineStart syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepend contains=markdownLineStart syn region markdownCode matchgroup=markdownCodeDelimiter start="`` \=" end=" \=``" keepend contains=markdownLineStart @@ -115,9 +117,10 @@ hi def link markdownH5 htmlH5 hi def link markdownH6 htmlH6 hi def link markdownHeadingRule markdownRule hi def link markdownHeadingDelimiter Delimiter -hi def link markdownOrderedListMarker markdownListMarker -hi def link markdownListMarker htmlTagName -hi def link markdownBlockquote Comment +hi def link markdownListMarkerL1 htmlTagName +hi def link markdownListMarkerL2 htmlTagName +hi def link markdownBlockquoteDelimiter Comment +hi link markdownBlockquote Normal hi def link markdownRule PreProc hi def link markdownFootnote Typedef From 35ceb393eb41f6e2e681214151cd77f8277da2bf Mon Sep 17 00:00:00 2001 From: Takenoko Date: Sat, 10 Jun 2017 15:14:26 +0900 Subject: [PATCH 5/6] Parameterize syntaxes of block elements --- syntax/markdown.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index bd6e294..8f12483 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -33,8 +33,8 @@ syn case ignore syn match markdownLineBreak " \{2,}$" syn match markdown "^" nextgroup=@markdownBlock -syn cluster markdownBlock contains=markdownParagraph,markdownRule,markdownBlockquote,markdownCodeBlock,@markdownHeading,markdownList syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,markdownItalic,markdownBold,markdownCode,markdownEscape,@htmlTop,markdownError,markdownHighlighttex,markdownAutomaticLink +syn cluster markdownBlock contains=markdownParagraph,markdownRule,markdownBlockquote,markdownCodeBlock,@markdownHeading,markdownList syn region markdownParagraph start="^ \{0,3}\%(#.\+\)\@!\S" end="^\s*$\|\%(\n \{0,3}\%(#.\+\|>\s*\)\)\@=" keepend contains=@markdownInline contained @@ -46,9 +46,9 @@ syn region markdownBlockquote matchgroup=markdownBlockquoteDelimiter start=" \{0 syn region markdownCodeBlock start=" \{4}" end="$" contained syn cluster markdownHeading contains=markdownH1,markdownH2,markdownH3,markdownH4,markdownH5,markdownH6 -syn match markdownH1 "\%(\%(^\s*\n\)\@<=\|\%^\)\s*\S.*\n=\+\s*$" contains=@markdownInline,markdownHeadingRule contained -syn match markdownH2 "\%(\%(^\s*\n\)\@<=\|\%^\)\s*\S.*\n-\+\s*$" contains=@markdownInline,markdownHeadingRule contained -syn match markdownHeadingRule "^[=-]\+\s*$" contained +syn match markdownH1 "\%(\%(^\s*\n\)\@<=\|\%^\) \{0}\s*\S.*\n=\+\s*$" contains=@markdownInline,markdownHeadingRule contained +syn match markdownH2 "\%(\%(^\s*\n\)\@<=\|\%^\) \{0}\s*\S.*\n-\+\s*$" contains=@markdownInline,markdownHeadingRule contained +syn match markdownHeadingRule "^ \{0}[=-]\+\s*$" contained syn region markdownH1 matchgroup=markdownHeadingDelimiter start="^ \{0,3}##\@!" end="$" keepend oneline contains=@markdownInline contained syn region markdownH2 matchgroup=markdownHeadingDelimiter start="^ \{0,3}###\@!" end="$" keepend oneline contains=@markdownInline contained syn region markdownH3 matchgroup=markdownHeadingDelimiter start="^ \{0,3}####\@!" end="$" keepend oneline contains=@markdownInline contained From 66855b4a0f81aa9452c18f96bb50da84968430a3 Mon Sep 17 00:00:00 2001 From: Takenoko Date: Sun, 11 Jun 2017 16:43:54 +0900 Subject: [PATCH 6/6] Implement real nesting --- syntax/markdown.vim | 83 ++++++++++++++++++++++++++++++--------------- 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 8f12483..22228fc 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -30,43 +30,72 @@ unlet! s:type syn sync minlines=10 syn case ignore -syn match markdownLineBreak " \{2,}$" - -syn match markdown "^" nextgroup=@markdownBlock +syn match markdown "^" nextgroup=@markdownBlockL0 syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,markdownItalic,markdownBold,markdownCode,markdownEscape,@htmlTop,markdownError,markdownHighlighttex,markdownAutomaticLink -syn cluster markdownBlock contains=markdownParagraph,markdownRule,markdownBlockquote,markdownCodeBlock,@markdownHeading,markdownList -syn region markdownParagraph start="^ \{0,3}\%(#.\+\)\@!\S" end="^\s*$\|\%(\n \{0,3}\%(#.\+\|>\s*\)\)\@=" keepend contains=@markdownInline contained +syn match markdownLineBreak " \{2,}$" -syn match markdownRule " \{0,3}\* *\* *\*[ *]*$" contained -syn match markdownRule " \{0,3}- *- *-[ -]*$" contained +if !exists('g:markdown_list_nesting_depth') + let g:markdown_list_nesting_depth = 2 +endif +let s:nesting = g:markdown_list_nesting_depth +while s:nesting >= 0 + let s:indent_num = s:nesting * &tabstop + let s:indent_pat = ' \{' . s:indent_num . ',' . (s:indent_num + &tabstop - 1) . '}' + if s:nesting == 0 + exe 'syn cluster markdownBlockL' . s:nesting . ' contains=markdownList,markdownParagraphL' . s:nesting . ',markdownRuleL' . s:nesting . ',markdownBlockquoteL' . s:nesting . ',markdownCodeBlockL' . s:nesting . ',@markdownHeadingL' . s:nesting + else + exe 'syn cluster markdownBlockL' . s:nesting . ' contains=markdownListItemBlockL' . s:nesting . ',markdownParagraphL' . s:nesting . ',markdownRuleL' . s:nesting . ',markdownBlockquoteL' . s:nesting . ',markdownCodeBlockL' . s:nesting . ',@markdownHeadingL' . s:nesting + endif + + exe 'syn region markdownParagraphL' . s:nesting . ' start="^' . s:indent_pat . '\%(#.\+\)\@!\S" end="^\s*$\|\%(\n' . s:indent_pat . '\%(#.\+\|>\s*\)\)\@=" keepend contains=@markdownInline contained' -syn region markdownBlockquote matchgroup=markdownBlockquoteDelimiter start=" \{0,3}>\%(\s\|$\)" end="$" contains=@markdownInline contained + exe 'syn match markdownRuleL' . s:nesting . ' "' . s:indent_pat . '\* *\* *\*[ *]*$" contained' + exe 'syn match markdownRuleL' . s:nesting . ' "' . s:indent_pat . '- *- *-[ -]*$" contained' -syn region markdownCodeBlock start=" \{4}" end="$" contained + exe 'syn region markdownBlockquoteL' . s:nesting . ' matchgroup=markdownBlockquoteDelimiter start="' . s:indent_pat . '>\%(\s\|$\)" end="$" contains=@markdownInline contained' -syn cluster markdownHeading contains=markdownH1,markdownH2,markdownH3,markdownH4,markdownH5,markdownH6 -syn match markdownH1 "\%(\%(^\s*\n\)\@<=\|\%^\) \{0}\s*\S.*\n=\+\s*$" contains=@markdownInline,markdownHeadingRule contained -syn match markdownH2 "\%(\%(^\s*\n\)\@<=\|\%^\) \{0}\s*\S.*\n-\+\s*$" contains=@markdownInline,markdownHeadingRule contained -syn match markdownHeadingRule "^ \{0}[=-]\+\s*$" contained -syn region markdownH1 matchgroup=markdownHeadingDelimiter start="^ \{0,3}##\@!" end="$" keepend oneline contains=@markdownInline contained -syn region markdownH2 matchgroup=markdownHeadingDelimiter start="^ \{0,3}###\@!" end="$" keepend oneline contains=@markdownInline contained -syn region markdownH3 matchgroup=markdownHeadingDelimiter start="^ \{0,3}####\@!" end="$" keepend oneline contains=@markdownInline contained -syn region markdownH4 matchgroup=markdownHeadingDelimiter start="^ \{0,3}#####\@!" end="$" keepend oneline contains=@markdownInline contained -syn region markdownH5 matchgroup=markdownHeadingDelimiter start="^ \{0,3}######\@!" end="$" keepend oneline contains=@markdownInline contained -syn region markdownH6 matchgroup=markdownHeadingDelimiter start="^ \{0,3}#######\@!" end="$" keepend oneline contains=@markdownInline contained + exe 'syn region markdownCodeBlockL' . s:nesting . ' start=" \{' . (s:indent_num + &tabstop) . '}" end="$" contained' -syn region markdownList start="\%(\%(^\s*\n\)\@<=\|\%^\) \{0,3}\%([*+-]\|\d\+\.\)\s\+\S" end="^\s*\%(\n \{0,3}\S\)\@=\n" contained keepend contains=markdownListItemBlockL1 + exe 'syn cluster markdownHeadingL' . s:nesting . ' contains=markdownH1L' . s:nesting . ',markdownH2L' . s:nesting . ',markdownH3L' . s:nesting . ',markdownH4L' . s:nesting . ',markdownH5L' . s:nesting . ',markdownH6L' . s:nesting + exe 'syn match markdownH1L' . s:nesting . ' "\%(\%(^\s*\n\)\@<=\|\%^\) \{' . s:indent_num . '}\s*\S.*\n \{' . s:indent_num . '}=\+\s*$" contains=@markdownInline,markdownHeadingRuleL' . s:nesting . ' contained' + exe 'syn match markdownH2L' . s:nesting . ' "\%(\%(^\s*\n\)\@<=\|\%^\) \{' . s:indent_num . '}\s*\S.*\n \{' . s:indent_num . '}-\+\s*$" contains=@markdownInline,markdownHeadingRuleL' . s:nesting . ' contained' + exe 'syn match markdownHeadingRuleL' . s:nesting . ' "^ \{' . s:indent_num . '}[=-]\+\s*$" contained' + exe 'syn region markdownH1L' . s:nesting . ' matchgroup=markdownHeadingDelimiter start="^ \{' . s:indent_num . '}##\@!" end="$" keepend oneline contains=@markdownInline contained' + exe 'syn region markdownH2L' . s:nesting . ' matchgroup=markdownHeadingDelimiter start="^ \{' . s:indent_num . '}###\@!" end="$" keepend oneline contains=@markdownInline contained' + exe 'syn region markdownH3L' . s:nesting . ' matchgroup=markdownHeadingDelimiter start="^ \{' . s:indent_num . '}####\@!" end="$" keepend oneline contains=@markdownInline contained' + exe 'syn region markdownH4L' . s:nesting . ' matchgroup=markdownHeadingDelimiter start="^ \{' . s:indent_num . '}#####\@!" end="$" keepend oneline contains=@markdownInline contained' + exe 'syn region markdownH5L' . s:nesting . ' matchgroup=markdownHeadingDelimiter start="^ \{' . s:indent_num . '}######\@!" end="$" keepend oneline contains=@markdownInline contained' + exe 'syn region markdownH6L' . s:nesting . ' matchgroup=markdownHeadingDelimiter start="^ \{' . s:indent_num . '}#######\@!" end="$" keepend oneline contains=@markdownInline contained' -syn region markdownListItemBlockL1 start="^ \{0,3}\%([*+-]\|\d\+\.\)\s\+\S" end="\n\%( \{0,3}\%([*+-]\|\d\+\.\)\s\+\S\)\@=\|^\s*\%(\n \{0,3}\S\)\@=\n" contained keepend contains=markdownListItemL1,markdownListMarkerL1,markdownListItemBlockL2 -syn match markdownListMarkerL1 "\%(^ \{0,3}\)\@<=\%([*+-]\|\d\+\.\)\%(\s\+\S\)\@=" contained -syn match markdownListItemL1 "\%(^ \{0,3}\%([*+-]\|\d\+\.\)\s\+\)\@<=\S.*\%(\n\%( *\%([*+-]\|\d\+\.\)\s\+\S\)\@!\s*\S.*\)*$" contained keepend contains=@markdownInline + if s:nesting == 0 + exe 'syn region markdownList start="\%(\%(^\s*\n\)\@<=\|\%^\)' . s:indent_pat . '\%([*+-]\|\d\+\.\)\s\+\S" end="^\s*\%(\n' . s:indent_pat . '\S\)\@=\n" contained keepend contains=markdownListItemBlockL' . s:nesting + endif -syn region markdownListItemBlockL2 start="^ \{4,7}\%([*+-]\|\d\+\.\)\s\+\S" end="\n\%( \{4,7}\%([*+-]\|\d\+\.\)\s\+\S\)\@=\|^\s*\%(\n \{4,7}\S\)\@=\n" contained keepend contains=markdownListItemL2,markdownListMarkerL2 -syn match markdownListMarkerL2 "\%(^ \{4,7}\)\@<=\%([*+-]\|\d\+\.\)\%(\s\+\S\)\@=" contained -syn match markdownListItemL2 "\%(^ \{4,7}\%([*+-]\|\d\+\.\)\s\+\)\@<=\S.*\%(\n\%( *\%([*+-]\|\d\+\.\)\s\+\S\)\@!\s*\S.*\)*$" contained keepend contains=@markdownInline + exe 'syn region markdownListItemBlockL' . s:nesting . ' start="^' . s:indent_pat . '\%([*+-]\|\d\+\.\)\s\+\S" end="\n\%(' . s:indent_pat . '\%([*+-]\|\d\+\.\)\s\+\S\)\@=\|^\s*\%(\n' . s:indent_pat . '\S\)\@=\n" contained keepend contains=markdownListItemL' . s:nesting . ',markdownListMarkerL' . s:nesting . ',@markdownBlockL' . (s:nesting + 1) + exe 'syn match markdownListMarkerL' . s:nesting . ' "\%(^' . s:indent_pat . '\)\@<=\%([*+-]\|\d\+\.\)\%(\s\+\S\)\@=" contained' + exe 'syn match markdownListItemL' . s:nesting . ' "\%(^' . s:indent_pat . '\%([*+-]\|\d\+\.\)\s\+\)\@<=\S.*\%(\n\%( *\%([*+-]\|\d\+\.\)\s\+\S\)\@!\s*\S.*\)*$" contained keepend contains=@markdownInline' + + exe 'hi def link markdownBlockL' . s:nesting . ' markdownBlock' + exe 'hi def link markdownParagraphL' . s:nesting . ' markdownParagraph' + exe 'hi def link markdownRuleL' . s:nesting . ' markdownRule' + exe 'hi def link markdownBlockquoteL' . s:nesting . ' markdownBlockquote' + exe 'hi def link markdownCodeBlockL' . s:nesting . ' markdownCodeBlock' + exe 'hi def link markdownHeadingL' . s:nesting . ' markdownHeading' + exe 'hi def link markdownHeadingRuleL' . s:nesting . ' markdownHeadingRule' + exe 'hi def link markdownH1L' . s:nesting . ' markdownH1' + exe 'hi def link markdownH2L' . s:nesting . ' markdownH2' + exe 'hi def link markdownH3L' . s:nesting . ' markdownH3' + exe 'hi def link markdownH4L' . s:nesting . ' markdownH4' + exe 'hi def link markdownH5L' . s:nesting . ' markdownH5' + exe 'hi def link markdownH6L' . s:nesting . ' markdownH6' + exe 'hi def link markdownListItemBlockL' . s:nesting . ' markdownListItemBlock' + exe 'hi def link markdownListMarkerL' . s:nesting . ' markdownListMarker' + exe 'hi def link markdownListItemL' . s:nesting . ' markdownListItem' + + let s:nesting -= 1 +endwhile -syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite syn match markdownUrl "\S\+" nextgroup=markdownUrlTitle skipwhite contained syn region markdownUrl matchgroup=markdownUrlDelimiter start="<" end=">" oneline keepend nextgroup=markdownUrlTitle skipwhite contained syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+"+ end=+"+ keepend contained