retext-project / retext

ReText: Simple but powerful editor for Markdown and reStructuredText
GNU General Public License v2.0
1.88k stars 196 forks source link

Use KaTeX instead of MathJax #510

Open Momo-Coco opened 4 years ago

Momo-Coco commented 4 years ago

Is it any way to configure ReText to use KaTeX instead of MathJax? I am working in an environment where KaTeX is the only option and it would be great if I could use my favorite markdown editor.

mitya57 commented 4 years ago

Hi! Unfortunately it is not possible yet.

Can you share a detail why KaTeX is the only option? Will it be an option to download and unpack MathJax locally, and use it?

Momo-Coco commented 4 years ago

Thank you for your quick answer. The reason for asking about KaTeX is that the editor should support GitLab-style markdown, which AFAIK uses KaTeX. Now that you answered 'no', I'm thinking I might get by with just configuring ReText/MathJax to use GitLab-style $`...`$ and ```math...```. Is it possible to to that? And if it is possible, how can it be done?

mitya57 commented 4 years ago

Hi!

I added GitLab support to the math extension ReText uses. To upgrade it before I officially release it, use this command:

python3 -m pip install --upgrade --user https://github.com/mitya57/python-markdown-math/archive/master.zip

Then, you can use GitLab syntax in your markdown files:

<!-- Required extensions: mdx_math(use_gitlab_delimiters=1) -->

Inline: $` e^{i \pi} = -1 `$.

Standalone:
```math
e^{i \varphi} = \cos \varphi + i \sin \varphi


Please test and give your feedback, then I will release the update to PyPI.
Momo-Coco commented 4 years ago

It works! Thank you. It even works globally with mdx_math(use_gitlab_delimiters=1) Do you have a way to define shortcuts? (I mean without editing /usr/share/retext/ReText/editor.py if possible...)

mitya57 commented 4 years ago

It works! Thank you.

Thanks for confirming this, I have released python-markdown-math 0.7 to PyPI yesterday which has this functionality.

Do you have a way to define shortcuts?

No, unfortunately. Is there any specific shortcut you want to have?