Skip to content

brainhivenl/html-to-markdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTML to CommonMark

Convert HTML to markdown (CommonMark). Uses html5ever for parsing HTML and comrak for generating markdown output. It generates a comrak AST based on the HTML input and then converts it to markdown using comrak::format_commonmark.

Usage

fn main() {
    let html = "<h1>Hello World</h1>".to_string();
    let markdown = html_to_markdown::render(html)
        .expect("failed to convert HTML to markdown");

    println!("{}", markdown); // # Hello World
}

Features

The following HTML elements are supported (other elements will be stripped):

  • h1
  • h2
  • h3
  • h4
  • h5
  • h6
  • p
  • ul
  • ol
  • li
  • em/i
  • strong/b
  • a
  • br
  • img
  • del

Releases

No releases published

Packages

No packages published