diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-02-12 14:39:22 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-02-12 15:49:39 +0100 |
| commit | c8e567ddc82bed8aac617741b799d24184358fcd (patch) | |
| tree | 866d7923815cb6353a61ce15924c5ed3450f8921 /src | |
| parent | 320ada6479b3e29c7d9a66bc56ac44c2d2b57566 (diff) | |
| download | rust-c8e567ddc82bed8aac617741b799d24184358fcd.tar.gz rust-c8e567ddc82bed8aac617741b799d24184358fcd.zip | |
Minify CSS rules to be able to handle minified theme files as well
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/theme.rs | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/librustdoc/theme.rs b/src/librustdoc/theme.rs index af1c50acb0a..eb8eabe1c03 100644 --- a/src/librustdoc/theme.rs +++ b/src/librustdoc/theme.rs @@ -179,20 +179,23 @@ fn get_previous_positions(events: &[Events], mut pos: usize) -> Vec<usize> { } fn build_rule(v: &[u8], positions: &[usize]) -> String { - positions - .chunks(2) - .map(|x| ::std::str::from_utf8(&v[x[0]..x[1]]).unwrap_or("")) - .collect::<String>() - .trim() - .replace("\n", " ") - .replace("/", "") - .replace("\t", " ") - .replace("{", "") - .replace("}", "") - .split(' ') - .filter(|s| s.len() > 0) - .collect::<Vec<&str>>() - .join(" ") + minifier::css::minify( + &positions + .chunks(2) + .map(|x| ::std::str::from_utf8(&v[x[0]..x[1]]).unwrap_or("")) + .collect::<String>() + .trim() + .replace("\n", " ") + .replace("/", "") + .replace("\t", " ") + .replace("{", "") + .replace("}", "") + .split(' ') + .filter(|s| s.len() > 0) + .collect::<Vec<&str>>() + .join(" "), + ) + .unwrap_or_else(|_| String::new()) } fn inner(v: &[u8], events: &[Events], pos: &mut usize) -> FxHashSet<CssPath> { |
