Syntax: Stricter italic match: match '_that_' not 'a_ that _a'

See: https://github.github.com/gfm/#emphasis-and-strong-emphasis

`A single * character can open emphasis iff (if and only if) it is part of a left-flanking delimiter run.`

Tim Pope default is too permissive (leads to too much emphasis openener): `\S\@<=_\|_\S\@=` -> `_\S\@=`
This commit is contained in:
Tinmarino
2020-08-08 16:51:28 -04:00
parent 21c5a7f796
commit a1f1b9c290
3 changed files with 33 additions and 22 deletions

View File

@@ -273,14 +273,11 @@ endfunction
" Helper: Expand regex from reduced typeface delimiters
" :param: list<list,delimiters>> with reduced regex
" Return: list with extended regex delimiters (not inside a word)
" -- [['\*_', '_\*']] -> [['\S\@<=\*_\|\*_\S\@=', '\S\@<=_\*\|_\*\S\@=']]
" -- [['\*_', '_\*']] -> [['\*_\S\@=', '\S\@<=_\*']]
function! vimwiki#u#hi_expand_regex(lst) abort
let res = []
function! s:expand_regex(rx) abort
return '\S\@<=' .a:rx . '\|' . a:rx . '\S\@='
endfunction
for delimiters in a:lst
call add(res, [s:expand_regex(delimiters[0]), s:expand_regex(delimiters[1])])
call add(res, [delimiters[0] . '\S\@=', '\S\@<=' . delimiters[1]])
endfor
return res
endfunction