# tl
**Repository Path**: wangkui35/tl
## Basic Information
- **Project Name**: tl
- **Description**: https://github.com/astral-sh/tl.git
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-03-25
- **Last Updated**: 2025-03-25
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# tl
tl is a fast HTML parser written in pure Rust.
- [Usage](#usage)
- [Examples](#examples)
- [SIMD-accelerated parsing](#simd-accelerated-parsing)
This crate (currently) does *not* strictly follow the full specification of the HTML standard, however this usually is not a problem for most use cases. This crate generally attempts to support most "sane" HTML. Not being limited by a specification allows for more optimization opportunities.
If you need a parser that can (very quickly) parse the typical HTML document and you need a simple API to work with the DOM, give this crate a try.
If you need a parser that closely follows the standard, consider using [html5ever](https://github.com/servo/html5ever), [lol-html](https://github.com/cloudflare/lol-html), or [html5gum](https://github.com/untitaker/html5gum).
## Usage
Add `tl` to your dependencies.
```toml
[dependencies]
tl = "0.7.8"
# or, with explicit SIMD support
# (requires a nightly compiler!)
tl = { version = "0.7.8", features = ["simd"] }
```
The main function is `tl::parse()`. It accepts an HTML source code string and parses it. It is important to note that tl currently silently ignores tags that are invalid, sort of like browsers do. Sometimes, this means that large chunks of the HTML document do not appear in the resulting tree.
```rust
let dom = tl::parse(r#"
Hello
"#, tl::ParserOptions::default()).unwrap(); let parser = dom.parser(); let element = dom.get_element_by_id("text") .expect("Failed to find element") .get(parser) .unwrap(); assert_eq!(element.inner_text(parser), "Hello"); ``` ## Examples