Crate html_page

Source
Expand description

Construct and manipulate an HTML element represented using Rust types.

Conceptually, an element has a tag, optional attributes, and optional children. A child can consist of non-HTML text, or be an element of its own.

This crate aims to follow the WhatWG specification at https://html.spec.whatwg.org/.

§Example

use html_page::{Element, Tag};

let e = Element::new(Tag::P)
    .with_text("hello ")
    .with_child(Element::new(Tag::Strong).with_text("world"));
assert_eq!(e.serialize(), "<P>hello <STRONG>world</STRONG></P>");
assert_eq!(e.plain_text(), "hello world");

Structs§

Element
An HTML element.
HtmlPage
An HTML document (“page’),consisting of a head and a body element.
TextVisitor
A visitor to extract the text of an element and its children.

Enums§

AttributeValue
The value of an element attribute.
Content
Represent content in HTML.
Tag
The tag of an HTML5 element.

Traits§

Visitor
A read-only visitor for an HTML element.