Crates.io | tidier |
lib.rs | tidier |
version | 0.5.3 |
source | src |
created_at | 2023-12-18 22:41:10.78322 |
updated_at | 2024-08-27 12:52:46.652763 |
description | Format HTML, XHTML and XML documents |
homepage | |
repository | https://github.com/insomnimus/tidier |
max_upload_size | |
id | 1073754 |
size | 52,998 |
This crate provides a safe abstraction over the Tidy C library.
Note: Check out the basic CLI example in the examples directory.
use tidier::{Doc, FormatOptions, Indent};
let html = "<html>
<head><title>Tidy Usage Example</title></head>
<body><p>Usage example</p></body>
</html>";
let opts = FormatOptions {
wrap: 60,
strip_comments: true,
indent: Indent {
tabs: true,
..Indent::DEFAULT
},
..FormatOptions::DEFAULT
};
// Alternatively
let opts = FormatOptions::new()
.tabs(true)
.strip_comments(true)
.wrap(60);
let doc = Doc::new(html, false)?;
let s1 = doc.format(&opts)?;
// Or for short:
let s2 = tidier::format(html, false, &opts)?;
assert_eq!(s1, s2);
# Ok::<_, tidier::Error>(())
This crate uses tidy-sys, which generates bindings on the fly using bindgen, then compiles the tidy C library from source. Therefore you need;
You don't need to install libtidy on your system; tidy-sys
vendors the source code, builds and links to it statically.