0

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?

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

1 Answers1

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