Skip to content

$ symbol in Display Math #7942

@PassionPenguin

Description

@PassionPenguin

Explain the problem.

I've made a filter to convert Math into svg with lua + latex + dvisvgm, and since latex cannot recognize CJK chars in either mhchem or chemfig, i have to quote these chars with \text{}, but since this is a math-mode control sequence, i have to quote it with $$ again...

Now with the quoted latex code it works in latex parser, but rise a new problem: pandoc seems to parse inline-math first than display-math, causing the whole latex code not parsed and the output is like this:

<p>$$ \ce{<span
class="math inline">$\underset{\ce{CO2}}{\ce{6[1C]}}$</span> + 6[5C]
-&gt; <span
class="math inline">$\underset{\text{3-磷酸甘油酸}}{\ce{12[3C]}}$</span>}\
\ce{12[3C] -&gt;[ATP] <span
class="math inline">$\underset{\text{1,3-二磷酸甘油酸}}{\ce{12[3C]}}$</span>}\
\ce{12[3C] -&gt;[NaDPH] <span
class="math inline">$\underset{\text{3-磷酸甘油醛/二羟丙酮磷酸}}{\ce{12[3C]}}$</span>}\
\ce{<span
class="math inline">$\underset{3-磷酸甘油醛}{\ce{2[3C]}}$</span>
-&gt;[\text{酶}] <span
class="math inline">$\underset{\text{葡萄糖}}{\ce{1[6C]}}$</span>}\
\ce{10[3C] -&gt;[\text{酶}][ATP] 6[5C]} $$</p>

Reproduce

tmp.md:

$$
\ce{$\underset{\ce{CO2}}{\ce{6[1C]}}$ + 6[5C] -> $\underset{\text{3-磷酸甘油酸}}{\ce{12[3C]}}$}\\
\ce{12[3C] ->[ATP] $\underset{\text{1,3-二磷酸甘油酸}}{\ce{12[3C]}}$}\\
\ce{12[3C] ->[NaDPH] $\underset{\text{3-磷酸甘油醛/二羟丙酮磷酸}}{\ce{12[3C]}}$}\\
\ce{$\underset{3-磷酸甘油醛}{\ce{2[3C]}}$ ->[\text{酶}] $\underset{\text{葡萄糖}}{\ce{1[6C]}}$}\\
\ce{10[3C] ->[\text{酶}][ATP] 6[5C]}
$$

shell command:

pandoc --lua-filter=filters\texsvg.lua -s 'tmp.md' -o tmp.html -f commonmark_x

Pandoc version?
pandoc.exe 2.17.1.1
Compiled with pandoc-types 1.22.1, texmath 0.12.4, skylighting 0.12.2,
citeproc 0.6.0.1, ipynb 0.2
User data directory: C:\Users\Hoarfroster\AppData\Roaming\pandoc
Copyright (C) 2006-2022 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions