diff options
author | Eevee <eevee.git@veekun.com> | 2013-05-09 18:31:38 -0700 |
---|---|---|
committer | Eevee <eevee.git@veekun.com> | 2013-05-23 13:43:24 -0700 |
commit | 9f10a04147bdc1b93a5f970ac142db6eb663cd4f (patch) | |
tree | 37e0b1adf218f313f9cb686c761458c3c9121fbb /scss/rule.py | |
parent | 86ae23509aa0ea0dfdf9f13d1f17f0ecf7b0cd8e (diff) | |
download | pyscss-9f10a04147bdc1b93a5f970ac142db6eb663cd4f.tar.gz |
Support scope blocks like `background: red { ... }`.
Diffstat (limited to 'scss/rule.py')
-rw-r--r-- | scss/rule.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/scss/rule.py b/scss/rule.py index 555fc97..491ee61 100644 --- a/scss/rule.py +++ b/scss/rule.py @@ -145,8 +145,13 @@ class BlockHeader(object): return BlockAtRuleHeader(directive, argument) else: - if prop.endswith(':'): - return BlockScopeHeader(prop) + if prop.endswith(u':') or u': ' in prop: + # Syntax is "<scope>: [prop]" -- if the optional prop exists, + # it becomes the first rule with no suffix + scope, unscoped_value = prop.split(u':', 1) + scope = scope.rstrip() + unscoped_value = unscoped_value.lstrip() + return BlockScopeHeader(scope, unscoped_value) else: return BlockSelectorHeader(prop) @@ -187,9 +192,14 @@ class BlockSelectorHeader(BlockHeader): class BlockScopeHeader(BlockHeader): is_scope = True - def __init__(self, scope): + def __init__(self, scope, unscoped_value): self.scope = scope + if unscoped_value: + self.unscoped_value = unscoped_value + else: + self.unscoped_value = None + class UnparsedBlock(object): """A Sass block whose contents have not yet been parsed. @@ -236,5 +246,5 @@ class UnparsedBlock(object): return self.header.is_atrule @property - def is_nested_property(self): + def is_scope(self): return self.header.is_scope |