Crate tl[][src]

tl is an efficient and easy to use HTML parser written in Rust.

It does minimal to no copying during parsing by borrowing parts of the input string. Additionally, it keeps track of parsed elements and stores elements with an id attribute in an internal HashMap, which makes element lookups by ID/class name very fast.

Examples

Finding an element by its id attribute and printing the inner text:

let input = r#"<p id="text">Hello</p>"#;
let dom = tl::parse(input);

let element = dom.get_element_by_id("text").expect("Failed to find element");

println!("Inner text: {}", element.inner_text());

Bytes

Some methods return a Bytes struct, which is an internal struct that is used to borrow a part of the input string. This is mainly used over a raw &[u8] for its Debug implementation.

Structs

Attributes

Stores all attributes of an HTML tag, as well as additional metadata such as id and class

Bytes

A wrapper around a DST-slice

HTMLTag

Represents a single HTML element

VDom

VDom represents a Document Object Model

Enums

HTMLVersion

HTML Version (<!DOCTYPE>)

Node

An HTML Node

Traits

AsBytes

A trait for converting a type into Bytes

Functions

parse

Parses the given input string

Type Definitions

Tree

A list of shared HTML nodes