Expand description
An HTML parser that follows the WHATWG HTML Standard, written for Netweir and for speed.
Modules§
- css
- CSS selectors, as Selectors Level 4 defines them and browsers match them in a static page: parsed once, matched right to left.
- tokenizer
- The tokenizer, as section 13.2.5 of the HTML Standard describes it.
Structs§
- Document
- A parsed HTML document, or a fragment.
- Options
- How to parse.
- Parser
- Parses a document as it arrives, a piece at a time, into the tree
parse_withwould build from the whole: the same for any way of cutting the input up, with the same spans and errors when asked for. - Serialize
Options - How
Document::serialize_withwrites a node. The default is the HTML Standard’s serialization, byte for byte whatDocument::outer_htmlgives. Most fields are html5lib’s serializer options, under html5lib’s names. - Shadow
Root - A shadow root’s settings, as
attachShadowtakes them and a declarative<template shadowrootmode>sets them. - Syntax
Error - A parse error the HTML Standard defines, from
Document::errors. The parser recovered from it, as the spec says to; it’s for a linter or an editor to report.
Enums§
- AttrNs
- A namespaced attribute’s namespace, from the spec’s “adjust foreign
attributes” table;
Nonefor every ordinary attribute. - Edit
Error - Why an edit was refused.
- Kind
- What a node is, as
Document::kindreports it. - Ns
- Parse
Error - Why a parse returned no document.
- Quirks
- Shadow
Root Mode - Whether a shadow root’s host lets scripts reach it, from
shadowrootmodeorattachShadow’smode. - Slot
Assignment - How a shadow root’s slots get their nodes: by the
slotattribute of the host’s children, or only asDocument::assignsays.
Constants§
- MAX_
INPUT - The most input a document can hold. Spans keep offsets in 30 bits, and the parse buffer, which only holds copies of what the input says, stays well under that.
Functions§
- is_
html_ element - Whether
name(in any case) names an element of HTML, current or obsolete, or the root of SVG or MathML:div,marquee,svg; notrss. - named_
reference - The character(s) HTML’s named reference
namestands for, without the&and with or without the;as the table has it:nbsp;gives U+00A0. - parse
- Parses a whole document. A leading byte order mark (U+FEFF) is dropped, as decoding the page would have.
- parse_
fragment - Parses
htmlas the contents of an element namedcontextin namespacens, asinnerHTMLdoes. - parse_
fragment_ with - Parses
htmlasparse_fragmentdoes, within a size limit and an optional budget, asparse_withdoes for a whole document. - parse_
with - Parses a whole document, within a size limit and an optional budget.
- tag_
number - The number
Document::known_taggives elements namedname(lowercase), if the parser knows the tag.
Type Aliases§
- NodeId
- A node’s index in its document; the document itself is node 0.