rustedbytes-tl
A lightweight HTML parser written in Rust. It borrows input bytes and offers
allocation-free bounded parsing by default, or heap-backed DOMs and CSS queries
with std. The Rust crate is imported as tl.
This README describes the current Git source. The source contains breaking changes since the published 0.2.0 API;
the first release containing them must be 0.3.x or later.
See Cargo.toml for the version selected for the next release.
The published 0.2.0 API reference
does not describe all APIs below. Generate current API docs with
cargo doc --features entities --open.
Getting started
Use the current source with heap-backed parsing:
[]
= { = "https://github.com/RustedBytes/rustedbytes-tl", = ["std"] }
Commit your application's Cargo.lock to retain the resolved Git revision.
#
Keep html alive for every use of the borrowed DOM. If the DOM must own its
input, use the safe tl::VDomGuard::parse(String, ParserOptions) constructor.
See the usage guide for owned input, attributes, decoded text,
query errors and bounded parsing.
Features
| Feature | Behavior |
|---|---|
| Default (none) | no_std, no allocation; explicit capacities in parse; bounded simple selectors |
std |
Heap-backed storage, owned DOMs, text extraction, structural CSS selectors |
entities |
Implies std; adds character-reference decoding through decoded_inner_text |
portable-simd |
Requires nightly Rust; optional SIMD parsing path, combinable with the above |
__INTERNALS_DO_NOT_USE exposes instrumentation internals and is not a supported
application feature. Stable builds should select features explicitly rather
than use --all-features, which enables nightly-only portable-simd.
Scope and documentation
The parser does not implement the complete HTML5 tree-building algorithm.
Malformed HTML can produce a different tree from a browser; omitted tbody
elements are not inserted. CSS support is a subset, and text extraction does
not implement browser layout or visibility rules. HTML parsing and text
extraction do not sanitize untrusted content.
- Usage guide: executable examples and API behavior.
- Development guide: feature checks, docs, benchmarks and troubleshooting.
- Migration and silkworm compatibility: supported selectors and remaining compatibility work.
- Rust audit: safety fixes and measured performance, with methodology and limits.
Provenance and license
Forked from astral-tl and extended for bounded
no_std parsing and RustedBytes consumers. Licensed under MIT; see LICENSE.