How to tidy a CSS string with rails?
-
28-10-2019 - |
سؤال
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?
لا يوجد حل صحيح
نصائح أخرى
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.
لا تنتمي إلى StackOverflow