Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MathML and SVG namespaces not added correctly #1078

Open
dhouck opened this issue Mar 21, 2023 · 0 comments
Open

MathML and SVG namespaces not added correctly #1078

dhouck opened this issue Mar 21, 2023 · 0 comments

Comments

@dhouck
Copy link

dhouck commented Mar 21, 2023

Version: HTML Tidy for Linux version 5.7.45

Situation:
Consider the following HTML5 document, which produces no warnings at https://validator.w3.org/nu/ (Tidy can properly handle most plausible warnings I could make it generate, but for the purpose of isolating variables, I made it not generate any):

<!DOCTYPE html>
<html lang="en">
    <head>
        <link rel="stylesheet" href="https://fred-wang.github.io/mathml.css/mathml.css">
        <title>Circle equation</title>
    </head>
    <body>
        <p>
            The equation
            <math display=inline>
                <mi>y</mi><mo>=</mo><mo>±</mo>
                <msqrt>
                    <msup><mi>r</mi><mn>2</mn></msup>
                    <mo>-</mo>
                    <msup><mi>x</mi><mn>2</mn></msup>
                </msqrt>
            </math>
            produces a circle with radius <math display=inline><mi>r</mi></math>:
            </p>
        <svg width="10em" height="10em" viewBox="0 0 100 100">
            <desc>A circle</desc>
            <circle cx="50" cy="50" r="40" fill="none" stroke="blue" stroke-width="1" />
        </svg>
    </body>
</html>

I ran this through tidy -asxhtml.

Expected result:
A valid XML document containing HTML, as described in the HTML spec. In particular, namespaces of the svg and math elements and their descendants should be accurate.

Actual result:
I get the two spurious warnings mentioned in #1046, but it also does not add the proper namespace directives to the math or svg elements. It adds a document-wide xmlns directive, but math and svg are not actually elements in the html namespace, so these are incorrect; it should add xmlns attributes to these as well.

Further note:
I expect both this and #1046 share the same cause; in particular, Tidy is trying to treat these elements as though the were HTML elements, which they are not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant