1
Fork 0
mirror of https://github.com/RGBCube/rgbcube.github.io synced 2025-05-22 09:25:07 +00:00

Clean up minify functions

This commit is contained in:
RGBCube 2023-12-20 22:27:35 +03:00
parent 9336ad99b0
commit 80c8f36435
No known key found for this signature in database
5 changed files with 26 additions and 17 deletions

View file

@ -1,13 +1,13 @@
const SPECIAL_CHARS: [char; 8] = ['{', '}', ':', ';', ' ', '\n', '!', '>'];
// Taken from https://github.com/amgarrett09/rust-css-minifier/blob/master/src/minify/mod.rs.
pub fn css(input: &str) -> String {
pub fn css<S: AsRef<str>>(input: S) -> String {
let mut last_char: Vec<char> = " ".chars().collect();
let mut output = Vec::new();
let mut inside_comment = false;
for c in input.chars() {
for c in input.as_ref().chars() {
// We're in a comment if we find '/*'
if !inside_comment && c == '*' && last_char[0] == '/' {
inside_comment = true;