40 releases
0.0.44 | Jan 27, 2025 |
---|---|
0.0.42 | Jan 25, 2025 |
0.0.41 | Dec 3, 2024 |
0.0.39 | Nov 25, 2024 |
0.0.9 | Dec 28, 2023 |
#1379 in Parser implementations
1,141 downloads per month
Used in 2 crates
(via spider_transformations)
105KB
2.5K
SLoC
fast_html2md
The fastest Rust library for transforming HTML into Markdown. Designed for performance and ease-of-use in Rust projects.
Installation
Add fast_html2md
to your Cargo.toml
:
cargo add fast_html2md
Usage
Below are examples to get started quickly. The library provides several methods depending on your needs.
Using the Rewriter (Default)
With the default rewriter
feature, recommended for high performance:
let md = html2md::rewrite_html("<p>JAMES</p>", false);
assert_eq!(md, "JAMES");
With Async Streaming
For handling large or concurrent workloads, use async streaming with the stream
and rewriter
feature. Ensure you have a tokio async runtime:
let md = html2md::rewrite_html_streaming("<p>JAMES</p>", false).await;
assert_eq!(md, "JAMES");
Using the Scraper
For a different approach, enable the scraper
feature:
let md = html2md::parse_html("<p>JAMES</p>", false);
assert_eq!(md, "JAMES");
Features
- rewriter: High performance transformation using the
rewriter
feature (default). - scraper: Alternative approach for HTML parsing with the
scraper
feature. - stream: enables streaming chunks for rewriter.
About
The features are split to help you choose the library you need. If your project heavily depends on scraper
and you need to keep the binary small, you can enable just that feature flag. The same applies to the rewriter
feature using lol_html
. This project is actively used in production at Spider.
License
This project is licensed under the MIT License.
Dependencies
~8–16MB
~260K SLoC