summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <eevee.git@veekun.com>2013-08-29 15:45:59 -0700
committerEevee (Alex Munroe) <eevee.git@veekun.com>2013-08-29 15:45:59 -0700
commit35d17d9c5f809843649fb3e0998f55392ea8d258 (patch)
tree2458c83023fc7c084bbf7a5795044e0ba9c3d74a
parent238753c47c08e75f425d39a917d7a480d48678a2 (diff)
downloadpyscss-35d17d9c5f809843649fb3e0998f55392ea8d258.tar.gz
Preserve semicolons on at-rules in compressed mode.
-rw-r--r--scss/__init__.py7
-rw-r--r--scss/tests/files/bugs/at-rules-compressed-semicolon.css1
-rw-r--r--scss/tests/files/bugs/at-rules-compressed-semicolon.scss7
3 files changed, 14 insertions, 1 deletions
diff --git a/scss/__init__.py b/scss/__init__.py
index 26d4fc7..1f1fb91 100644
--- a/scss/__init__.py
+++ b/scss/__init__.py
@@ -1509,6 +1509,10 @@ class Scss(object):
# Close blocks and outdent as necessary
for i in range(len(old_ancestry), first_mismatch, -1):
+ # Possibly skip the last semicolon of the last inner statement
+ if not sc and result and result[-1] == ';':
+ result = result[:-1]
+
result += tb * (i - 1) + '}' + nl
# Open new blocks as necessary
@@ -1540,10 +1544,11 @@ class Scss(object):
if not skip_selectors:
result += self._print_properties(rule.properties, sc, sp, tb * len(ancestry), nl, wrap)
+ # Close all remaining blocks
+ for i in reversed(range(len(old_ancestry))):
if not sc and result and result[-1] == ';':
result = result[:-1]
- for i in reversed(range(len(old_ancestry))):
result += tb * i + '}' + nl
return (result, total_rules, total_selectors)
diff --git a/scss/tests/files/bugs/at-rules-compressed-semicolon.css b/scss/tests/files/bugs/at-rules-compressed-semicolon.css
new file mode 100644
index 0000000..3fac26b
--- /dev/null
+++ b/scss/tests/files/bugs/at-rules-compressed-semicolon.css
@@ -0,0 +1 @@
+@charset "utf8";a{b:c}
diff --git a/scss/tests/files/bugs/at-rules-compressed-semicolon.scss b/scss/tests/files/bugs/at-rules-compressed-semicolon.scss
new file mode 100644
index 0000000..9b1d741
--- /dev/null
+++ b/scss/tests/files/bugs/at-rules-compressed-semicolon.scss
@@ -0,0 +1,7 @@
+@option compress: true;
+
+@charset "utf8";
+
+a {
+ b: c;
+}