Skip to content

Commit c8e567d

Browse files
Minify CSS rules to be able to handle minified theme files as well
1 parent 320ada6 commit c8e567d

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/librustdoc/theme.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,23 @@ fn get_previous_positions(events: &[Events], mut pos: usize) -> Vec<usize> {
179179
}
180180

181181
fn build_rule(v: &[u8], positions: &[usize]) -> String {
182-
positions
183-
.chunks(2)
184-
.map(|x| ::std::str::from_utf8(&v[x[0]..x[1]]).unwrap_or(""))
185-
.collect::<String>()
186-
.trim()
187-
.replace("\n", " ")
188-
.replace("/", "")
189-
.replace("\t", " ")
190-
.replace("{", "")
191-
.replace("}", "")
192-
.split(' ')
193-
.filter(|s| s.len() > 0)
194-
.collect::<Vec<&str>>()
195-
.join(" ")
182+
minifier::css::minify(
183+
&positions
184+
.chunks(2)
185+
.map(|x| ::std::str::from_utf8(&v[x[0]..x[1]]).unwrap_or(""))
186+
.collect::<String>()
187+
.trim()
188+
.replace("\n", " ")
189+
.replace("/", "")
190+
.replace("\t", " ")
191+
.replace("{", "")
192+
.replace("}", "")
193+
.split(' ')
194+
.filter(|s| s.len() > 0)
195+
.collect::<Vec<&str>>()
196+
.join(" "),
197+
)
198+
.unwrap_or_else(|_| String::new())
196199
}
197200

198201
fn inner(v: &[u8], events: &[Events], pos: &mut usize) -> FxHashSet<CssPath> {

0 commit comments

Comments
 (0)