From a65a2d52c70def075d8b4ed4c57dfd81b1f96ba3 Mon Sep 17 00:00:00 2001 From: Matt Riggott Date: Sat, 6 Feb 2021 15:41:10 +0000 Subject: [PATCH] Update minify-html dependency to version 0.4.2 (#1340) * Update minify-html dependency to version 0.4.2 Fixes https://github.com/getzola/zola/issues/1300. See also https://github.com/wilsonzlin/minify-html/issues/21 * Update minify-html dependency in Cargo.lock * Add test to check pre whitespace isn't collapsed --- Cargo.lock | 4 ++-- components/utils/Cargo.toml | 2 +- components/utils/src/minify.rs | 31 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0099cb07..3e05b5ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1388,9 +1388,9 @@ dependencies = [ [[package]] name = "minify-html" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345dcbf4663db7d3a78a6e6b6c279c8bb6c32d6365cd98da977d7f7543b6c167" +checksum = "d7af79ea8ac719a1cc299787058518a12018700af7ec7be4b789930526e1a1ab" dependencies = [ "aho-corasick", "lazy_static", diff --git a/components/utils/Cargo.toml b/components/utils/Cargo.toml index 2c2f664e..66bbca8a 100644 --- a/components/utils/Cargo.toml +++ b/components/utils/Cargo.toml @@ -15,7 +15,7 @@ serde_derive = "1" slug = "0.1" percent-encoding = "2" filetime = "0.2.12" -minify-html = "0.4" +minify-html = "0.4.2" errors = { path = "../errors" } diff --git a/components/utils/src/minify.rs b/components/utils/src/minify.rs index a0513262..faab7812 100644 --- a/components/utils/src/minify.rs +++ b/components/utils/src/minify.rs @@ -59,4 +59,35 @@ mod tests { let res = html(input.to_owned()).unwrap(); assert_eq!(res, expected); } + + // https://github.com/getzola/zola/issues/1300 + #[test] + fn can_minify_and_preserve_whitespace_in_pre_elements() { + let input = r#" + + + + + + +
fn main() {
+    println!("Hello, world!");
+    loop {
+      println!("Hello, world!");
+    }
+  }
+  
+ + +"#; + let expected = r#"
fn main() {
+    println!("Hello, world!");
+    loop {
+      println!("Hello, world!");
+    }
+  }
+  
"#; + let res = html(input.to_owned()).unwrap(); + assert_eq!(res, expected); + } }