htmlproc
HTML processors as utils written in Rust.
Each function is offered as a single feature
, so the dependencies are kept small. (omit_enclosure
which is used as document outline formatter is exception.)
Install in Rust project
# install crate
# install crate with specific features
# uninstall
# cargo remove htmlproc
Functions (Features)
omit_attr
Remove specific tag attribute(s) from HTML text.
Usage
First, run cargo add htmlproc --features omit_attr
. Then specify attrs to omit. Three formats are available:
attr
: remove all attrs from all tags.*.attr
: same to the above.tag.attr
: remove all attrs from specifig tag. ex)span.style
use manipulate;
let html = "<div id=\"preserved\"><span style=\"want: remove;\" class=\"also: wanted;\" z-index=\"1\">Content</span></div>";
let omit_attrs = &;
let result: String = manipulate;
omit_enclosure
Remove specific tag enclosure(s) from HTML text.
Usage
use manipulate;
let result: String = manipulate;
path_to_url
Convert paths to URLs.
Usage
use ;
let result: String = convert;
In this case, href
value "/some/path
" is converted to "https://target.domain/some/path
". Options such as http protocol, port number and current directory are available.