Improve markdown syntax for fenced code blocks. Closes #764
This commit is contained in:
		@@ -2276,7 +2276,7 @@ endfunction
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
function! vimwiki#base#detect_nested_syntax() abort
 | 
					function! vimwiki#base#detect_nested_syntax() abort
 | 
				
			||||||
  let last_word = '\v.*<(\w+)\s*$'
 | 
					  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)", "")')
 | 
					        \ 'substitute(v:val, last_word, "\\=submatch(1)", "")')
 | 
				
			||||||
  let dict = {}
 | 
					  let dict = {}
 | 
				
			||||||
  for elem in lines
 | 
					  for elem in lines
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3486,6 +3486,8 @@ https://github.com/vimwiki-backup/vimwiki/issues.
 | 
				
			|||||||
2.5 (in progress)~
 | 
					2.5 (in progress)~
 | 
				
			||||||
 | 
					
 | 
				
			||||||
New:~
 | 
					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.
 | 
					    * Set default |vimwiki-option-list_margin| = 0 for markdown syntax.
 | 
				
			||||||
    * PR #785: |:VimwikiGoto| completion works with part of filename and
 | 
					    * PR #785: |:VimwikiGoto| completion works with part of filename and
 | 
				
			||||||
      nested directories
 | 
					      nested directories
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,8 +80,8 @@ let s:markdown_syntax.list_markers = ['-', '*', '+', '1.']
 | 
				
			|||||||
let s:markdown_syntax.rxListDefine = '::\%(\s\|$\)'
 | 
					let s:markdown_syntax.rxListDefine = '::\%(\s\|$\)'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Preformatted text
 | 
					" Preformatted text
 | 
				
			||||||
let s:markdown_syntax.rxPreStart = '```'
 | 
					let s:markdown_syntax.rxPreStart = '\%(`\{3,}\|\~\{3,}\)'
 | 
				
			||||||
let s:markdown_syntax.rxPreEnd = '```'
 | 
					let s:markdown_syntax.rxPreEnd = '\%(`\{3,}\|\~\{3,}\)'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Math block
 | 
					" Math block
 | 
				
			||||||
let s:markdown_syntax.rxMathStart = '\$\$'
 | 
					let s:markdown_syntax.rxMathStart = '\$\$'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -211,6 +211,21 @@ Given vimwiki (Markdown, Text and Vim):
 | 
				
			|||||||
  set hlsearch
 | 
					  set hlsearch
 | 
				
			||||||
  ```
 | 
					  ```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  `````vim
 | 
				
			||||||
 | 
					  " this is vim
 | 
				
			||||||
 | 
					  set hlsearch
 | 
				
			||||||
 | 
					  `````
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ~~~vim
 | 
				
			||||||
 | 
					  " this is vim
 | 
				
			||||||
 | 
					  set hlsearch
 | 
				
			||||||
 | 
					  ~~~
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ~~~~~vim
 | 
				
			||||||
 | 
					  " this is vim
 | 
				
			||||||
 | 
					  set hlsearch
 | 
				
			||||||
 | 
					  ~~~~~~~~~~~
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Execute (Set syntax markdown):
 | 
					Execute (Set syntax markdown):
 | 
				
			||||||
  let g:vimwiki_global_vars['vimwiki_automatic_nested_syntaxes'] = 1
 | 
					  let g:vimwiki_global_vars['vimwiki_automatic_nested_syntaxes'] = 1
 | 
				
			||||||
  call SetSyntax('markdown')
 | 
					  call SetSyntax('markdown')
 | 
				
			||||||
@@ -225,6 +240,18 @@ Execute (Assert Code syntax):
 | 
				
			|||||||
  AssertEqual SyntaxAt(5, 1), 'VimwikiPre'
 | 
					  AssertEqual SyntaxAt(5, 1), 'VimwikiPre'
 | 
				
			||||||
  AssertEqual SyntaxAt(9, 1), 'vimLineComment'
 | 
					  AssertEqual SyntaxAt(9, 1), 'vimLineComment'
 | 
				
			||||||
  AssertEqual SyntaxAt(10, 1), 'vimCommand'
 | 
					  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
 | 
					# 11 Math {{{1
 | 
				
			||||||
@@ -277,7 +304,7 @@ Given vimwiki (Math wiki):
 | 
				
			|||||||
  &= 2.
 | 
					  &= 2.
 | 
				
			||||||
  }}$
 | 
					  }}$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Execute (Set syntax markdown):
 | 
					Execute (Set syntax default):
 | 
				
			||||||
  call SetSyntax('default')
 | 
					  call SetSyntax('default')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Execute (Assert math syntax):
 | 
					Execute (Assert math syntax):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user