|0.1.13||Jul 21, 2020|
|0.1.11||Mar 5, 2020|
|0.1.8||Jul 22, 2018|
|0.1.7||Feb 13, 2018|
|0.1.3||Dec 31, 2016|
#10 in Template engine
1,388 downloads per month
Used in 8 crates (5 directly)
html2text is a Rust crate which converts HTML to plain text.
The project aims to do a reasonable job of rendering reasonable HTML in a terminal or other places where HTML needs to be converted to text (for example the text/plain fallback in HTML e-mails).
use html2text::from_read; let html = b" <ul> <li>Item one</li> <li>Item two</li> <li>Item three</li> </ul>"; assert_eq!(from_read(&html[..], 20), "\ * Item one * Item two * Item three ");
A couple of simple demonstration programs are included as examples:
The simplest example uses
from_read to convert HTML on stdin into plain
$ cargo run --example html2text < foo.html [...]
A very simple example of using the rich interface (
from_read_rich) for a
slightly interactive console HTML viewer is provided as
$ cargo run --example html2term foo.html [...]
Note that this example takes the HTML file as a parameter so that it can read keys from stdin.