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); + } }