maddy icon indicating copy to clipboard operation
maddy copied to clipboard

latex support?

Open nkeonkeo opened this issue 4 years ago • 3 comments

Can you add latex support?

inline formula: $...$ display formula: $$...$$

Don't escape the formula.

nkeonkeo avatar Jul 13 '20 23:07 nkeonkeo

Yeah, can do that. Just have to find time for it ;)

progsource avatar Oct 04 '20 16:10 progsource

I think it's easily possible by using https://www.mathjax.org/ .

In order to write support for a LaTeX rendering framework, it's needed to write a complete HTML generator (with both head and body tags).

NicusorN5 avatar Feb 11 '23 20:02 NicusorN5

With #42 the block format is supported, if you combine it with MathJax. For future versions it could be considered to parse the actual LaTeX code to svg directly.

Trying to add inline support resulted in non-backwards-compatible issues. For example, if the italic parser regex would be changed to something like

static std::regex re("(?!.*`.*|.*<code>.*|[^\\\\]*\\$.*)\\*(?!.*`.*|.*<\\/code>.*)([^\\*]*)\\*(?!.*`.*|.*<\\/code>.*|[^\\\\]*\\$.*)");

then writing Markdown like

some text \$a + b = 3\$ *test* \$a + b = 3\$

would make the italic still work, but

some text $a + b = 3$ *test* $a + b = 3$

would result in the italic text not being italic.

Because of that I postpone the introduction of LaTeX inline support for now, but hope, that adding the block support may help you already a little ;) If you happen to have an idea how to make it work via regex with inline support, feel free to open up a PR.

progsource avatar Jul 27 '23 13:07 progsource