Skip to content

MathML incorrect for LaTeX prime notation #254

@castedo

Description

@castedo

REPRO STEPS:

  1. Create doc.md
cat > doc.md <<'EOF'
$$
Z^p
$$

$$
Z^+
$$

$$
Z^\prime
$$

$$
Z'
$$

$$
Z\prime
$$
EOF
  1. Save an optional line of MathJax script:
cat > mathjax.md <<'EOF'
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/mml-chtml.js" type="text/javascript"></script>
EOF
  1. Generate MathML to be viewed with MathJax:
pandoc mathjax.md doc.md -s --mathml > mathjax-with-mathml.html
  1. Open mathjax-with-mathml.html in a browser.

RESULT:
The MathML generated by pandoc (in mathjax-with-mathml) is (edited for clarity):

<p> ... <msup><mi>Z</mi><mi>p</mi></msup>   <annotation>Z^p</annotation> ... </p>
<p> ... <msup><mi>Z</mi><mo>+</mo></msup>   <annotation>Z^+</annotation> ... </p>
<p> ... <msup><mi>Z</mi><mi>′</mi></msup>   <annotation>Z^\prime</annotation> ... </p>
<p> ... <mrow><mi>Z</mi><mi>′</mi></mrow>   <annotation>Z&#39;</annotation> ... </p>
<p> ... <mrow><mi>Z</mi><mi>′</mi></mrow><annotation>Z\prime</annotation> ... </p>

And then visually looking at the webpage, the result of Z' looks like Z\prime and not Z^\prime.

EXPECTED:
Output like what LaTeX and MathJax generate.

Specifically the MathML for Z' should be a <msup>, like what MathJax generates, and not <mrow>.

<p> ... <msup><mi>Z</mi><mi>p</mi></msup>   <annotation>Z^p</annotation> ... </p>
<p> ... <msup><mi>Z</mi><mo>+</mo></msup>   <annotation>Z^+</annotation> ... </p>
<p> ... <msup><mi>Z</mi><mi>′</mi></msup>   <annotation>Z^\prime</annotation> ... </p>
<p> ... <mrow><mi>Z</mi><mi>′</mi></mrow>   <annotation>Z&#39;</annotation> ... </p>
<p> ... <mrow><mi>Z</mi><mi>′</mi></mrow><annotation>Z\prime</annotation> ... </p>

Similarly, the visual result is not what LaTeX produces. The visual output of LaTeX for Z' looks like Z^\prime and not Z\prime.

I'll add more information and commentary separately in this thread.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions