pub struct Html {
    pub errors: Vec<Cow<'static, str>>,
    pub quirks_mode: QuirksMode,
    pub tree: Tree<Node>,
}
Expand description

An HTML tree.

Parsing does not fail hard. Instead, the quirks_mode is set and errors are added to the errors field. The tree will still be populated as best as possible.

Implements the TreeSink trait from the html5ever crate, which allows HTML to be parsed.

Fields

errors: Vec<Cow<'static, str>>

Parse errors.

quirks_mode: QuirksMode

The quirks mode.

tree: Tree<Node>

The node tree.

Implementations

Creates an empty HTML document.

Creates an empty HTML fragment.

Parses a string of HTML as a document.

This is a convenience method for the following:

use html5ever::driver::{self, ParseOpts};
use scraper::Html;
use tendril::TendrilSink;

let parser = driver::parse_document(Html::new_document(), ParseOpts::default());
let html = parser.one(document);

Parses a string of HTML as a fragment.

Returns an iterator over elements matching a selector.

Returns the root <html> element.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Note: does not support the <template> element.

The overall result of parsing. Read more

Handle is a reference to a DOM node. The tree builder requires that a Handle implements Clone to get another reference to the same node. Read more

Consume this sink and return the overall result of parsing. Read more

Signal a parse error.

Set the document’s quirks mode.

Get a handle to the Document node.

Do two handles refer to the same node?

What is the name of this element? Read more

Create an element. Read more

Create a comment node.

Append a DOCTYPE element to the Document node.

Append a node as the last child of the given node. If this would produce adjacent sibling text nodes, it should concatenate the text instead. Read more

Append a node as the sibling immediately before the given node. Read more

Detach the given node from its parent.

Remove all the children from node and append them to new_parent.

Add each attribute to the given element, if no attribute with that name already exists. The tree builder promises this will never be called with something else than an element. Read more

Get a handle to a template’s template contents. The tree builder promises this will never be called with something else than a template element. Read more

Mark a HTML <script> as “already started”.

Create a Processing Instruction node.

When the insertion point is decided by the existence of a parent node of the element, we consider both possibilities and send the element which will be used if a parent node exists, along with the element to be used if there isn’t one. Read more

Indicate that a node was popped off the stack of open elements.

Associate the given form-associatable element with the form element

Returns true if the adjusted current node is an HTML integration point and the token is a start tag. Read more

Called whenever the line number changes.

Indicate that a script element is complete.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.