From: Hiroshi Shirosaki Date: Fri, 5 Feb 2016 09:52:55 +0000 (+0900) Subject: Merge pull request #252 from alexconst/feat/emphasis_singleline X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/7501816f7befaee111f9fe9b87e5a1f6acfb23e4?hp=c6d43fde597d5edd51360fcd16c188e1fb93b4bc Merge pull request #252 from alexconst/feat/emphasis_singleline Add option for singleline emphasis --- diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index d68e7c0..4019ff9 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -631,6 +631,10 @@ function! s:MarkdownHighlightSources(force) if !exists('b:mkd_known_filetypes') let b:mkd_known_filetypes = {} endif + if !exists('b:mkd_included_filetypes') + " set syntax file name included + let b:mkd_included_filetypes = {} + endif if !a:force && (b:mkd_known_filetypes == filetypes || empty(filetypes)) return endif @@ -646,7 +650,12 @@ function! s:MarkdownHighlightSources(force) let filetype = ft endif let group = 'mkdSnippet' . toupper(substitute(filetype, "[+-]", "_", "g")) - let include = s:SyntaxInclude(filetype) + if !has_key(b:mkd_included_filetypes, filetype) + let include = s:SyntaxInclude(filetype) + let b:mkd_included_filetypes[filetype] = 1 + else + let include = '@' . toupper(filetype) + endif let command = 'syntax region %s matchgroup=%s start="^\s*```%s$" matchgroup=%s end="\s*```$" keepend contains=%s%s' execute printf(command, group, startgroup, ft, endgroup, include, has('conceal') ? ' concealends' : '') execute printf('syntax cluster mkdNonListItem add=%s', group) diff --git a/test/syntax.vader b/test/syntax.vader index e5618f3..8ac0a28 100644 --- a/test/syntax.vader +++ b/test/syntax.vader @@ -375,6 +375,21 @@ Execute (fenced code block syntax with a language specifier): AssertEqual SyntaxOf('code'), 'mkdSnippetCPP' AssertEqual SyntaxOf('def'), 'rubyDefine' +Given markdown; +```vim +let g:a = 1 +``` + +```viml +let g:b = 1 +``` + +Execute (fenced code block syntax with alias language specifier): + let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax') + call b:func(0) + AssertEqual SyntaxOf('g:a'), 'vimVar' + AssertEqual SyntaxOf('g:b'), 'vimVar' + Given markdown; ```a+b- code @@ -385,7 +400,6 @@ Execute (fenced code block syntax with an unknown language specifier): call b:func(0) AssertEqual SyntaxOf('code'), 'mkdSnippetA_B_' - Given markdown; ``` =