Menu

#204 MathML fragment is broken

v2.30
open
None
5
2023-06-19
2018-06-25
Dan
No

In a HTML5 document, the MathML fragment is completely broken after cleanup. For example:

<!DOCTYPE html>
<html lang="fr">
    <head>
        <title>HTML5 SVG and MathML with no namespaces should be rendered in the output.</title>
    </head>
    <body>

        <h1>The quadratic formula</h1>
        <p>
            <math>
                <mi>x</mi>
                <mo>=</mo>
                <mfrac>
                    <mrow>
                        <mo form="prefix"></mo>
                        <mi>b</mi>
                        <mo>±</mo>
                        <msqrt>
                            <msup>
                                <mi>b</mi>
                                <mn>2</mn>
                            </msup>
                            <mo></mo>
                            <mn>4</mn>
                            <mo></mo>
                            <mi>a</mi>
                            <mo></mo>
                            <mi>c</mi>
                        </msqrt>
                    </mrow>
                    <mrow>
                        <mn>2</mn>
                        <mo></mo>
                        <mi>a</mi>
                    </mrow>
                </mfrac>
            </math>
        </p>
        <h1>My first SVG</h1>

        <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
            <title>This is the title</title>
            <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4"
                fill="yellow" />
        </svg>
    </body>
</html>

The result fragment is:

  <math
                  xmlns="http://www.w3.org/1998/Math/MathML">
                  <mi>x</mi>
                  <mo>=</mo>
                  <mfrac> </mfrac>
                  <mrow>
                    <mo
                      form="prefix"></mo>
                    <mi>b</mi>
                    <mo>±</mo>
                    <msqrt> </msqrt>
                    <msup>
                      <mi>b</mi>
                      <mn>2</mn>
                    </msup>
                    <mo></mo>
                    <mn>4</mn>
                    <mo></mo>
                    <mi>a</mi>
                    <mo></mo>
                    <mi>c</mi>
                  </mrow>
                  <mrow>
                    <mn>2</mn>
                    <mo></mo>
                    <mi>a</mi>
                  </mrow>
                </math>

Please note how the "mfrac", or "msqrt" is closed before its actual content.

Thank you,
Dan

Discussion

  • Dan

    Dan - 2018-06-25

    In 2.10 it works fine.

     
  • Scott Wilson

    Scott Wilson - 2018-06-25

    Hi Dan,

    Thanks for the report - I can confirm the issue.

    This can be fixed by uncommenting the following line in Html5TagProvider:

    tagInfo.setAssumedNamespace("http://www.w3.org/1998/Math/MathML");
    

    This functionality was removed as it was causing some other issues, but I think it can be reinstated.

    S

     
  • Scott Wilson

    Scott Wilson - 2019-09-04
    • Group: v2.22 --> v2.24
     
  • Scott Wilson

    Scott Wilson - 2020-04-29
    • Group: v2.24 --> v2.25
     
  • Scott Wilson

    Scott Wilson - 2021-09-24
    • Group: v2.25 --> v2.26
     
  • Scott Wilson

    Scott Wilson - 2023-04-29
    • Group: v2.26 --> v2.29
     
  • Scott Wilson

    Scott Wilson - 2023-06-19
    • Group: v2.29 --> v2.30
     

Log in to post a comment.

MongoDB Logo MongoDB