From 284927540a1c5bad3816afd80ac9c2d65419267c Mon Sep 17 00:00:00 2001 From: tyru Date: Sun, 28 Oct 2018 09:22:40 +0900 Subject: [PATCH] avoid infinite syn include recursion (fix #121) This is reported by @rhysd. https://github.com/tyru/markdown-codehl-onthefly.vim/pull/3 --- syntax/markdown.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 26ba4c9..3aa694a 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -20,7 +20,7 @@ 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,'[^.]*')) + if has_key(s:done_include, matchstr(s:type,'[^.]*')) || matchstr(s:type,'[^.]*') ==# 'markdown' continue endif if s:type =~ '\.' @@ -97,7 +97,8 @@ exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start= 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 markdownCode matchgroup=markdownCodeDelimiter start="^\s*````*\%(markdown\)\@!$" end="^\s*````*\ze\s*$" keepend +syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*````*markdown$" end="^\s*````*\ze\s*$" transparent syn match markdownFootnote "\[^[^\]]\+\]" syn match markdownFootnoteDefinition "^\[^[^\]]\+\]:" @@ -105,7 +106,7 @@ 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,'[^.]*')) + if has_key(s:done_include, matchstr(s:type,'[^.]*')) || matchstr(s:type,'[^.]*') ==# 'markdown' 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')