xlink:href is prefix = Some("xlink"). The prefix is kept unresolved:resolving it needs the xmlns declarations in scope, which is a documentquestion and not a markup one.
The two are identical to a browser and different to a person reading adiff, so the tree keeps the distinction and the printer decides what to dowith it. Quoting style is deliberately NOT kept: Pretty alwaysdouble-quotes and Minified drops the quotes where that is legal, the sameway the CSS printer normalises 'x' to "x".
What could not be parsed, kept so that the tree covers the whole source.
text is the exact source the node replaced. Keeping it is what lets theprinter echo an unparsable region verbatim instead of deleting it -- a pagewith one templating directive the parser has never seen should come backwith that directive still in it.
You cannot print an element back without knowing this, and no other fieldcan be made to say it. It is the same argument LayerRule::body makes onthe CSS side: the alternatives are different constructs, not one constructwith an optional part.
A <!-- ... -->. text is the body, without the delimiters.
Comments are first-class nodes rather than trivia attached to a neighbour.Conditional comments, <!-- /ko --> and every framework that hides adirective in one depend on it, and the CSS module's decision to drop themthrough the notation is the one lossy spot this module does not repeat.
One type rather than two, because a fragment is a document whose childrenhappen not to include a doctype, and every operation either would support isthe same operation. html5ever needs the distinction because its tree builderruns different insertion modes for the two; a markup parser has no insertionmodes to run.
Not decoration: it decides four things that are otherwise ambiguous in thesame bytes -- whether /> closes an element or is ignored, whether anattribute name is lowercased or table-adjusted, whether <![CDATA[ is CDATAor a bogus comment, and whether <title> holds text or elements.
The children of a node, empty for everything that cannot have any.
A total function rather than an option, because every caller that walks atree wants to recurse without asking first, and "a text node has nochildren" is not a case worth making them handle.
A separate node from Text because it is not text: no reference resolves init, nothing in it is escaped on the way out, and the printer must refuse toemit a body containing the element's own end tag rather than escaping it,because there is no escape.
The name is NORMALISED -- ASCII-lowercased in HTML, case-adjusted by tablein SVG and MathML -- so that <DIV> and <div> are one node, and<LINEARGRADIENT> and <linearGradient> are the one that exists. Case isnot a semantic difference in either vocabulary, which is why this normaliseswhere Text::raw preserves.
raw is the source spelling, kept when decoding was not the identity. Itexists for the reason Number::repr exists in the CSS tree: a formatterasked to reindent a file must not also rewrite every entity in it, andturning into an invisible byte is a change a reviewer cannot seeand a reader cannot undo.
A semantic markup tree for MoonBit: HTML, SVG and MathML, with a tolerant parser, a printer with pretty, compact and minified modes, and structured diagnostics