Pandoc developer here. Two comments: (1) to convert equations pandoc uses the texmath library, which I also wrote (https://github.com/jgm/texmath). Compiling texmath with `-fexecutable` will give you a standalone executable that just converts the equation (and doesn't add the `<p>` element or anything extraneous). Compiling it with `-fserver` will give you a webserver that converts equations. (2) Regarding the bug, note that it's not an empty `<mo></mo>`. There's an invisible U+2061 character ("function application") inside. We don't want to take that out, but it looks like putting the `<mi>` and the `<mo>` together in an `<mrow>` will also solve the problem. I'll fix this.
seanhunter · 1h ago
The limit formatting the author doesn’t like isn’t a bug in pandoc I don’t think - it looks to me as if they have just written it ambiguously in latex.
If you write a limit as \lim_{n \to \infty} etc etc then LaTex gets to decide whether to write your limit in inline style (next to the limit) or below. If you want it always to be below then you need to write
\lim\limits_{n \to \infty}
It’s the same deal with summations and integrals.
satgo1546 · 1h ago
I love how Keyboard Maestro comes into play. Instead of some Markdown extension doing the conversion on render, the author selects and converts each equation manually. I think it's a good idea to keep MathML rather than LaTeX in Markdown source.
I have written an AutoHotkey script for my own use that does something similar, but for converting Markdown to HTML — so that I can write in Markdown, but fall back to embedded HTML easily if Markdown is not enough. Maybe I shall replace its pulldown_cmark backend with pandoc to get support for MathML.
bArray · 5h ago
One problem I ran into a long time ago (2021) is that MathML was not well supported in Chrome and other browsers, but seemed well supported in Firefox.
After trying many Pandoc options [1] I ended up selecting a very small implementation by Preet [2] which was some ~70kB [3] compared to other implementations at about 10x (i.e. MathJax [4]). I use it with the Polyfill to check if it is already supported. If you checkout the torture test, it really performs quite well [5].
In the future I still want to convert to SVG vectors (with bitmap backups) and include those instead, but I'm not yet pleased with the offerings. My concern with JS is that it seems to be on the way out, I think it will eventually go the way of Flash in favour of something else.
With the current solutions for rendering equations you either have this ridiculous wrapper around LaTeX or similar, or some other weirdness. If I get bored for a few days I might end up writing a parser to convert MathML to such outputs. It shouldn't take insane efforts to pass some torture tests.
GitHub has also switched to MathML recently (or I've just noticed it). It is a nice comeback.
esafak · 7h ago
From MathJax? Why, it's mature enough?
huijzer · 7h ago
Anyone here know whether there are other converters too? I like Pandoc but find it not so nice to run in production. I don’t remember why though.
omneity · 6h ago
Pandoc can be painful (mostly due to the complexity of all the tools it orchestrates in my opinion), but I find it very hard to beat once you get in non-trivial publishing territory and you refuse to use TeX/LaTeX-style processors.
The learning curve is worth it imo (if you often work on documents and publications).
If you write a limit as \lim_{n \to \infty} etc etc then LaTex gets to decide whether to write your limit in inline style (next to the limit) or below. If you want it always to be below then you need to write
\lim\limits_{n \to \infty}
It’s the same deal with summations and integrals.
I have written an AutoHotkey script for my own use that does something similar, but for converting Markdown to HTML — so that I can write in Markdown, but fall back to embedded HTML easily if Markdown is not enough. Maybe I shall replace its pulldown_cmark backend with pandoc to get support for MathML.
After trying many Pandoc options [1] I ended up selecting a very small implementation by Preet [2] which was some ~70kB [3] compared to other implementations at about 10x (i.e. MathJax [4]). I use it with the Polyfill to check if it is already supported. If you checkout the torture test, it really performs quite well [5].
In the future I still want to convert to SVG vectors (with bitmap backups) and include those instead, but I'm not yet pleased with the offerings. My concern with JS is that it seems to be on the way out, I think it will eventually go the way of Flash in favour of something else.
With the current solutions for rendering equations you either have this ridiculous wrapper around LaTeX or similar, or some other weirdness. If I get bored for a few days I might end up writing a parser to convert MathML to such outputs. It shouldn't take insane efforts to pass some torture tests.
[1] https://coffeespace.org.uk/projects/mathml-render.html
[2] https://github.com/pshihn
[3] https://github.com/pshihn/math-ml
[4] https://www.mathjax.org/
[5] https://pshihn.github.io/math-ml/examples/torture.html
The learning curve is worth it imo (if you often work on documents and publications).