home
NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Tidier HTML Example For Rust

This is a test to see if tider will work with just snippets. The goal was to see if it can be used without automatically closing tags, but I don't see a way to do that. (That makes sense based off what Tidy is designed to do. I was just looking to see if it had the option)

April 2024
Code
```cargo
[dependencies]
tidier = "0.5.2"
```

use tidier::{Doc, FormatOptions};


fn main() {
  let html = r#"<div><p>Usage example</p>"#;
  match do_format(&html) {
    Ok(html) => println!("{}", html),
    Err(e) => println!("{}", e)
  }
}

fn do_format(html: &str) -> Result<String, tidier::Error> {
  let opts = FormatOptions::new()
    .tabs(true)
    .strip_comments(true)
    .wrap(60);
  let doc = Doc::new(html, false)?;
  let output = doc.format(&opts)?;
  Ok(output)
}
Results

Usage example

═══ § ═══

Footnotes And References