Fix: Typeface should not be nested in single equation (#977)
Solution: make thos a tex nested region and let tex decide the syntax
This commit is contained in:
parent
aa628f8a12
commit
348b014957
@ -349,11 +349,6 @@ function! vimwiki#u#hi_typeface(dic) abort
|
||||
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiCode', '')
|
||||
endfor
|
||||
|
||||
"" Equation
|
||||
for u in a:dic['eq']
|
||||
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiEqIn', nested)
|
||||
endfor
|
||||
|
||||
" Superscript
|
||||
for u in a:dic['sup']
|
||||
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiSuperScript', nested, 0, 'oneline')
|
||||
|
@ -25,7 +25,7 @@ let syntax_dic = g:vimwiki_syntax_variables[s:current_syntax]
|
||||
|
||||
" Declare nesting capabilities
|
||||
" -- to be embeded in standard: bold, italic, underline
|
||||
let syntax_dic.nested_extended = 'VimwikiCode,VimwikiEqIn,VimwikiSuperScript,VimwikiSubScript'
|
||||
let syntax_dic.nested_extended = 'VimwikiCode,VimwikiEqIn,VimwikiSuperScript,VimwikiSubScript,textSnipTEX'
|
||||
" -- to be embeded in exetended (the one above)
|
||||
let syntax_dic.nested_typeface = 'VimwikiBold,VimwikiItalic,VimwikiUmderline,VimwikiDelText'
|
||||
let syntax_dic.nested = syntax_dic.nested_extended . ',' . syntax_dic.nested_typeface
|
||||
@ -43,13 +43,6 @@ let syntax_dic.dTypeface.code = [
|
||||
let syntax_dic.dTypeface.del = ([
|
||||
\ ['\~\~', '\~\~']])
|
||||
|
||||
" text: $ equation_inline $
|
||||
" Match only one $
|
||||
" ( ^ or not $) before $ and after: not $
|
||||
let syntax_dic.dTypeface.eq = ([
|
||||
\ ['\%(^\|[^$]\)\@<=\$\%($\|[^$]\)\@=',
|
||||
\ '\%(^\|[^$]\)\@<=\$\%($\|[^$]\)\@=']])
|
||||
|
||||
" text: ^superscript^
|
||||
let syntax_dic.dTypeface.sup = ([
|
||||
\ ['\^', '\^']])
|
||||
@ -58,6 +51,13 @@ let syntax_dic.dTypeface.sup = ([
|
||||
let syntax_dic.dTypeface.sub = ([
|
||||
\ [',,', ',,']])
|
||||
|
||||
" text: $ equation_inline $
|
||||
" Match only one $
|
||||
" ( ^ or not $) before $ and after: not $
|
||||
let syntax_dic.dTypeface.eq = ([
|
||||
\ ['\%(^\|[^$]\)\@<=\$\%($\|[^$]\)\@=',
|
||||
\ '\%(^\|[^$]\)\@<=\$\%($\|[^$]\)\@=']])
|
||||
|
||||
|
||||
" LINKS: highlighting is complicated due to "nonexistent" links feature
|
||||
function! s:add_target_syntax_ON(target, type) abort
|
||||
@ -483,12 +483,26 @@ if !empty(s:nested)
|
||||
endfor
|
||||
endif
|
||||
|
||||
" LaTex: Load
|
||||
if !empty(globpath(&runtimepath, 'syntax/tex.vim'))
|
||||
execute 'syntax include @textGrouptex syntax/tex.vim'
|
||||
endif
|
||||
if !empty(globpath(&runtimepath, 'after/syntax/tex.vim'))
|
||||
execute 'syntax include @textGrouptex after/syntax/tex.vim'
|
||||
endif
|
||||
|
||||
" LaTeX
|
||||
" LaTeX: Block
|
||||
call vimwiki#base#nested_syntax('tex',
|
||||
\ vimwiki#vars#get_syntaxlocal('rxMathStart').'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
\ '\%([[:blank:][:punct:]].*\)\?',
|
||||
\ vimwiki#vars#get_syntaxlocal('rxMathEnd'), 'VimwikiMath')
|
||||
|
||||
" LaTeX: Inline
|
||||
for u in syntax_dic.dTypeface.eq
|
||||
execute 'syntax region textSniptex matchgroup=texSnip'
|
||||
\ . ' start="'.u[0].'" end="'.u[1].'"'
|
||||
\ . ' contains=@texMathZoneGroup'
|
||||
\ . ' keepend oneline '. b:vimwiki_syntax_concealends
|
||||
endfor
|
||||
|
||||
syntax spell toplevel
|
||||
|
@ -55,10 +55,10 @@ Given vimwiki (Extended Types mono):
|
||||
Execute (Set syntax markdown):
|
||||
call SetSyntax('markdown')
|
||||
|
||||
Execute (Assert Syntax extended types mono):
|
||||
Execute (Assert Syntax extended types x 1):
|
||||
AssertEqual 'VimwikiCode' , SyntaxAt(1, 8)
|
||||
AssertEqual 'VimwikiDelText' , SyntaxAt(2, 8)
|
||||
AssertEqual 'VimwikiEqIn' , SyntaxAt(3, 8)
|
||||
AssertEqual 'textSnipTEX' , SyntaxAt(3, 8)
|
||||
AssertEqual 'VimwikiSuperScript' , SyntaxAt(4, 8)
|
||||
AssertEqual 'VimwikiSubScript' , SyntaxAt(5, 8)
|
||||
|
||||
@ -73,10 +73,10 @@ Given vimwiki (Extended Types nested in basic):
|
||||
Execute (Set syntax markdown):
|
||||
call SetSyntax('markdown')
|
||||
|
||||
Execute (Assert Syntax extended types mono):
|
||||
Execute (Assert Syntax extended types x 2):
|
||||
AssertEqual 'VimwikiCode' , SyntaxAt(1, 23)
|
||||
AssertEqual 'VimwikiDelText' , SyntaxAt(2, 23)
|
||||
AssertEqual 'VimwikiEqIn' , SyntaxAt(3, 23)
|
||||
AssertEqual 'textSnipTEX' , SyntaxAt(3, 23)
|
||||
AssertEqual 'VimwikiSuperScript' , SyntaxAt(4, 23)
|
||||
AssertEqual 'VimwikiSubScript' , SyntaxAt(5, 23)
|
||||
|
||||
@ -93,8 +93,8 @@ Execute (Set syntax markdown):
|
||||
Execute (Assert Syntax extended types nested in extended):
|
||||
AssertEqual 'VimwikiCode' , SyntaxAt(1, 23)
|
||||
AssertEqual 'VimwikiDelText' , SyntaxAt(2, 23)
|
||||
AssertEqual 'VimwikiEqIn' , SyntaxAt(3, 23)
|
||||
AssertEqual 'VimwikiSuperScript' , SyntaxAt(4, 23)
|
||||
AssertEqual 'textSnipTEX' , SyntaxAt(3, 23)
|
||||
AssertEqual 'textSnipTEX' , SyntaxAt(4, 23)
|
||||
AssertEqual 'VimwikiSubScript' , SyntaxAt(5, 23)
|
||||
|
||||
Given vimwiki (Basic Types nested in extended):
|
||||
@ -107,10 +107,10 @@ Given vimwiki (Basic Types nested in extended):
|
||||
Execute (Set syntax markdown):
|
||||
call SetSyntax('markdown')
|
||||
|
||||
Execute (Assert Syntax extended types nested in extended):
|
||||
Execute (Assert Syntax basic types nested in extended):
|
||||
AssertEqual 'VimwikiBold' , SyntaxAt(1, 23)
|
||||
AssertEqual 'VimwikiItalic' , SyntaxAt(2, 23)
|
||||
AssertEqual 'VimwikiBold' , SyntaxAt(3, 23)
|
||||
AssertEqual 'textSnipTEX' , SyntaxAt(3, 23)
|
||||
AssertEqual 'VimwikiItalic' , SyntaxAt(4, 23)
|
||||
AssertEqual 'VimwikiBold' , SyntaxAt(5, 23)
|
||||
|
||||
@ -145,7 +145,7 @@ Given vimwiki (Multiline Typfaces Basic and extended):
|
||||
and mutli
|
||||
path
|
||||
`
|
||||
and $ multi
|
||||
but no $ multi
|
||||
equation
|
||||
$
|
||||
^ but no multi
|
||||
@ -162,7 +162,7 @@ Execute (Multiline syantax but not sup and sub):
|
||||
AssertEqual 'VimwikiItalic' , SyntaxAt(5, 1)
|
||||
AssertEqual 'VimwikiDelText' , SyntaxAt(8, 1)
|
||||
AssertEqual 'VimwikiCode' , SyntaxAt(11, 1)
|
||||
AssertEqual 'VimwikiEqIn' , SyntaxAt(14, 1)
|
||||
AssertEqual '' , SyntaxAt(14, 1)
|
||||
AssertEqual '' , SyntaxAt(17, 1)
|
||||
AssertEqual '' , SyntaxAt(20, 1)
|
||||
|
||||
@ -549,7 +549,7 @@ Execute (Assert Code syntax):
|
||||
#######################
|
||||
|
||||
Given vimwiki (Math markdown):
|
||||
math inline: $ \sum_i a_i^2 = 1 $
|
||||
math inline: $ aaaaaaaaaaaaaa \sum_i a_i^2 = 1 $
|
||||
|
||||
math block:
|
||||
$$
|
||||
@ -568,7 +568,7 @@ Execute (Set syntax markdown):
|
||||
call SetSyntax('markdown')
|
||||
|
||||
Execute (Assert math syntax 1):
|
||||
AssertEqual 'VimwikiEqIn', SyntaxAt(1, 18)
|
||||
AssertEqual 'textSnipTEX', SyntaxAt(1, 18)
|
||||
let syntax_5 = SyntaxAt(5, 1)
|
||||
Assert syntax_5 == 'texStatement' || syntax_5 == 'texMathSymbol'
|
||||
let syntax_12 = SyntaxAt(12, 1)
|
||||
@ -579,7 +579,7 @@ Execute (Assert math syntax 1):
|
||||
##############################
|
||||
|
||||
Given vimwiki (Math wiki):
|
||||
math inline: $ \sum_i a_i^2 = 1 $
|
||||
math inline: $aaaaaaaaaaaaaaaaaaaaaaaaaa \sum_i a_i^2 = 1 $
|
||||
|
||||
math block:
|
||||
{{$
|
||||
@ -598,7 +598,7 @@ Execute (Set syntax default):
|
||||
call SetSyntax('default')
|
||||
|
||||
Execute (Assert math syntax 2):
|
||||
AssertEqual 'VimwikiEqIn', SyntaxAt(1, 18)
|
||||
AssertEqual 'textSnipTEX', SyntaxAt(1, 18)
|
||||
let syntax_5 = SyntaxAt(5, 1)
|
||||
Assert syntax_5 == 'texStatement' || syntax_5 == 'texMathSymbol'
|
||||
let syntax_12 = SyntaxAt(12, 1)
|
||||
|
Loading…
Reference in New Issue
Block a user