Skip to content

Commit

Permalink
Merge pull request #492 from jrwrigh/master
Browse files Browse the repository at this point in the history
feat: Allow characters after code fence language
  • Loading branch information
shirosaki authored Jul 12, 2020
2 parents 23a5146 + dfd92dd commit 909c0e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ftplugin/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,8 @@ function! s:MarkdownHighlightSources(force)
" Look for code blocks in the current file
let filetypes = {}
for line in getline(1, '$')
let ft = matchstr(line, '```\s*\zs[0-9A-Za-z_+-]*')
let ft = matchstr(line, '```\s*\zs[0-9A-Za-z_+-]*\ze.*')
echom ft

This comment has been minimized.

Copy link
@3rd

3rd Jul 13, 2020

opening an issue on this, it currently pollutes cmdline

This comment has been minimized.

Copy link
@glepnir

glepnir Jul 14, 2020

yes. got same issue here.

This comment has been minimized.

Copy link
@3rd

3rd Jul 14, 2020

there's a PR for it #498

if !empty(ft) && ft !~ '^\d*$' | let filetypes[ft] = 1 | endif
endfor
if !exists('b:mkd_known_filetypes')
Expand Down Expand Up @@ -819,7 +820,7 @@ function! s:MarkdownHighlightSources(force)
else
let include = '@' . toupper(filetype)
endif
let command = 'syntax region %s matchgroup=%s start="^\s*```\s*%s$" matchgroup=%s end="\s*```$" keepend contains=%s%s'
let command = 'syntax region %s matchgroup=%s start="^\s*```\s*%s.*$" matchgroup=%s end="\s*```$" keepend contains=%s%s'
execute printf(command, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) && get(g:, 'vim_markdown_conceal_code_blocks', 1) ? ' concealends' : '')
execute printf('syntax cluster mkdNonListItem add=%s', group)

Expand Down
6 changes: 6 additions & 0 deletions test/syntax.vader
Original file line number Diff line number Diff line change
Expand Up @@ -739,12 +739,18 @@ def a
end
```

```ruby {linenos=table,hl_lines=[8,"15-17"],linenostart=199}
class b
end
```

Execute (fenced code block syntax with a language specifier):
let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
call b:func(0)
AssertEqual SyntaxOf('include'), 'cInclude'
AssertEqual SyntaxOf('code'), 'mkdSnippetCPP'
AssertEqual SyntaxOf('def'), 'rubyDefine'
AssertEqual SyntaxOf('class'), 'rubyClass'

Given markdown;
``` c++
Expand Down

0 comments on commit 909c0e5

Please sign in to comment.