PureHTML.TreeBuilder.ForeignContent (PureHTML v0.4.0)

View Source

The rules for parsing tokens in foreign content (SVG and MathML), the integration point tests that decide when the tree construction dispatcher applies them, and the insertion of foreign elements with their tag and attribute adjustments.

See: https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign

Summary

Functions

Whether there is an adjusted current node and it is not an element in the HTML namespace: the tokenizer's condition for a CDATA section.

Whether the tree construction dispatcher routes token to the rules for parsing tokens in foreign content.

Pops elements while the current node is not a MathML text integration point, an HTML integration point, or an element in the HTML namespace.

Returns true if the current element is an HTML integration point.

Inserts a foreign element in namespace ns with the SVG tag and foreign attribute adjustments applied. A self-closing tag is inserted and popped (its flag acknowledged); otherwise the element is pushed.

Processes token with the rules for parsing tokens in foreign content.

Functions

adjusted_current_node_foreign?(state)

Whether there is an adjusted current node and it is not an element in the HTML namespace: the tokenizer's condition for a CDATA section.

applies?(token, state)

Whether the tree construction dispatcher routes token to the rules for parsing tokens in foreign content.

close(state)

Pops elements while the current node is not a MathML text integration point, an HTML integration point, or an element in the HTML namespace.

html_integration_point?(map)

Returns true if the current element is an HTML integration point.

HTML integration points are foreign elements where content is parsed as HTML:

  • SVG: foreignObject, desc, title
  • MathML: mi, mo, mn, ms, mtext
  • MathML: annotation-xml with encoding="text/html" or "application/xhtml+xml"

insert_element(state, ns, tag, attrs, self_closing)

Inserts a foreign element in namespace ns with the SVG tag and foreign attribute adjustments applied. A self-closing tag is inserted and popped (its flag acknowledged); otherwise the element is pushed.

process(token, state)

Processes token with the rules for parsing tokens in foreign content.