joplin-rich-markdown icon indicating copy to clipboard operation
joplin-rich-markdown copied to clipboard

[Feature]: Preview for KaTex (math)

Open vsimkus opened this issue 2 years ago • 10 comments

Hi Caleb, great plugin! Do you have any plans for adding support for previewing math expressions? This is the main feature missing from this plugin for my use case :)

vsimkus avatar Aug 14 '21 11:08 vsimkus

Thanks! Yes, I do plan on adding katex rendering. The current plan is to include the Joplin renderer in the plugin, and use it to render images, tables, katex and anything else that will benefit.

CalebJohn avatar Aug 14 '21 19:08 CalebJohn

This package seems enough for rendering the math: https://github.com/SamyPesse/codemirror-widgets

SeptemberHX avatar Jun 04 '22 07:06 SeptemberHX

@SeptemberHX it can be rendered the same as an image. My holdup is that i want to support all Joplin special forms (mermaid, katex, etc.) without doing each individually. Ideally the plugin would also support other plugins, but I'm not sure if that's possible with the plugin system, so might not ever get there.

CalebJohn avatar Jun 05 '22 01:06 CalebJohn

I think the image style renderer is not suitable for math because it still shows the ![]() things.

For math, it looks very messy with lots of inline math in a paragraph. I think we need to hide raw katex string and show rendered results instead.

SeptemberHX avatar Jun 05 '22 13:06 SeptemberHX

I successfully rendered katex inline math string to equation in the markdown editor. However, I notice serious performance issues when there are many rendered equations in the editor: It can take about 1 second to show your input. I think the problem maybe caused like https://github.com/codemirror/codemirror5/issues/5873

SeptemberHX avatar Jun 11 '22 08:06 SeptemberHX

I think you can render to an image and display that instead. It should perform better.

CalebJohn avatar Jun 11 '22 17:06 CalebJohn

I think you can render to an image and display that instead. It should perform better.

Yes, I also think images should help. But unfortunately, I haven't found the solutions to convert katex rendered results to an image. There are some discussions about svg image as katex output in Katex repo, but currently there is no implementation for it.

SeptemberHX avatar Jun 13 '22 02:06 SeptemberHX

It looks like you might be able to use a generic tool like html2canvas for this. Although that specific one is in a beta state.

CalebJohn avatar Jun 14 '22 02:06 CalebJohn

It seems a good tool. I also check the obsidian's editor since it has already supported live preview markdown editor. It also directly insert the dom elements for rendered math, but it performs much better. Maybe it is related to codemirror 6 and mathjax.

SeptemberHX avatar Jun 15 '22 07:06 SeptemberHX

@CalebJohn, I am sorry for nagging. I wonder whether there is any progress with the KaTeX-rendering support. (By the way, indeed this plugin is awsome and finally I can get rid of the preview ~~pane~~pain and save some screen space. Thank you for that 😃).

are-scenic avatar Jul 26 '22 09:07 are-scenic