summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermán M. Bravo <german.mb@gmail.com>2013-05-15 07:37:26 -0700
committerGermán M. Bravo <german.mb@gmail.com>2013-05-15 07:37:26 -0700
commitf9fe1138761e76f302fa6062f1e2a2f422233e7c (patch)
treef1289f11e4f4435b7d127950d23f5954280e0920
parentd01e36a189d183b3384824cb1dbd046bbc0ba532 (diff)
parente83fb7abb974035434112a52deb18853c5bb2bf2 (diff)
downloadpyscss-f9fe1138761e76f302fa6062f1e2a2f422233e7c.tar.gz
Merge pull request #155 from radiac/divide_by_unit
Fix and test for issue #154 (dividing numbers of the same unit type)
-rw-r--r--scss/__init__.py4
-rw-r--r--scss/tests.rst17
2 files changed, 21 insertions, 0 deletions
diff --git a/scss/__init__.py b/scss/__init__.py
index a9cac83..be613f2 100644
--- a/scss/__init__.py
+++ b/scss/__init__.py
@@ -4460,6 +4460,10 @@ class NumberValue(Value):
first.value /= 100.0
elif second_unit == '%' and first_unit != '%':
second = NumberValue(first) * second.value
+ elif op == operator.__div__:
+ if first_unit and first_unit == second_unit:
+ first.units = {}
+ second.units = {}
val = op(first.value, second.value)
diff --git a/scss/tests.rst b/scss/tests.rst
index 4b10608..cf95d45 100644
--- a/scss/tests.rst
+++ b/scss/tests.rst
@@ -301,6 +301,23 @@ http://xcss.antpaw.org/docs/syntax/math
>>> print css.compile('''
... @option compress:no, short_colors:yes, reverse_colors:yes;
... .selector {
+ ... padding: [4em / 2em];
+ ... margin: [4em / 2em]em;
+ ... width: [8px / 2px];
+ ... height: [500px / 2];
+ ... }
+ ... ''') #doctest: +NORMALIZE_WHITESPACE
+ .selector {
+ padding: 2;
+ margin: 2em;
+ width: 4;
+ height: 250px;
+ }
+
+
+ >>> print css.compile('''
+ ... @option compress:no, short_colors:yes, reverse_colors:yes;
+ ... .selector {
... padding: [5em - 3em + 5px]px;
... margin: [20 - 10] [30% - 10];
... }