lervag / wiki-ft.vim

Simple Vim filetype plugin for wiki-files
MIT License
14 stars 5 forks source link

Enhance math support #2

Closed j1-lee closed 3 years ago

j1-lee commented 3 years ago

Hi, I am trying out wiki.vim and wiki-ft.vim today, and I like it!

I would like to ask for some enhancement regarding math in wiki; there are two issues, which are shown in the following example.

Minimal example code

minimal.vim

call plug#begin()
Plug 'lervag/vimtex'
Plug 'lervag/wiki.vim'
Plug 'lervag/wiki-ft.vim'
call plug#end()

" The following line would show that $$...$$ region is well-supported by pandoc, even when one wants to export to an html file.
" let g:wiki_export = {'ext': 'html', 'args': '--mathjax --standalone'}

minimal.tex

This code
```tex
\begin{aligned}
e &= \lim_{n\to\infty} \left(1 + \frac{1}{n}\right)^n\\
  &= \sum_{n=0}^\infty \frac{1}{n!}.
\end{aligned}
```
will produce the following:
$$
\begin{aligned}
e &= \lim_{n\to\infty} \left(1 + \frac{1}{n}\right)^n\\
  &= \sum_{n=0}^\infty \frac{1}{n!}.
\end{aligned}
$$

Observed behavior

Screenshot at 2021-01-04 19-01-05

  1. The multi-line math region

    $$
    ...
    $$

    is not highlighted.

  2. As we can see, when combined with lervag/vimtex, the fence part of the tex code block is concealed to . (This does not happen when vimtex turned off.)

Expected behavior

  1. I hope the multi-line math region to nest tex syntax. As $$...$$ math region is supported by pandoc markdown (as well as other markdown variants as well), I think this is not too a far-fetched enhancement; instead, it might be useful for writing wiki pages that involve some small math. (Note that one needs to use $$...$$, not pre block, in order to show the processed equation in the exported pdf or html documents).
  2. I hope the code block fences to be not subject to the syntax nested in the block.

Thank you!

lervag commented 3 years ago
  1. Seems fair, I'll look at it.

  2. Should be solved now. Note that the reason for the "glitch" is because the entire fenced region allows tex syntax, and you have set conceallevel=2 and conceals activated. I don't know a general way to avoid the tex syntax to match also on the fences, but I've updated to ignore the conflicting texLigature group.

lervag commented 3 years ago

Can you test now?

j1-lee commented 3 years ago

This is great, thank you!

lervag commented 3 years ago

Glad you like it!