Skip to content

spider-rs/html2md

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fast_html2md

The fastest Rust html to markdown transformer.

cargo add fast_html2md

You can use a scraper or rewriter to transform. The rewriter is over 2-3 times faster.

use html2md::parse_html;

let md = parse_html("<p>JAMES</p>", false);
assert_eq!(md, "JAMES")

Using a rewriter.

use html2md::rewrite_html;

let md = parse_html("<p>JAMES</p>", false);
assert_eq!(md, "JAMES")

Ignoring Tags

    let mut tag_factory: HashMap<String, Box<dyn html2md::TagHandlerFactory>> =
        HashMap::new();

    let tag = Box::new(IgnoreTagFactory {});

    tag_factory.insert(String::from("script"), tag.clone());
    tag_factory.insert(String::from("style"), tag.clone());
    tag_factory.insert(String::from("noscript"), tag.clone());
    let html = html2md::parse_html_custom(&html, &tag_factory, false);