Open TheThirdOne opened 7 years ago
Related functionality / discussion https://github.com/sampathsris/marked-tex-renderer https://github.com/chjj/marked/issues/722 https://github.com/chjj/marked/pull/799
One option that might be easy is switching to kramed, a fork of marked with some changes, including proper math support. It uses kramdown math syntax — $$
delimeters for both inline and display math (https://github.com/GitbookIO/kramed/blob/master/test/tests/math.text).
If not, simplest implementation-wise are literal-based math syntaxes, like what you wanted.
Their beauty is you don't really need to modify/hook the renderer; I believe you could run marked (or any markdown rendered) as-is, then you look for code
tags with class="texmath"
and post-process those.
Inline math is trickier as there is no agreed syntax to specify "language" of inline literals. For instance Gitlab went with $`a^2+b^2`$
syntax.
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4638 for how they did this.
I'm collecting math-in-markdown syntaxes at https://github.com/cben/mathdown/wiki/math-in-markdown.
It would be nice to be able to include math mode latex in presentations.
I was thinking of overloading code blocks to hook into a latex renderer, but when looking through the code, I didn't see an easy way to put a custom renderer for marked.
More generally having a quick way to put in a custom renderer would allow a variety of small extensions to be made.