im compressing a stylesheet into 1 line, using
cat stylesheet.css | gsed "s|/\*\(\\\\\)\?\*/|/~\1~/|g" -e "s|/\*[^*]*\*\+\([^/][^*]*\*\+\)*/||g" -e "s|\([^:/]\)//.*$|\1|" -e "s|^//.*$||" | tr '\n' ' ' | sed -e "s|/\*[^*]*\*\+\([^/][^*]*\*\+\)*/||g" -e "s|/\~\(\\\\\)\?\~/|/*\1*/|g" -e "s|\s\+| |g" -e "s| \([{;:,]\)|\1|g" -e "s|\([{;:,]\) |\1|g"
im trying to reverse the process.
cat stylesheet-compress.css | gsed 's/\([;{]\)\([^\n]\)/\1\n\t\2/g' | gsed 's/\([^}]\)}/\1;\n}\n\n/g' | gsed 's/{/ {/g' | gsed 's/[,]/& /g' | gsed '/}/ { n;n; s/}\n\([^\n]\)/}\n\n\1/ }'
works for the most part but some of the css entries have indenting and extra ;'s
I think you're looking for a CSS formatter. There are lots of them online. E.g. http://www.lonniebest.com/FormatCSS/. If you have to do it from shell, I'd spawn to another program to do the heavy lifting. http://cthedot.de/cssutils/ will do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With