Add markdown syntax support for indented code blocks.

This commit is contained in:
Rane Brown 2020-01-03 07:10:02 -07:00
parent 59e1229da6
commit 3ec0c9cd91
4 changed files with 36 additions and 12 deletions

View File

@ -3486,6 +3486,7 @@ https://github.com/vimwiki-backup/vimwiki/issues.
2.5 (in progress)~
New:~
* Add support for markdown indented code blocks.
* Issue #764: fenced code blocks are properly supported for markdown
syntax i.e. more than 3 backticks, adds tilde support.
* Set default |vimwiki-option-list_margin| = 0 for markdown syntax.

View File

@ -79,9 +79,10 @@ let s:markdown_syntax.number_types = ['1.']
let s:markdown_syntax.list_markers = ['-', '*', '+', '1.']
let s:markdown_syntax.rxListDefine = '::\%(\s\|$\)'
" Preformatted text
" Preformatted text (code blocks)
let s:markdown_syntax.rxPreStart = '\%(`\{3,}\|\~\{3,}\)'
let s:markdown_syntax.rxPreEnd = '\%(`\{3,}\|\~\{3,}\)'
let s:markdown_syntax.rxIndentedCodeBlock = '^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+\(^\s*\n\)'
" Math block
let s:markdown_syntax.rxMathStart = '\$\$'

View File

@ -190,7 +190,9 @@ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ VimwikiEqInT,
\ @Spell
" indented code blocks https://github.github.com/gfm/#indented-code-blocks
execute 'syntax match VimwikiIndentedCodeBlock /' . vimwiki#vars#get_syntaxlocal('rxIndentedCodeBlock') . '/'
hi def link VimwikiIndentedCodeBlock VimwikiPre
" syntax group highlighting
hi def link VimwikiImage VimwikiLink

View File

@ -226,6 +226,23 @@ Given vimwiki (Markdown, Text and Vim):
set hlsearch
~~~~~~~~~~~
Here is an indented code block:
int main()
Must be surrounded by blank lines.
This isn't a code block:
int main()
- But this is one in a list
- Item
- subitem
int main()
- list item
- done
Execute (Set syntax markdown):
let g:vimwiki_global_vars['vimwiki_automatic_nested_syntaxes'] = 1
call SetSyntax('markdown')
@ -252,6 +269,9 @@ Execute (Assert Code syntax):
AssertEqual SyntaxAt(24, 1), 'vimLineComment'
AssertEqual SyntaxAt(25, 1), 'vimCommand'
AssertEqual SyntaxAt(26, 1), 'VimwikiPre'
AssertEqual SyntaxAt(30, 1), 'VimwikiIndentedCodeBlock'
AssertEqual SyntaxAt(35, 1), ''
AssertEqual SyntaxAt(40, 1), 'VimwikiIndentedCodeBlock'
# 11 Math {{{1