Expand description
A utility for comparing HTML output with configurable comparison options.
This crate provides tools for comparing HTML strings while ignoring differences that don’t affect the rendered output, such as whitespace, attribute order, and other configurable aspects.
§Example
ⓘ
use html_compare::{HtmlComparer, HtmlCompareOptions};
let html1 = "<div><p>Hello</p></div>";
let html2 = "<div>\n <p>Hello</p>\n</div>";
let comparer = HtmlComparer::new();
assert!(comparer.compare(html1, html2).unwrap());
For testing, you can use the provided assertion macros:
ⓘ
assert_html_eq!(
"<div><p>Hello</p></div>",
"<div>\n <p>Hello</p>\n</div>"
);
Modules§
- presets
- Convenience functions for creating common comparison configurations
Macros§
- assert_
html_ eq - Asserts that two HTML strings are equivalent according to the given comparison options.
- assert_
html_ ne - Asserts that two HTML strings are not equivalent according to the given comparison options.
Structs§
- Html
Compare Options - Configuration for HTML comparison
- Html
Comparer - Main struct for comparing HTML