TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

MathML with Pandoc

58 点作者 goranmoomin10 天前

7 条评论

fiddlosopher10 天前
Pandoc developer here. Two comments: (1) to convert equations pandoc uses the texmath library, which I also wrote (<a href="https:&#x2F;&#x2F;github.com&#x2F;jgm&#x2F;texmath">https:&#x2F;&#x2F;github.com&#x2F;jgm&#x2F;texmath</a>). Compiling texmath with `-fexecutable` will give you a standalone executable that just converts the equation (and doesn&#x27;t add the `&lt;p&gt;` element or anything extraneous). Compiling it with `-fserver` will give you a webserver that converts equations. (2) Regarding the bug, note that it&#x27;s not an empty `&lt;mo&gt;&lt;&#x2F;mo&gt;`. There&#x27;s an invisible U+2061 character (&quot;function application&quot;) inside. We don&#x27;t want to take that out, but it looks like putting the `&lt;mi&gt;` and the `&lt;mo&gt;` together in an `&lt;mrow&gt;` will also solve the problem. I&#x27;ll fix this.
seanhunter10 天前
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.<p>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<p>\lim\limits_{n \to \infty}<p>It’s the same deal with summations and integrals.
评论 #43915584 未加载
bArray10 天前
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.<p>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].<p>In the future I still want to convert to SVG vectors (with bitmap backups) and include those instead, but I&#x27;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.<p>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&#x27;t take insane efforts to pass some torture tests.<p>[1] <a href="https:&#x2F;&#x2F;coffeespace.org.uk&#x2F;projects&#x2F;mathml-render.html" rel="nofollow">https:&#x2F;&#x2F;coffeespace.org.uk&#x2F;projects&#x2F;mathml-render.html</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;pshihn">https:&#x2F;&#x2F;github.com&#x2F;pshihn</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;pshihn&#x2F;math-ml">https:&#x2F;&#x2F;github.com&#x2F;pshihn&#x2F;math-ml</a><p>[4] <a href="https:&#x2F;&#x2F;www.mathjax.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.mathjax.org&#x2F;</a><p>[5] <a href="https:&#x2F;&#x2F;pshihn.github.io&#x2F;math-ml&#x2F;examples&#x2F;torture.html" rel="nofollow">https:&#x2F;&#x2F;pshihn.github.io&#x2F;math-ml&#x2F;examples&#x2F;torture.html</a>
JadeNB8 天前
The author&#x27;s construction for a piecewise definition will work, but the preferred LaTeX construct is `\begin{cases} … \end{cases}`. (Actually, I think it&#x27;s from AMSLaTeX.) I believe it always left aligns columns, and doesn&#x27;t obey multiple `&amp;`s, so it doesn&#x27;t exactly reproduce the author&#x27;s construction—but, from my point of view, that means that the specifics of the author&#x27;s construction are not standard practice, at least within the domain of the AMS. Otherwise it would be formatted as<p><pre><code> \[ f(x) = \begin{cases} -1, &amp; x &lt; 0 \\ 0, &amp; x = 0 \\ 1, &amp; x &gt; 0. \end{cases} \]</code></pre>
satgo154610 天前
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&#x27;s a good idea to keep MathML rather than LaTeX in Markdown source.<p>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.
ayhanfuat10 天前
GitHub has also switched to MathML recently (or I&#x27;ve just noticed it). It is a nice comeback.
评论 #43882781 未加载
huijzer10 天前
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.
评论 #43882910 未加载
评论 #43882888 未加载