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

Support more styles of fenced code blocks #278

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
Support more styles of fenced code blocks
E.g. pandoc's

  ~~~ {.haskell}
  ...
  ~~~

and rmarkdown's

  ``` {r setup}
  ...
  ```
  • Loading branch information
UnkindPartition committed May 12, 2016
commit 48100f8f3ba89281ed473c549ec26a6679205aff
4 changes: 2 additions & 2 deletions ftplugin/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ 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, '\v(```|\~\~\~)\s*(\{\.?)?\zs[0-9A-Za-z_+-]*\ze')
if !empty(ft) && ft !~ '^\d*$' | let filetypes[ft] = 1 | endif
endfor
if !exists('b:mkd_known_filetypes')
Expand Down Expand Up @@ -686,7 +686,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="\v^\s*(```|\~\~\~)\s*(\{\.?)?%s.*$" matchgroup=%s end="\v\s*(```|\~\~\~)$" keepend contains=%s%s'
execute printf(command, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) ? ' concealends' : '')
execute printf('syntax cluster mkdNonListItem add=%s', group)

Expand Down