yzhang-gh / vscode-markdown

Markdown All in One
https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one
MIT License
2.93k stars 325 forks source link

Support MathJax in addition to KaTeX #531

Open yzhang-gh opened 5 years ago

yzhang-gh commented 5 years ago

Any chance to add MathJaX support in addition to KaTeX? Like letting the user to select the Math Rendering Engine?

MathJaX is almost fully compliant with LaTeX while KaTeX misses few abilities.

Originally posted by @RoyiAvital in https://github.com/yzhang-gh/vscode-markdown/issues/106#issuecomment-468934680

yzhang-gh commented 5 years ago

Hi @RoyiAvital, thanks for the feedback.

There is a workaround now (use MathJax scripts and export it to HTML). For example,

<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

\\(\alpha\\)

Remember to use \\( and \\[ rather than $ and $$.

The only disadvantage is you cannot see the preview inside VSCode as it disables scripts for security concerns. I suggest using markdown.extension.print.onFileSave option and Live Server extension.

mathjax

RoyiAvital commented 5 years ago

As I wrote in the other issue, I really think this feature will make this extension perfect for students as alternative to LaTeX. Yet in that case KaTeX won't cut it. it has too many limitations and missing features.

It will be great to have MathJaX support in addition to KaTeX. As the other features in this package are amazing (I like specifically all the flexibility with TOC).

PierreMarchand20 commented 5 years ago

Just out of curiosity, what are the missing features of KaTeX ?

You could also ask them to add them, I mean the advantage of KaTeX is that it is really fast, which may be convenient while taking notes.

RoyiAvital commented 5 years ago

On modern Chrome the speed difference isn't an issue. MathJaX has support for all environments of LaTeX while KaTeX doesn't. It also doesn't have the reference and labeling system of MathJaX.

We have written many times about features of KaTeX but they are not easy to implement in KaTeX. I guess due to the design choices made there.

If you want to have a true replacement for LaTeX in MarkDown, you need MathJaX.

yzhang-gh commented 5 years ago

@RoyiAvital I agree it might be a good addition. It is just because I don't much time for it. BTW, we haven't got a new version of this extension for near 3 months 😅.

RoyiAvital commented 4 years ago

@yzhang-gh , I see new features in the extension (Great!). Any chance to give this another thought?

It is the only blocker for me to use it as my daily MarkDown driver for University.

Thank You.

yzhang-gh commented 4 years ago

Actually, most of those features come from PRs (or only require a few tweaks to the source code).

MathJax support is not a "small" feature. It requires extra dependency and needs testing. For comparison, supporting \(\) and \[\] delimiters seems to be a more popular feature (#552) and easier to implement. (However, no ETA too. 😑)

I would suggest using Markdown+Math plugin which is more dedicated to math support. I'm not sure whether it is compatible with this extension. But I can add an option to disable math support of this one. It is much easier.

RoyiAvital commented 4 years ago

Markdown+Math use KaTeX as well instead of MathJaX.

Can't the MathJaX functionality be borrowed from other Extensions? MarkDown Preview Enhanced is using MathJaX. Could their code be borrowed?

yzhang-gh commented 4 years ago

Markdown Preview Enhanced is using MathJaX. Could their code be borrowed?

It goes for an entirely different direction, providing a standalone preview, rather than contribute to the VSCode's default one.

Since you have mentioned it, why not just use it 😳? It is compatible with this extension (it has its own preview window and supports exporting to PDF/HTML)

RoyiAvital commented 4 years ago

I am using it. But your extension has many features I'd like to have.

yzhang-gh commented 4 years ago

Yep, I have seen many people using the two extensions together. This extension provides the general features and the MPE enables many useful Markdown dialects.

RoyiAvital commented 4 years ago

I'm not sure I'm following. Which one will render the output, this one or MPE? MPE uses MathJaX (Can be configured) while this uses the limited KaTeX. When both implement the same feature, which one will be the effective one?

yzhang-gh commented 4 years ago

https://shd101wyy.github.io/markdown-preview-enhanced/#/usages image

For this extension, it is ctrl+shift+v/ctrl+k v.

RoyiAvital commented 4 years ago

I can guarantee you that Ctrl + k, v is what's used to enable the preview for MPE on Visual Studio Code:

image

yzhang-gh commented 4 years ago

Alright, you may not be very familiar with VSCode (and the MPE's docs are not clear) so I tried it out for you.

You need to invoke the toggle-preview command from the command palette because the assigned keybindings are conflicted.

image

image

You can reassign those keybindings as you wish (see https://code.visualstudio.com/docs/getstarted/keybindings).

PeterWang-dev commented 2 years ago

Any update about this function?

mathematicsformisfits commented 1 year ago

Adding to this request. MathJax has full accessibility support, KaTeX has none.