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:
parent
21c5a7f796
commit
a1f1b9c290
@ -273,14 +273,11 @@ endfunction
|
|||||||
" Helper: Expand regex from reduced typeface delimiters
|
" Helper: Expand regex from reduced typeface delimiters
|
||||||
" :param: list<list,delimiters>> with reduced regex
|
" :param: list<list,delimiters>> with reduced regex
|
||||||
" Return: list with extended regex delimiters (not inside a word)
|
" Return: list with extended regex delimiters (not inside a word)
|
||||||
" -- [['\*_', '_\*']] -> [['\S\@<=\*_\|\*_\S\@=', '\S\@<=_\*\|_\*\S\@=']]
|
" -- [['\*_', '_\*']] -> [['\*_\S\@=', '\S\@<=_\*']]
|
||||||
function! vimwiki#u#hi_expand_regex(lst) abort
|
function! vimwiki#u#hi_expand_regex(lst) abort
|
||||||
let res = []
|
let res = []
|
||||||
function! s:expand_regex(rx) abort
|
|
||||||
return '\S\@<=' .a:rx . '\|' . a:rx . '\S\@='
|
|
||||||
endfunction
|
|
||||||
for delimiters in a:lst
|
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
|
endfor
|
||||||
return res
|
return res
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -16,23 +16,19 @@ let b:vimwiki_syntax_conceal = exists('+conceallevel') ? ' conceal' : ''
|
|||||||
let b:vimwiki_syntax_concealends = has('conceal') ? ' concealends' : ''
|
let b:vimwiki_syntax_concealends = has('conceal') ? ' concealends' : ''
|
||||||
|
|
||||||
" text: *strong*
|
" text: *strong*
|
||||||
let s:default_syntax.dTypeface.bold = [
|
let s:default_syntax.dTypeface.bold = vimwiki#u#hi_expand_regex([
|
||||||
\ ['\S\@<=\*\|\*\S\@=', '\S\@<=\*\|\*\S\@='],
|
\ ['\*', '\*']])
|
||||||
\ ]
|
|
||||||
|
|
||||||
" text: _italic_
|
" text: _italic_
|
||||||
let s:default_syntax.dTypeface.italic = [
|
let s:default_syntax.dTypeface.italic = vimwiki#u#hi_expand_regex([
|
||||||
\ ['\S\@<=_\|_\S\@=', '\S\@<=_\|_\S\@='],
|
\ ['_', '_']])
|
||||||
\ ]
|
|
||||||
|
|
||||||
" text: no underline defined
|
" text: no underline defined
|
||||||
let s:default_syntax.dTypeface.underline = []
|
let s:default_syntax.dTypeface.underline = []
|
||||||
|
|
||||||
" text: *_bold italic_* or _*italic bold*_
|
" text: *_bold italic_* or _*italic bold*_
|
||||||
let s:default_syntax.dTypeface.bold_italic = [
|
let s:default_syntax.dTypeface.bold_italic = vimwiki#u#hi_expand_regex([
|
||||||
\ ['\S\@<=\*_\|\*_\S\@=', '\S\@<=_\*\|_\*\S\@='],
|
\ ['\*_', '_\*'], ['_\*', '\*_']])
|
||||||
\ ['\S\@<=_\*\|_\*\S\@=', '\S\@<=\*_\|\*_\S\@='],
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
" generic headers
|
" generic headers
|
||||||
let s:default_syntax.rxH = '='
|
let s:default_syntax.rxH = '='
|
||||||
|
@ -4,6 +4,24 @@
|
|||||||
# 1 Typeface {{{1
|
# 1 Typeface {{{1
|
||||||
#################
|
#################
|
||||||
|
|
||||||
|
# Emphasis stricker {{{2
|
||||||
|
# See: https://github.github.com/gfm/#emphasis-and-strong-emphasis
|
||||||
|
|
||||||
|
Given vimwiki (Emphasis and not):
|
||||||
|
this __bold__ ok
|
||||||
|
this _italic_ ok
|
||||||
|
t__ no bold __ t
|
||||||
|
t_ no ital _ t
|
||||||
|
|
||||||
|
Execute (Set syntax markdown):
|
||||||
|
call SetSyntax('markdown')
|
||||||
|
|
||||||
|
Execute (Assert Syntax extended types x 1):
|
||||||
|
AssertEqual 'VimwikiBold' , SyntaxAt(1, 9)
|
||||||
|
AssertEqual 'VimwikiItalic' , SyntaxAt(2, 9)
|
||||||
|
AssertEqual '' , SyntaxAt(3, 9)
|
||||||
|
AssertEqual '' , SyntaxAt(4, 9)
|
||||||
|
|
||||||
# With vimwiki_hl_cb_checked {{{2
|
# With vimwiki_hl_cb_checked {{{2
|
||||||
|
|
||||||
Given vimwiki (task list with code):
|
Given vimwiki (task list with code):
|
||||||
@ -102,17 +120,17 @@ Given vimwiki (Basic Types nested in extended):
|
|||||||
From ,,sub to _italic with en_ aaaaaaa,, morF
|
From ,,sub to _italic with en_ aaaaaaa,, morF
|
||||||
From $eq to **boldboldboldbo** aaaaaaaaa $
|
From $eq to **boldboldboldbo** aaaaaaaaa $
|
||||||
From ^super t *italic aaaaaaa*aaaaaaaaaaaaaaaaaaaaa
|
From ^super t *italic aaaaaaa*aaaaaaaaaaaaaaaaaaaaa
|
||||||
From ~~strike__ bbbbbbbbbbbbb__ssssssssssssssssss~~
|
From ~~strike__bbbbbbbbbbbbb__ssssssssssssssssss~~
|
||||||
|
|
||||||
Execute (Set syntax markdown):
|
Execute (Set syntax markdown):
|
||||||
call SetSyntax('markdown')
|
call SetSyntax('markdown')
|
||||||
|
|
||||||
Execute (Assert Syntax basic types nested in extended):
|
Execute (Assert Syntax basic types nested in extended):
|
||||||
AssertEqual 'VimwikiBold' , SyntaxAt(1, 23)
|
AssertEqual 'VimwikiBold1' , SyntaxAt(1, 23) . 1
|
||||||
AssertEqual 'VimwikiItalic' , SyntaxAt(2, 23)
|
AssertEqual 'VimwikiItalic2' , SyntaxAt(2, 23) . 2
|
||||||
AssertEqual 'textSnipTEX' , SyntaxAt(3, 23)
|
AssertEqual 'textSnipTEX3' , SyntaxAt(3, 23) . 3
|
||||||
AssertEqual 'VimwikiItalic' , SyntaxAt(4, 23)
|
AssertEqual 'VimwikiItalic4' , SyntaxAt(4, 23) . 4
|
||||||
AssertEqual 'VimwikiBold' , SyntaxAt(5, 23)
|
AssertEqual 'VimwikiBold5' , SyntaxAt(5, 23) . 5
|
||||||
|
|
||||||
Given vimwiki (Try to nest in code):
|
Given vimwiki (Try to nest in code):
|
||||||
From `codeto__no onenest in code__ end`
|
From `codeto__no onenest in code__ end`
|
||||||
|
Loading…
Reference in New Issue
Block a user