progsource/maddy

latex support?

nkeonkeo opened this issue · 3 comments

Can you add latex support?

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

Don't escape the formula.

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

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).

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.