summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <eevee.git@veekun.com>2013-08-23 19:47:57 -0700
committerEevee (Alex Munroe) <eevee.git@veekun.com>2013-08-23 19:47:57 -0700
commit99d826ea01739a83e55478fb00da8275d75df986 (patch)
treefd52cc95488bf64949be45f811f70e2da58388c1
parent747f09eac073e409e865cdf1ab98c486074bc1c5 (diff)
downloadpyscss-99d826ea01739a83e55478fb00da8275d75df986.tar.gz
Cheap heuristic for whether +foo is an @include or a selector.
-rw-r--r--scss/rule.py11
-rw-r--r--scss/tests/files/bugs/selectors-adjacent-is-not-include.css3
-rw-r--r--scss/tests/files/bugs/selectors-adjacent-is-not-include.scss5
3 files changed, 14 insertions, 5 deletions
diff --git a/scss/rule.py b/scss/rule.py
index 4ddb625..a2694a8 100644
--- a/scss/rule.py
+++ b/scss/rule.py
@@ -256,12 +256,13 @@ class BlockHeader(object):
is_selector = False
@classmethod
- def parse(cls, prop):
+ def parse(cls, prop, has_contents=False):
# Simple pre-processing
- if prop.startswith('+'):
- # Expand '+' at the beginning of a rule as @include
+ if prop.startswith('+') and not has_contents:
+ # Expand '+' at the beginning of a rule as @include. But not if
+ # there's a block, because that's probably a CSS selector.
+ # DEVIATION: this is some semi hybrid of Sass and xCSS syntax
prop = '@include ' + prop[1:]
- # TODO what is this, partial sass syntax?
try:
if '(' not in prop or prop.index(':') < prop.index('('):
prop = prop.replace(':', '(', 1)
@@ -366,7 +367,7 @@ class UnparsedBlock(object):
def __init__(self, parent_rule, lineno, prop, unparsed_contents):
self.parent_rule = parent_rule
- self.header = BlockHeader.parse(prop)
+ self.header = BlockHeader.parse(prop, has_contents=bool(unparsed_contents))
# Basic properties
self.lineno = lineno
diff --git a/scss/tests/files/bugs/selectors-adjacent-is-not-include.css b/scss/tests/files/bugs/selectors-adjacent-is-not-include.css
new file mode 100644
index 0000000..ea0d7b3
--- /dev/null
+++ b/scss/tests/files/bugs/selectors-adjacent-is-not-include.css
@@ -0,0 +1,3 @@
+p + h4 {
+ margin-top: 28px;
+}
diff --git a/scss/tests/files/bugs/selectors-adjacent-is-not-include.scss b/scss/tests/files/bugs/selectors-adjacent-is-not-include.scss
new file mode 100644
index 0000000..84fef9a
--- /dev/null
+++ b/scss/tests/files/bugs/selectors-adjacent-is-not-include.scss
@@ -0,0 +1,5 @@
+p {
+ + h4 {
+ margin-top: 28px;
+ }
+}