Crate html_compare_rs

Source
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§

HtmlCompareOptions
Configuration for HTML comparison
HtmlComparer
Main struct for comparing HTML

Enums§

HtmlCompareError