https://github.com/spider-rs/html2md
Fast HTML to markdown lib for Rust
https://github.com/spider-rs/html2md
html html2md markdown rust
Last synced: 8 months ago
JSON representation
Fast HTML to markdown lib for Rust
- Host: GitHub
- URL: https://github.com/spider-rs/html2md
- Owner: spider-rs
- License: mit
- Created: 2024-09-21T12:57:13.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-03T15:16:23.000Z (over 1 year ago)
- Last Synced: 2025-01-08T09:19:10.417Z (over 1 year ago)
- Topics: html, html2md, markdown, rust
- Language: HTML
- Homepage: https://docs.rs/fast_html2md/latest/html2md/
- Size: 1.2 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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`:
```sh
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:
```rust
let md = html2md::rewrite_html("
JAMES
", 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:
```rust
let md = html2md::rewrite_html_streaming("
JAMES
", false).await;
assert_eq!(md, "JAMES");
```
### Using the Scraper
For a different approach, enable the `scraper` feature:
```rust
let md = html2md::parse_html("
JAMES
", 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`](https://docs.rs/html5ever/latest/html5ever/) 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`](https://docs.rs/lol_html/latest/lol_html/). This project is actively used in production at [Spider](https://spider.cloud).
## License
This project is licensed under the MIT License.