summaryrefslogtreecommitdiff
path: root/scss/rule.py
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <eevee.git@veekun.com>2014-12-10 14:39:35 -0800
committerEevee (Alex Munroe) <eevee.git@veekun.com>2014-12-10 14:39:35 -0800
commit20c74b6796a244f118c2dcb4cf6b7b1e05b6789d (patch)
tree6e05c084e0f0d9c7e9878d147c95ae107b3f692d /scss/rule.py
parent77a58288ded8506cf8ca161fa2df5d8bd9876ece (diff)
downloadpyscss-20c74b6796a244f118c2dcb4cf6b7b1e05b6789d.tar.gz
Fix parsing of `@if(...)`, where there's no literal space.
Diffstat (limited to 'scss/rule.py')
-rw-r--r--scss/rule.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/scss/rule.py b/scss/rule.py
index 712f4ba..b8bf8c9 100644
--- a/scss/rule.py
+++ b/scss/rule.py
@@ -2,6 +2,7 @@ from __future__ import absolute_import
from __future__ import print_function
import logging
+import re
from scss.namespace import Namespace
@@ -239,17 +240,17 @@ class BlockHeader(object):
# Minor parsing
if prop.startswith('@'):
- if prop.lower().startswith('@else if '):
- directive = '@else if'
- argument = prop[9:]
- else:
- chunks = prop.split(None, 1)
- if len(chunks) == 2:
- directive, argument = chunks
- else:
- directive, argument = prop, None
- directive = directive.lower()
-
+ # This pattern MUST NOT BE ABLE TO FAIL!
+ # This is slightly more lax than the CSS syntax technically allows,
+ # e.g. identifiers aren't supposed to begin with three hyphens.
+ # But we don't care, and will just spit it back out anyway.
+ m = re.match(
+ u'@(else if|[-_a-zA-Z0-9\U00000080-\U0010FFFF]*)\\b',
+ prop, re.I)
+ directive = m.group(0).lower()
+ argument = prop[len(directive):].strip()
+ if not argument:
+ argument = None
return BlockAtRuleHeader(directive, argument, num_lines)
elif prop.split(None, 1)[0].endswith(':'):
# Syntax is "<scope>: [prop]" -- if the optional prop exists, it