Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

highlight in math environment #236

Closed
ycpei opened this issue Aug 28, 2016 · 0 comments
Closed

highlight in math environment #236

ycpei opened this issue Aug 28, 2016 · 0 comments
Labels

Comments

@ycpei
Copy link
Contributor

ycpei commented Aug 28, 2016

This is both a issue report and my-attempt-to-fix-the-issue report:

When I try to use the maths environment, say

{{$
a^b
}}$

it is highlighted as if I am using maths in a non-maths environment, that is, the ^ is red.
However, if I put

{{$
$a^b
}}$

the red error-highlighting is gone and the content after $ in the second line is treated as maths in latex, but after conversion to html there would be an extra $ at the beginning of the equation.

I am trying to solve this problem by delving into the syntax files of both vimwiki and latex (tex.vim)

These lines 608-613 in syntax/vimwiki.vim caught my attention:

" LaTeX
call vimwiki#base#nested_syntax('tex', 
      \ g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'.
      \ '\%([[:blank:][:punct:]].*\)\?',
      \ g:vimwiki_rxMathEnd, 'VimwikiMath')
"}}}

as well as line 509

hi def link VimwikiMath Number

I am not quite familiar with vimscript, but some googling tells me this line links VimwikiMath group to Number group.

But how is the Number group related to the syntax highlight in tex.vim?

Inspecting tex.vim, I notice the following lines

syn region texMathZoneV matchgroup=Delimiter start="\\("            matchgroup=Delimiter    end="\\)\|%stopzone\>"          keepend concealends contains=@texMathZoneGroup
syn region texMathZoneW matchgroup=Delimiter start="\\\["           matchgroup=Delimiter    end="\\]\|%stopzone\>"          keepend concealends contains=@texMathZoneGroup

So I added

syn region texMathZoneU matchgroup=Delimiter start="{{\$"           matchgroup=Delimiter    end="}}\$\|%stopzone\>"         keepend concealends contains=@texMathZoneGroup

I also changed
syn cluster texMathZones contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ

to

syn cluster texMathZones        contains=texMathZoneU,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ

and added

HiLink texMathZoneU     texMath

Now the highlight of

{{$
a^b
}}$

works as expected in .tex files, but the problem in .wiki files persists...

Can anyone give an explanation, or simply fix the issue?

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants