I have a string of CSS with new line characters in it and I would like to tidy the CSS string with rails somehow - using standard CSS tidying rules. I am not looking to minify it because I want to preserve the new lines and tab indents. How can I do this?
Asked
Active
Viewed 164 times
0
-
I don't know about theses rules, but maybe a regex? – basgys Jan 15 '12 at 03:29
1 Answers
0
I ended up giving up on rails and am making the browser do all the work with javascript code using cssbeautify
Seems to work OK taking a string like this
.selector{font-family: verdana; color: #ffffff}
turning into this:
.selector {
font-family: verdana;
color: #fff;
}
Note the addition of line breaks, tabs, semicolons at the end of every value, and conversion of 6 character color codes into 3 when possible. This is all for readability so maybe it does make more sense to keep it client-side. I just worry about large CSS files.

Devin McQueeney
- 1,277
- 2
- 14
- 31