Improve markdown syntax for fenced code blocks. Closes #764

This commit is contained in:
Rane Brown 2020-01-01 10:58:56 -07:00
parent 2c50f710b8
commit 5cdeb9a682
4 changed files with 33 additions and 4 deletions

View File

@ -2276,7 +2276,7 @@ endfunction
function! vimwiki#base#detect_nested_syntax() abort
let last_word = '\v.*<(\w+)\s*$'
let lines = map(filter(getline(1, '$'), 'v:val =~# "\\%({{{\\|```\\)" && v:val =~# last_word'),
let lines = map(filter(getline(1, '$'), 'v:val =~# "\\%({{{\\|`\\{3,\}\\|\\~\\{3,\}\\)" && v:val =~# last_word'),
\ 'substitute(v:val, last_word, "\\=submatch(1)", "")')
let dict = {}
for elem in lines

View File

@ -3486,6 +3486,8 @@ https://github.com/vimwiki-backup/vimwiki/issues.
2.5 (in progress)~
New:~
* 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.
* PR #785: |:VimwikiGoto| completion works with part of filename and
nested directories

View File

@ -80,8 +80,8 @@ let s:markdown_syntax.list_markers = ['-', '*', '+', '1.']
let s:markdown_syntax.rxListDefine = '::\%(\s\|$\)'
" Preformatted text
let s:markdown_syntax.rxPreStart = '```'
let s:markdown_syntax.rxPreEnd = '```'
let s:markdown_syntax.rxPreStart = '\%(`\{3,}\|\~\{3,}\)'
let s:markdown_syntax.rxPreEnd = '\%(`\{3,}\|\~\{3,}\)'
" Math block
let s:markdown_syntax.rxMathStart = '\$\$'

View File

@ -211,6 +211,21 @@ Given vimwiki (Markdown, Text and Vim):
set hlsearch
```
`````vim
" this is vim
set hlsearch
`````
~~~vim
" this is vim
set hlsearch
~~~
~~~~~vim
" this is vim
set hlsearch
~~~~~~~~~~~
Execute (Set syntax markdown):
let g:vimwiki_global_vars['vimwiki_automatic_nested_syntaxes'] = 1
call SetSyntax('markdown')
@ -225,6 +240,18 @@ Execute (Assert Code syntax):
AssertEqual SyntaxAt(5, 1), 'VimwikiPre'
AssertEqual SyntaxAt(9, 1), 'vimLineComment'
AssertEqual SyntaxAt(10, 1), 'vimCommand'
AssertEqual SyntaxAt(13, 1), 'VimwikiPre'
AssertEqual SyntaxAt(14, 1), 'vimLineComment'
AssertEqual SyntaxAt(15, 1), 'vimCommand'
AssertEqual SyntaxAt(16, 1), 'VimwikiPre'
AssertEqual SyntaxAt(18, 1), 'VimwikiPre'
AssertEqual SyntaxAt(19, 1), 'vimLineComment'
AssertEqual SyntaxAt(20, 1), 'vimCommand'
AssertEqual SyntaxAt(21, 1), 'VimwikiPre'
AssertEqual SyntaxAt(23, 1), 'VimwikiPre'
AssertEqual SyntaxAt(24, 1), 'vimLineComment'
AssertEqual SyntaxAt(25, 1), 'vimCommand'
AssertEqual SyntaxAt(26, 1), 'VimwikiPre'
# 11 Math {{{1
@ -277,7 +304,7 @@ Given vimwiki (Math wiki):
&= 2.
}}$
Execute (Set syntax markdown):
Execute (Set syntax default):
call SetSyntax('default')
Execute (Assert math syntax):