Question

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?

No correct solution

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top