Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

CSS decode/encode

View gist:1281776
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
function CSSencode(code)
{
code = code.replace(/\n/ig,'');
code = code.replace(/(\s){2,}/ig,'$1');
code = code.replace(/\t/ig,'');
code = code.replace(/\n\}/ig,'\}');
code = code.replace(/\n\{\s*/ig,'\{');
code = code.replace(/(\S)\s*\}/ig,'$1\}');
code = code.replace(/(\S)\s*\{/ig,'$1\{');
code = code.replace(/\{\s*(\S)/ig,'\{$1');
return code;
}
function CSSdecode(code)
{
code = code.replace(/(\s){2,}/ig,'$1');
code = code.replace(/(\S)\s*\{/ig,'$1 {');
code = code.replace(/\*\/(.[^\}\{]*)}/ig,'\*\/\n$1}');
code = code.replace(/\/\*/ig,'\n\/\*');
code = code.replace(/;\s*(\S)/ig,';\n\t$1');
code = code.replace(/\}\s*(\S)/ig,'\}\n$1');
code = code.replace(/\n\s*\}/ig,'\n\}');
code = code.replace(/\{\s*(\S)/ig,'\{\n\t$1');
code = code.replace(/(\S)\s*\*\//ig,'$1\*\/');
code = code.replace(/\*\/\s*([^\}\{]\S)/ig,'\*\/\n\t$1');
code = code.replace(/(\S)\}/ig,'$1\n\}');
code = code.replace(/(\n){2,}/ig,'\n');
code = code.replace(/:/ig,': ');
code = code.replace(/ /ig,' ');
return code;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.