Skip to main content

can_contain_sym

Function can_contain_sym 

Source
pub fn can_contain_sym(tag: SymStr, child: SymStr) -> bool
Expand description

The single faithful containment check (Perl Common/Model.pm::canContain), keyed on interned SymStr names — the arena’s native currency. This is the canonical implementation; can_contain is a thin &str wrapper over it.

It is the entry point the serializer’s #PCDATA indentation test (Document::serialize_into) and the digestion auto-open/close logic use, so it stays allocation-lean: the common exact-match branch interns nothing, and the negation/namespace-wildcard probes fire only when the exact child is absent from the content model.

The ns:* namespace-wildcard fallback (below) is why a FOREIGN element whose content model is a wildcard — ltx:rawhtml’s xhtml:*, svg:* — is handled correctly: it has no exact tagprop entry, so an exact-match-only check wrongly answered can_contain(xhtml:b, #PCDATA) == false, and the serializer then treated mixed HTML content as block and injected indentation whitespace that HTML treats as significant (<xhtml:b>\n bold </xhtml:b>). arXiv/html_feedback#680 (xworld21).