26 releases (9 breaking)

0.10.2 Dec 10, 2024
0.10.0 Oct 16, 2024
0.9.1 Jun 21, 2024
0.7.0 Mar 30, 2024

#860 in Parser implementations

Download history 1/week @ 2024-12-21 4/week @ 2025-01-04 11/week @ 2025-01-11 9/week @ 2025-01-18 46/week @ 2025-01-25 10/week @ 2025-02-01 10/week @ 2025-02-08 14/week @ 2025-02-15 12/week @ 2025-02-22 7/week @ 2025-03-01 8/week @ 2025-03-08 11/week @ 2025-03-15 557/week @ 2025-03-29 1840/week @ 2025-04-05

2,411 downloads per month
Used in 2 crates (via playdate-bindgen)

MIT license

49KB
849 lines

A library for safely parsing HTML and converting it to Markdown.

Example

use html2md_rs::to_md::from_html_to_md;

let html = "<h1>Hello World</h1>".to_string();
let parsed = from_html_to_md(html);

assert_eq!(parsed, "# Hello World\n");

Supported HTML Elements

The list of supported HTML elements is in the structs::NodeType enum.

HTML Attributes

By default, the library parses all attributes of an HTML element as a HashMap.

Markdown Convention

This library follows the CommonMark Spec.

License

This library is licensed under the MIT license. Check the GitHub repository for more information.


html2md-rs

Parses HTML and converts it to markdown.

Usage

use html2md_rs::to_md::from_html_to_md;

fn main() {
    let html = "<h1>Hello, World!</h1>";
    let md = from_html_to_md(html);
    assert_eq!(md, "# Hello, World!");
}

Markdown Convention

There are many markdown conventions/standards out there. This project references the CommonMark Spec.

Supported HTML tags

Check the supported HTML tags here. Unsupported HTML tags will be parsed as NodeType::Unknown(String).

License

This project is licensed under the MIT License - see the LICENSE file for details.

Dependencies