Support standalone MathML files in MML format
https://bugs.webkit.org/show_bug.cgi?id=280682
Summary Support standalone MathML files in MML format
Vadim Makeev
Reported 2024-10-01 08:38:15 PDT
Created attachment 472751 [details] Standalone MathML file There’s a .mml file extension [mentioned in the MathML 4.0 spec](https://w3c.github.io/mathml/#encoding-names) for standalone MathML files, just like .svg for SVG. And just like SVG, it’s an XML-based format that requires the `xmlns` attribute with a certain value to work and doesn’t need the `xmlns` when inlined in HTML. ```xml <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> <msup> <mi>x</mi> <mn>2</mn> </msup> <mo>+</mo> <mi>y</mi> </mrow> </math> ``` ```xml <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"> <rect width="20" height="20" fill="green" /> </svg> ``` Today, all browsers support rendering MathML inlined into HTML, but currently, only Firefox supports rendering MML files. ```html <p> <math> <mrow> <msup> <mi>x</mi> <mn>2</mn> </msup> <mo>+</mo> <mi>y</mi> </mrow> </math> </p> ``` ```html <p> <svg width="20" height="20" viewBox="0 0 20 20"> <rect width="20" height="20" fill="green" /> </svg> </p> ``` The MML rendering in Firefox looks very similar to SVG: it takes the whole page, there’s XML in the view source and DOM in the DevTools, and it shows parsing error when the MML file is not well-formed. MML files also work when loaded in an iframe, but doesn’t work in `<img>`. Both Safari and Chrome show MML as plain text. See the attached MML file example. It’s not common to share MathML as standalone files. Still, it might be convenient/useful to store formulas in external files to reuse them in multiple content locations (inlined during build time, for example), just like SVG.
Attachments
Standalone MathML file (164 bytes, application/mathml+xml)
2024-10-01 08:38 PDT, Vadim Makeev
no flags
Vadim Makeev
Comment 1 2024-10-03 05:11:44 PDT
Correction: Safari doesn’t show plain text for MML files, it downloads them. Also, when renamed to .xml, both Safari and Chrome render MathML. Although they render `<math>` element centered, as it has `display="block"` attribute. Firefox renders `<math>` in the default inline mode. Experiments with serving `application/mathml+xml` MIME type with a server response didn’t help much.
Karl Dubost
Comment 2 2024-10-03 14:35:26 PDT
https://w3c.github.io/mathml/spec.html#encoding-names > MathML (generic): The instance may contain presentation MathML markup, content MathML markup, or a mixture of the two. > > File name extension: .mml > Media Type: application/mathml+xml > Windows Clipboard Flavor: MathML > Universal Type Identifier: public.mathml There is also https://w3c.github.io/mathml-docs/mathml-media-types/#media-types-mathml
Radar WebKit Bug Importer
Comment 3 2024-10-08 08:39:13 PDT
Note You need to log in before you can comment on or make changes to this bug.