Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid infinite syn include recursion when using markdown as a fenced language #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions syntax/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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 =~ '\.'
Expand Down Expand Up @@ -97,15 +97,16 @@ 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 "^\[^[^\]]\+\]:"

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')
Expand Down