#html #tags #check #validation #xss #sanitation

is-html

Check if a string is HTML

4 releases

0.1.3 May 11, 2022
0.1.2 May 8, 2022
0.1.1 May 5, 2022
0.1.0 May 5, 2022

#5 in #xss

MIT license

5KB
149 lines

is-html

Check if a string is HTML

You should not use this for any kind of validation, sanitation, or XSS checks.

Install

$ cargo install is-html

Usage

This crate is on crates.io and can be used by adding is-html to your dependencies in your project’s Cargo.toml.

[dependencies]
is-html = "0.1.2"
use is_html::is_html;

is_html("<p>I am HTML</p>");
//=> true

is_html("<!doctype><html><body><h1>I ❤ rust</h1></body></html>");
//=> true

is_html("<cake>I am XML</cake>");
//=> false

is_html(">+++++++>++++++++++>+++>+<<<<-");
//=> false

Note: It does not detect deprecated HTML tags.

Reference

is-html

Dependencies

~2.2–3MB
~54K SLoC