1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//! HTML to Markdown converter - Lightweight library written in Rust.

const INDENT_DEFAULT_SIZE: usize = 0;
const INDENT_UNIT_SIZE: usize = 4;

mod components;
mod utils;

use crate::utils::node::parse_html;

/// Convert HTML to Markdown
///
/// ```
/// use mdka::from_html;
///
/// let input = r#"
/// <h1>heading 1</h1>
/// <p>Hello, world.</p>"#;
/// let expect = "# heading 1\n\nHello, world.\n\n";
/// let ret = from_html(input);
/// assert_eq!(ret, expect);
/// ```
///
pub fn from_html(html: &str) -> String {
    let dom = parse_html(html);
    components::node::node_md(&dom.document, None::<usize>)
}