Skip to content

Commit 7d720b5

Browse files
committed
Replace all backslashes in selectors
This allows all operators to be used in the SASS pre-processor (and further allows scope-segments beginning with numbers). Fixes #11.
1 parent e61821e commit 7d720b5

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tinycsscheme/dumper.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,20 @@ def datafy_ruleset(self, rset):
141141
# TODO test selector?
142142
sel = rset.selector.as_css()
143143
if sel != '*':
144-
# We replace escaping of the subtract operator because SASS
145-
# doesn't like the literal hyphen in selectors.
146-
# '-' was not recognized anymore starting around Dec 2014, use \- now.
147-
sel = sel.replace("'-'", "-").replace("\\-", "-")
148-
# Also replace multiple whitespaces (including newlines) with
149-
# single space; we don't know how exactly it will perform
150-
# otherwise.
151-
rdict['scope'] = ' '.join(sel.split())
144+
# We replace all backslashes in the selector
145+
# for compatibility with the SASS pre-processor.
146+
# Notably, this allows "numeric classes"
147+
# and all operators (including braces).
148+
sel = sel.replace("\\", "")
149+
# '-' was used initially for only the subtract operator
150+
# but is not recognized anymore starting around Dec 2014.
151+
sel = sel.replace("'-'", "-")
152+
# Also replace multiple whitespaces (including newlines)
153+
# with a single space;
154+
# we don't know how exactly it will perform otherwise.
155+
sel = " ".join(sel.split())
156+
157+
rdict['scope'] = sel
152158

153159
# Arbitrary at-rules -> add to dict
154160
for r in rset.at_rules:

0 commit comments

Comments
 (0)