Skip to content

Describe how to layout DOM elements violating HTML5 model #57

@fred-wang

Description

@fred-wang

cc @bfgeek

This was discussed during the previous meeting.

The HTML parser has some restrictions on the DOM tree but one can always use JS API to insert elements where they want: https://mathml-refresh.github.io/mathml-core/#html-and-svg

Some cases:

  • non-MathML elements used inside MathML elements that only accept MathML children (e.g. <math><p>x</p></math>. What WebKit and Chromium do is not to create any layout box i.e. don't render anything. Firefox renders something. Note that HTML has very precise definition (e.g. only allowing phrasing element or annotation element with special encoding values) that we probably want to simplify as that's adding complexity Synchronization with WHATWG HTML5 spec mathml#145 -- I think we can either not render anything (like chromium and webkit do) or define a MathML box for such non-MathML element from its CSS margin box (which as @rwlbuis pointed out is probably more consistent with the idea of trying to render everything).

  • text nodes inside MathML elements that don't accept text (e.g. <math>x</math>). Again, WebKit and Chromium don't create any layout box i.e. don't render anything contrary to Firefox. The HTML and MathML3 spec say they should be rendered as if they were wrapped in a <mtext>, but not sure that's worth it Synchronization with WHATWG HTML5 spec mathml#145 -- And we can again probably define a MathML box for such non-MathML element from its CSS margin box.

  • A MathML element that is an invalid childr of another MathML element e.g. <math><mfrac><annotation>x</annotation><mn><mtext>1</mtext></mn></math> or <mrow><math></mrow>. The HTML and MathML3 spec say they should be rendered as an merror with appropriate message. This is a bit similar to Interoperable handling of invalid markup  #136 where we instead decided to render something. I think in general since the box layout is recursive we can just render things as already specified by the spec. Probably some care has to be taken for the edge case of <math> and token elements though.

  • MathML elements, other than the <math> root, inside non-MathML elements. e.g. <p><mn>2</mn></p>. I think we can allow these cases too as we already define a CSS box for the MathML ones.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions