checkpoint identifiers
This commit is contained in:
parent
61c55e7ca6
commit
57c64bcea8
@ -189,7 +189,6 @@ class LessParser(object):
|
||||
self.handle_error(e, p)
|
||||
p[0] = None
|
||||
self.scope.pop()
|
||||
self.scope.add_block(block)
|
||||
|
||||
def p_block_replace(self, p):
|
||||
""" block_decl : identifier ';'
|
||||
@ -206,7 +205,7 @@ class LessParser(object):
|
||||
"""
|
||||
p[1].parse(self.scope)
|
||||
p[0] = p[1]
|
||||
self.scope.current = p[1].real
|
||||
self.scope.current = p[1]
|
||||
|
||||
def p_font_face_open(self, p):
|
||||
""" block_open : css_font_face t_ws brace_open
|
||||
|
@ -10,8 +10,7 @@ class Block(Node):
|
||||
"""
|
||||
"""
|
||||
if not self.parsed:
|
||||
name, inner = self.tokens
|
||||
self.name = name.parse(scope)
|
||||
self.name, inner = self.tokens
|
||||
if not inner: inner = []
|
||||
self.parsed = [p.parse(scope)
|
||||
for p in inner
|
||||
@ -31,14 +30,7 @@ class Block(Node):
|
||||
out = []
|
||||
if self.parsed:
|
||||
f = "%(identifier)s%(ws)s{%(nl)s%(proplist)s}%(eb)s"
|
||||
name = self.name.strip()
|
||||
if fills['nl']:
|
||||
if len(name) > 80 and name.count(',') > 5:
|
||||
name = name.replace(',', ',%s' % fills['nl'])
|
||||
else:
|
||||
name = name.replace(',', ',%s' % fills['ws'])
|
||||
else:
|
||||
name = re.sub(' ([\+\>~]) ', '\\1', name)
|
||||
name = self.name.format(fills)
|
||||
fills.update({
|
||||
'identifier': name,
|
||||
'proplist': ''.join([p.format(fills) for p in self.parsed]),
|
||||
|
@ -1,34 +1,69 @@
|
||||
"""
|
||||
"""
|
||||
import re
|
||||
from .node import Node
|
||||
from lesscpy.lessc import utility
|
||||
class Identifier(Node):
|
||||
def parse(self, scope):
|
||||
"""
|
||||
"""
|
||||
name = ''.join([t + ' '
|
||||
if t in '*>~+'
|
||||
else t
|
||||
for t in utility.flatten(self.tokens)])
|
||||
names = self.root(scope, name) if scope else [name]
|
||||
self.real = name
|
||||
return ','.join(names)
|
||||
names = []
|
||||
name = []
|
||||
for n in utility.flatten(self.tokens):
|
||||
if n == '*':
|
||||
name.append('* ')
|
||||
elif n in '>+~':
|
||||
if name and name[-1] == ' ':
|
||||
name.pop()
|
||||
name.append('?%s?' % n)
|
||||
elif n == ',':
|
||||
names.append(name)
|
||||
name = []
|
||||
else:
|
||||
name.append(n)
|
||||
names.append(name)
|
||||
self.parsed = self.root(scope, names) if scope else names
|
||||
return self
|
||||
|
||||
def root(self, scope, name):
|
||||
def root(self, scope, names):
|
||||
"""
|
||||
"""
|
||||
names = [p.strip()
|
||||
for p in name.split(',')]
|
||||
parent = scope.scopename[:-1]
|
||||
parent = scope.scopename
|
||||
if parent:
|
||||
parent.reverse()
|
||||
for p in parent:
|
||||
parts = p.split(',')
|
||||
names = [n.replace('&', p.strip())
|
||||
if '&' in n
|
||||
else
|
||||
"%s %s" % (p.strip(), n)
|
||||
for n in names
|
||||
for p in parts]
|
||||
parent = parent[-1]
|
||||
return [self._pscn(part, n)
|
||||
for part in parent.parsed
|
||||
for n in names]
|
||||
return names
|
||||
|
||||
def _pscn(self, parent, name):
|
||||
"""
|
||||
"""
|
||||
parsed = []
|
||||
if any((n for n in name if n == '&')):
|
||||
for n in name:
|
||||
if n == '&':
|
||||
if parent[-1] == ' ':
|
||||
parent.pop()
|
||||
parsed.extend(parent)
|
||||
else:
|
||||
parsed.append(n)
|
||||
else:
|
||||
parsed.extend(parent)
|
||||
if parent[-1] != ' ':
|
||||
parsed.append(' ')
|
||||
parsed.extend(name)
|
||||
return parsed
|
||||
|
||||
|
||||
def format(self, fills):
|
||||
"""
|
||||
"""
|
||||
name = ',$$'.join(''.join(p).strip()
|
||||
for p in self.parsed)
|
||||
name = re.sub(' *?\?(.)\? *?', '%(ws)s\\1%(ws)s', name) % fills
|
||||
return (name.replace('$$', fills['nl'])
|
||||
if len(name) > 85
|
||||
else name.replace('$$', fills['ws'])).replace(' ', ' ')
|
||||
|
||||
|
||||
|
@ -82,7 +82,16 @@ p::before {
|
||||
:lang(en-gb) > q {
|
||||
quotes: "\2018""\2019""\201c""\201d";
|
||||
}
|
||||
a.one, a.two, a.three, a.four, a.five, a.six, a.seven, a.eight, a.nine, a.ten {
|
||||
a.one,
|
||||
a.two,
|
||||
a.three,
|
||||
a.four,
|
||||
a.five,
|
||||
a.six,
|
||||
a.seven,
|
||||
a.eight,
|
||||
a.nine,
|
||||
a.ten {
|
||||
max-width: 12px;
|
||||
}
|
||||
a.longclassname.one,
|
||||
@ -180,6 +189,16 @@ audio,
|
||||
video {
|
||||
padding: 0;
|
||||
}
|
||||
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
|
||||
article,
|
||||
aside,
|
||||
details,
|
||||
figcaption,
|
||||
figure,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
menu,
|
||||
nav,
|
||||
section {
|
||||
padding: 0;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
.div .nest.deep .deeper .deepest {
|
||||
color: purple;
|
||||
}
|
||||
h1 a:hover, h2 a:hover, h3 a:hover, h1 p:hover, h2 p:hover, h3 p:hover {
|
||||
h1 a:hover, h1 p:hover, h2 a:hover, h2 p:hover, h3 a:hover, h3 p:hover {
|
||||
color: red;
|
||||
}
|
||||
a {
|
||||
@ -31,10 +31,10 @@ p a span {
|
||||
.foo .bar .qux, .foo .baz .qux {
|
||||
display: block;
|
||||
}
|
||||
.foo .qux .bar, .foo .qux .baz {
|
||||
.qux .foo .bar, .qux .foo .baz {
|
||||
display: inline;
|
||||
}
|
||||
.foo .qux .bar .biz, .foo .qux .baz .biz {
|
||||
.qux .foo .bar .biz, .qux .foo .baz .biz {
|
||||
display: none;
|
||||
}
|
||||
#first > .one {
|
||||
@ -58,174 +58,183 @@ p a span {
|
||||
#first > .one > #second .two > #deux #third ~ p.general_sibling_selector {
|
||||
color: unused;
|
||||
}
|
||||
#first > .one > #second .two > #deux #fourth, #first > .one > #second .two > #deux #five, #first > .one > #second .two > #deux #six {
|
||||
#first > .one > #second .two > #deux #fourth,
|
||||
#first > .one > #second .two > #deux #five,
|
||||
#first > .one > #second .two > #deux #six {
|
||||
color: #110000;
|
||||
}
|
||||
#first > .one > #second .two > #deux #fourth .seven, #first > .one > #second .two > #deux #five .seven, #first > .one > #second .two > #deux #six .seven, #first > .one > #second .two > #deux #fourth .eight > #nine, #first > .one > #second .two > #deux #five .eight > #nine, #first > .one > #second .two > #deux #six .eight > #nine {
|
||||
#first > .one > #second .two > #deux #fourth .seven,
|
||||
#first > .one > #second .two > #deux #fourth .eight > #nine,
|
||||
#first > .one > #second .two > #deux #five .seven,
|
||||
#first > .one > #second .two > #deux #five .eight > #nine,
|
||||
#first > .one > #second .two > #deux #six .seven,
|
||||
#first > .one > #second .two > #deux #six .eight > #nine {
|
||||
border: 1px solid black;
|
||||
}
|
||||
#first > .one > #second .two > #deux #fourth #ten, #first > .one > #second .two > #deux #five #ten, #first > .one > #second .two > #deux #six #ten {
|
||||
#first > .one > #second .two > #deux #fourth #ten,
|
||||
#first > .one > #second .two > #deux #five #ten,
|
||||
#first > .one > #second .two > #deux #six #ten {
|
||||
color: red;
|
||||
}
|
||||
h1 a .one:hover,
|
||||
h2 a .one:hover,
|
||||
h3 a .one:hover,
|
||||
h4 a .one:hover,
|
||||
h5 a .one:hover,
|
||||
h1 p .one:hover,
|
||||
h2 p .one:hover,
|
||||
h3 p .one:hover,
|
||||
h4 p .one:hover,
|
||||
h5 p .one:hover,
|
||||
h1 div .one:hover,
|
||||
h2 div .one:hover,
|
||||
h3 div .one:hover,
|
||||
h4 div .one:hover,
|
||||
h5 div .one:hover,
|
||||
h1 span .one:hover,
|
||||
h2 span .one:hover,
|
||||
h3 span .one:hover,
|
||||
h4 span .one:hover,
|
||||
h5 span .one:hover,
|
||||
h1 a .two:hover,
|
||||
h2 a .two:hover,
|
||||
h3 a .two:hover,
|
||||
h4 a .two:hover,
|
||||
h5 a .two:hover,
|
||||
h1 p .two:hover,
|
||||
h2 p .two:hover,
|
||||
h3 p .two:hover,
|
||||
h4 p .two:hover,
|
||||
h5 p .two:hover,
|
||||
h1 div .two:hover,
|
||||
h2 div .two:hover,
|
||||
h3 div .two:hover,
|
||||
h4 div .two:hover,
|
||||
h5 div .two:hover,
|
||||
h1 span .two:hover,
|
||||
h2 span .two:hover,
|
||||
h3 span .two:hover,
|
||||
h4 span .two:hover,
|
||||
h5 span .two:hover,
|
||||
h1 a .three:hover,
|
||||
h2 a .three:hover,
|
||||
h3 a .three:hover,
|
||||
h4 a .three:hover,
|
||||
h5 a .three:hover,
|
||||
h1 p .three:hover,
|
||||
h2 p .three:hover,
|
||||
h3 p .three:hover,
|
||||
h4 p .three:hover,
|
||||
h5 p .three:hover,
|
||||
h1 div .three:hover,
|
||||
h2 div .three:hover,
|
||||
h3 div .three:hover,
|
||||
h4 div .three:hover,
|
||||
h5 div .three:hover,
|
||||
h1 span .three:hover,
|
||||
h2 span .three:hover,
|
||||
h3 span .three:hover,
|
||||
h4 span .three:hover,
|
||||
h5 span .three:hover,
|
||||
h1 a .four:hover,
|
||||
h2 a .four:hover,
|
||||
h3 a .four:hover,
|
||||
h4 a .four:hover,
|
||||
h5 a .four:hover,
|
||||
h1 p .four:hover,
|
||||
h2 p .four:hover,
|
||||
h3 p .four:hover,
|
||||
h4 p .four:hover,
|
||||
h5 p .four:hover,
|
||||
h1 div .four:hover,
|
||||
h2 div .four:hover,
|
||||
h3 div .four:hover,
|
||||
h4 div .four:hover,
|
||||
h5 div .four:hover,
|
||||
h1 span .four:hover,
|
||||
h2 span .four:hover,
|
||||
h3 span .four:hover,
|
||||
h4 span .four:hover,
|
||||
h5 span .four:hover,
|
||||
h1 a .one:focus,
|
||||
h2 a .one:focus,
|
||||
h3 a .one:focus,
|
||||
h4 a .one:focus,
|
||||
h5 a .one:focus,
|
||||
h1 p .one:focus,
|
||||
h2 p .one:focus,
|
||||
h3 p .one:focus,
|
||||
h4 p .one:focus,
|
||||
h5 p .one:focus,
|
||||
h1 div .one:focus,
|
||||
h2 div .one:focus,
|
||||
h3 div .one:focus,
|
||||
h4 div .one:focus,
|
||||
h5 div .one:focus,
|
||||
h1 span .one:focus,
|
||||
h2 span .one:focus,
|
||||
h3 span .one:focus,
|
||||
h4 span .one:focus,
|
||||
h5 span .one:focus,
|
||||
h1 a .two:hover,
|
||||
h1 a .two:focus,
|
||||
h2 a .two:focus,
|
||||
h3 a .two:focus,
|
||||
h4 a .two:focus,
|
||||
h5 a .two:focus,
|
||||
h1 p .two:focus,
|
||||
h2 p .two:focus,
|
||||
h3 p .two:focus,
|
||||
h4 p .two:focus,
|
||||
h5 p .two:focus,
|
||||
h1 div .two:focus,
|
||||
h2 div .two:focus,
|
||||
h3 div .two:focus,
|
||||
h4 div .two:focus,
|
||||
h5 div .two:focus,
|
||||
h1 span .two:focus,
|
||||
h2 span .two:focus,
|
||||
h3 span .two:focus,
|
||||
h4 span .two:focus,
|
||||
h5 span .two:focus,
|
||||
h1 a .three:hover,
|
||||
h1 a .three:focus,
|
||||
h2 a .three:focus,
|
||||
h3 a .three:focus,
|
||||
h4 a .three:focus,
|
||||
h5 a .three:focus,
|
||||
h1 p .three:focus,
|
||||
h2 p .three:focus,
|
||||
h3 p .three:focus,
|
||||
h4 p .three:focus,
|
||||
h5 p .three:focus,
|
||||
h1 div .three:focus,
|
||||
h2 div .three:focus,
|
||||
h3 div .three:focus,
|
||||
h4 div .three:focus,
|
||||
h5 div .three:focus,
|
||||
h1 span .three:focus,
|
||||
h2 span .three:focus,
|
||||
h3 span .three:focus,
|
||||
h4 span .three:focus,
|
||||
h5 span .three:focus,
|
||||
h1 a .four:hover,
|
||||
h1 a .four:focus,
|
||||
h2 a .four:focus,
|
||||
h3 a .four:focus,
|
||||
h4 a .four:focus,
|
||||
h5 a .four:focus,
|
||||
h1 p .one:hover,
|
||||
h1 p .one:focus,
|
||||
h1 p .two:hover,
|
||||
h1 p .two:focus,
|
||||
h1 p .three:hover,
|
||||
h1 p .three:focus,
|
||||
h1 p .four:hover,
|
||||
h1 p .four:focus,
|
||||
h2 p .four:focus,
|
||||
h3 p .four:focus,
|
||||
h4 p .four:focus,
|
||||
h5 p .four:focus,
|
||||
h1 div .one:hover,
|
||||
h1 div .one:focus,
|
||||
h1 div .two:hover,
|
||||
h1 div .two:focus,
|
||||
h1 div .three:hover,
|
||||
h1 div .three:focus,
|
||||
h1 div .four:hover,
|
||||
h1 div .four:focus,
|
||||
h2 div .four:focus,
|
||||
h3 div .four:focus,
|
||||
h4 div .four:focus,
|
||||
h5 div .four:focus,
|
||||
h1 span .one:hover,
|
||||
h1 span .one:focus,
|
||||
h1 span .two:hover,
|
||||
h1 span .two:focus,
|
||||
h1 span .three:hover,
|
||||
h1 span .three:focus,
|
||||
h1 span .four:hover,
|
||||
h1 span .four:focus,
|
||||
h2 a .one:hover,
|
||||
h2 a .one:focus,
|
||||
h2 a .two:hover,
|
||||
h2 a .two:focus,
|
||||
h2 a .three:hover,
|
||||
h2 a .three:focus,
|
||||
h2 a .four:hover,
|
||||
h2 a .four:focus,
|
||||
h2 p .one:hover,
|
||||
h2 p .one:focus,
|
||||
h2 p .two:hover,
|
||||
h2 p .two:focus,
|
||||
h2 p .three:hover,
|
||||
h2 p .three:focus,
|
||||
h2 p .four:hover,
|
||||
h2 p .four:focus,
|
||||
h2 div .one:hover,
|
||||
h2 div .one:focus,
|
||||
h2 div .two:hover,
|
||||
h2 div .two:focus,
|
||||
h2 div .three:hover,
|
||||
h2 div .three:focus,
|
||||
h2 div .four:hover,
|
||||
h2 div .four:focus,
|
||||
h2 span .one:hover,
|
||||
h2 span .one:focus,
|
||||
h2 span .two:hover,
|
||||
h2 span .two:focus,
|
||||
h2 span .three:hover,
|
||||
h2 span .three:focus,
|
||||
h2 span .four:hover,
|
||||
h2 span .four:focus,
|
||||
h3 a .one:hover,
|
||||
h3 a .one:focus,
|
||||
h3 a .two:hover,
|
||||
h3 a .two:focus,
|
||||
h3 a .three:hover,
|
||||
h3 a .three:focus,
|
||||
h3 a .four:hover,
|
||||
h3 a .four:focus,
|
||||
h3 p .one:hover,
|
||||
h3 p .one:focus,
|
||||
h3 p .two:hover,
|
||||
h3 p .two:focus,
|
||||
h3 p .three:hover,
|
||||
h3 p .three:focus,
|
||||
h3 p .four:hover,
|
||||
h3 p .four:focus,
|
||||
h3 div .one:hover,
|
||||
h3 div .one:focus,
|
||||
h3 div .two:hover,
|
||||
h3 div .two:focus,
|
||||
h3 div .three:hover,
|
||||
h3 div .three:focus,
|
||||
h3 div .four:hover,
|
||||
h3 div .four:focus,
|
||||
h3 span .one:hover,
|
||||
h3 span .one:focus,
|
||||
h3 span .two:hover,
|
||||
h3 span .two:focus,
|
||||
h3 span .three:hover,
|
||||
h3 span .three:focus,
|
||||
h3 span .four:hover,
|
||||
h3 span .four:focus,
|
||||
h4 a .one:hover,
|
||||
h4 a .one:focus,
|
||||
h4 a .two:hover,
|
||||
h4 a .two:focus,
|
||||
h4 a .three:hover,
|
||||
h4 a .three:focus,
|
||||
h4 a .four:hover,
|
||||
h4 a .four:focus,
|
||||
h4 p .one:hover,
|
||||
h4 p .one:focus,
|
||||
h4 p .two:hover,
|
||||
h4 p .two:focus,
|
||||
h4 p .three:hover,
|
||||
h4 p .three:focus,
|
||||
h4 p .four:hover,
|
||||
h4 p .four:focus,
|
||||
h4 div .one:hover,
|
||||
h4 div .one:focus,
|
||||
h4 div .two:hover,
|
||||
h4 div .two:focus,
|
||||
h4 div .three:hover,
|
||||
h4 div .three:focus,
|
||||
h4 div .four:hover,
|
||||
h4 div .four:focus,
|
||||
h4 span .one:hover,
|
||||
h4 span .one:focus,
|
||||
h4 span .two:hover,
|
||||
h4 span .two:focus,
|
||||
h4 span .three:hover,
|
||||
h4 span .three:focus,
|
||||
h4 span .four:hover,
|
||||
h4 span .four:focus,
|
||||
h5 a .one:hover,
|
||||
h5 a .one:focus,
|
||||
h5 a .two:hover,
|
||||
h5 a .two:focus,
|
||||
h5 a .three:hover,
|
||||
h5 a .three:focus,
|
||||
h5 a .four:hover,
|
||||
h5 a .four:focus,
|
||||
h5 p .one:hover,
|
||||
h5 p .one:focus,
|
||||
h5 p .two:hover,
|
||||
h5 p .two:focus,
|
||||
h5 p .three:hover,
|
||||
h5 p .three:focus,
|
||||
h5 p .four:hover,
|
||||
h5 p .four:focus,
|
||||
h5 div .one:hover,
|
||||
h5 div .one:focus,
|
||||
h5 div .two:hover,
|
||||
h5 div .two:focus,
|
||||
h5 div .three:hover,
|
||||
h5 div .three:focus,
|
||||
h5 div .four:hover,
|
||||
h5 div .four:focus,
|
||||
h5 span .one:hover,
|
||||
h5 span .one:focus,
|
||||
h5 span .two:hover,
|
||||
h5 span .two:focus,
|
||||
h5 span .three:hover,
|
||||
h5 span .three:focus,
|
||||
h5 span .four:hover,
|
||||
h5 span .four:focus {
|
||||
display: block;
|
||||
}
|
||||
|
10
lesscpy/test/css/nesting.min.css
vendored
10
lesscpy/test/css/nesting.min.css
vendored
@ -3,14 +3,14 @@
|
||||
.div .nest.deep{color:yellow;}
|
||||
.div .nest.deep .deeper{color:angry;}
|
||||
.div .nest.deep .deeper .deepest{color:purple;}
|
||||
h1 a:hover,h2 a:hover,h3 a:hover,h1 p:hover,h2 p:hover,h3 p:hover{color:red;}
|
||||
h1 a:hover,h1 p:hover,h2 a:hover,h2 p:hover,h3 a:hover,h3 p:hover{color:red;}
|
||||
a{color:red;}
|
||||
a:hover{color:blue;}
|
||||
div a{color:green;}
|
||||
p a span{color:yellow;}
|
||||
.foo .bar .qux,.foo .baz .qux{display:block;}
|
||||
.foo .qux .bar,.foo .qux .baz{display:inline;}
|
||||
.foo .qux .bar .biz,.foo .qux .baz .biz{display:none;}
|
||||
.qux .foo .bar,.qux .foo .baz{display:inline;}
|
||||
.qux .foo .bar .biz,.qux .foo .baz .biz{display:none;}
|
||||
#first>.one{font-size:2em;}
|
||||
#first>.one>#second .two>#deux{width:50%;}
|
||||
#first>.one>#second .two>#deux #third{height:100%;}
|
||||
@ -19,6 +19,6 @@ p a span{color:yellow;}
|
||||
#first>.one>#second .two>#deux #third:focus #fifth>#sixth .seventh #eighth+.sibling_selector{color:angry;}
|
||||
#first>.one>#second .two>#deux #third~p.general_sibling_selector{color:unused;}
|
||||
#first>.one>#second .two>#deux #fourth,#first>.one>#second .two>#deux #five,#first>.one>#second .two>#deux #six{color:#110000;}
|
||||
#first>.one>#second .two>#deux #fourth .seven,#first>.one>#second .two>#deux #five .seven,#first>.one>#second .two>#deux #six .seven,#first>.one>#second .two>#deux #fourth .eight>#nine,#first>.one>#second .two>#deux #five .eight>#nine,#first>.one>#second .two>#deux #six .eight>#nine{border:1px solid black;}
|
||||
#first>.one>#second .two>#deux #fourth .seven,#first>.one>#second .two>#deux #fourth .eight>#nine,#first>.one>#second .two>#deux #five .seven,#first>.one>#second .two>#deux #five .eight>#nine,#first>.one>#second .two>#deux #six .seven,#first>.one>#second .two>#deux #six .eight>#nine{border:1px solid black;}
|
||||
#first>.one>#second .two>#deux #fourth #ten,#first>.one>#second .two>#deux #five #ten,#first>.one>#second .two>#deux #six #ten{color:red;}
|
||||
h1 a .one:hover,h2 a .one:hover,h3 a .one:hover,h4 a .one:hover,h5 a .one:hover,h1 p .one:hover,h2 p .one:hover,h3 p .one:hover,h4 p .one:hover,h5 p .one:hover,h1 div .one:hover,h2 div .one:hover,h3 div .one:hover,h4 div .one:hover,h5 div .one:hover,h1 span .one:hover,h2 span .one:hover,h3 span .one:hover,h4 span .one:hover,h5 span .one:hover,h1 a .two:hover,h2 a .two:hover,h3 a .two:hover,h4 a .two:hover,h5 a .two:hover,h1 p .two:hover,h2 p .two:hover,h3 p .two:hover,h4 p .two:hover,h5 p .two:hover,h1 div .two:hover,h2 div .two:hover,h3 div .two:hover,h4 div .two:hover,h5 div .two:hover,h1 span .two:hover,h2 span .two:hover,h3 span .two:hover,h4 span .two:hover,h5 span .two:hover,h1 a .three:hover,h2 a .three:hover,h3 a .three:hover,h4 a .three:hover,h5 a .three:hover,h1 p .three:hover,h2 p .three:hover,h3 p .three:hover,h4 p .three:hover,h5 p .three:hover,h1 div .three:hover,h2 div .three:hover,h3 div .three:hover,h4 div .three:hover,h5 div .three:hover,h1 span .three:hover,h2 span .three:hover,h3 span .three:hover,h4 span .three:hover,h5 span .three:hover,h1 a .four:hover,h2 a .four:hover,h3 a .four:hover,h4 a .four:hover,h5 a .four:hover,h1 p .four:hover,h2 p .four:hover,h3 p .four:hover,h4 p .four:hover,h5 p .four:hover,h1 div .four:hover,h2 div .four:hover,h3 div .four:hover,h4 div .four:hover,h5 div .four:hover,h1 span .four:hover,h2 span .four:hover,h3 span .four:hover,h4 span .four:hover,h5 span .four:hover,h1 a .one:focus,h2 a .one:focus,h3 a .one:focus,h4 a .one:focus,h5 a .one:focus,h1 p .one:focus,h2 p .one:focus,h3 p .one:focus,h4 p .one:focus,h5 p .one:focus,h1 div .one:focus,h2 div .one:focus,h3 div .one:focus,h4 div .one:focus,h5 div .one:focus,h1 span .one:focus,h2 span .one:focus,h3 span .one:focus,h4 span .one:focus,h5 span .one:focus,h1 a .two:focus,h2 a .two:focus,h3 a .two:focus,h4 a .two:focus,h5 a .two:focus,h1 p .two:focus,h2 p .two:focus,h3 p .two:focus,h4 p .two:focus,h5 p .two:focus,h1 div .two:focus,h2 div .two:focus,h3 div .two:focus,h4 div .two:focus,h5 div .two:focus,h1 span .two:focus,h2 span .two:focus,h3 span .two:focus,h4 span .two:focus,h5 span .two:focus,h1 a .three:focus,h2 a .three:focus,h3 a .three:focus,h4 a .three:focus,h5 a .three:focus,h1 p .three:focus,h2 p .three:focus,h3 p .three:focus,h4 p .three:focus,h5 p .three:focus,h1 div .three:focus,h2 div .three:focus,h3 div .three:focus,h4 div .three:focus,h5 div .three:focus,h1 span .three:focus,h2 span .three:focus,h3 span .three:focus,h4 span .three:focus,h5 span .three:focus,h1 a .four:focus,h2 a .four:focus,h3 a .four:focus,h4 a .four:focus,h5 a .four:focus,h1 p .four:focus,h2 p .four:focus,h3 p .four:focus,h4 p .four:focus,h5 p .four:focus,h1 div .four:focus,h2 div .four:focus,h3 div .four:focus,h4 div .four:focus,h5 div .four:focus,h1 span .four:focus,h2 span .four:focus,h3 span .four:focus,h4 span .four:focus,h5 span .four:focus{display:block;}
|
||||
h1 a .one:hover,h1 a .one:focus,h1 a .two:hover,h1 a .two:focus,h1 a .three:hover,h1 a .three:focus,h1 a .four:hover,h1 a .four:focus,h1 p .one:hover,h1 p .one:focus,h1 p .two:hover,h1 p .two:focus,h1 p .three:hover,h1 p .three:focus,h1 p .four:hover,h1 p .four:focus,h1 div .one:hover,h1 div .one:focus,h1 div .two:hover,h1 div .two:focus,h1 div .three:hover,h1 div .three:focus,h1 div .four:hover,h1 div .four:focus,h1 span .one:hover,h1 span .one:focus,h1 span .two:hover,h1 span .two:focus,h1 span .three:hover,h1 span .three:focus,h1 span .four:hover,h1 span .four:focus,h2 a .one:hover,h2 a .one:focus,h2 a .two:hover,h2 a .two:focus,h2 a .three:hover,h2 a .three:focus,h2 a .four:hover,h2 a .four:focus,h2 p .one:hover,h2 p .one:focus,h2 p .two:hover,h2 p .two:focus,h2 p .three:hover,h2 p .three:focus,h2 p .four:hover,h2 p .four:focus,h2 div .one:hover,h2 div .one:focus,h2 div .two:hover,h2 div .two:focus,h2 div .three:hover,h2 div .three:focus,h2 div .four:hover,h2 div .four:focus,h2 span .one:hover,h2 span .one:focus,h2 span .two:hover,h2 span .two:focus,h2 span .three:hover,h2 span .three:focus,h2 span .four:hover,h2 span .four:focus,h3 a .one:hover,h3 a .one:focus,h3 a .two:hover,h3 a .two:focus,h3 a .three:hover,h3 a .three:focus,h3 a .four:hover,h3 a .four:focus,h3 p .one:hover,h3 p .one:focus,h3 p .two:hover,h3 p .two:focus,h3 p .three:hover,h3 p .three:focus,h3 p .four:hover,h3 p .four:focus,h3 div .one:hover,h3 div .one:focus,h3 div .two:hover,h3 div .two:focus,h3 div .three:hover,h3 div .three:focus,h3 div .four:hover,h3 div .four:focus,h3 span .one:hover,h3 span .one:focus,h3 span .two:hover,h3 span .two:focus,h3 span .three:hover,h3 span .three:focus,h3 span .four:hover,h3 span .four:focus,h4 a .one:hover,h4 a .one:focus,h4 a .two:hover,h4 a .two:focus,h4 a .three:hover,h4 a .three:focus,h4 a .four:hover,h4 a .four:focus,h4 p .one:hover,h4 p .one:focus,h4 p .two:hover,h4 p .two:focus,h4 p .three:hover,h4 p .three:focus,h4 p .four:hover,h4 p .four:focus,h4 div .one:hover,h4 div .one:focus,h4 div .two:hover,h4 div .two:focus,h4 div .three:hover,h4 div .three:focus,h4 div .four:hover,h4 div .four:focus,h4 span .one:hover,h4 span .one:focus,h4 span .two:hover,h4 span .two:focus,h4 span .three:hover,h4 span .three:focus,h4 span .four:hover,h4 span .four:focus,h5 a .one:hover,h5 a .one:focus,h5 a .two:hover,h5 a .two:focus,h5 a .three:hover,h5 a .three:focus,h5 a .four:hover,h5 a .four:focus,h5 p .one:hover,h5 p .one:focus,h5 p .two:hover,h5 p .two:focus,h5 p .three:hover,h5 p .three:focus,h5 p .four:hover,h5 p .four:focus,h5 div .one:hover,h5 div .one:focus,h5 div .two:hover,h5 div .two:focus,h5 div .three:hover,h5 div .three:focus,h5 div .four:hover,h5 div .four:focus,h5 span .one:hover,h5 span .one:focus,h5 span .two:hover,h5 span .two:focus,h5 span .three:hover,h5 span .three:focus,h5 span .four:hover,h5 span .four:focus{display:block;}
|
||||
|
@ -6,6 +6,7 @@ from lesscpy.plib.identifier import Identifier
|
||||
|
||||
class TestIdentifier(unittest.TestCase):
|
||||
def test_basic(self):
|
||||
fl = {'ws': ' '}
|
||||
for i in [
|
||||
([], ''),
|
||||
(['.scope', ' ', 'a'], '.scope a'),
|
||||
@ -13,42 +14,71 @@ class TestIdentifier(unittest.TestCase):
|
||||
(['a', '.scope'], 'a.scope'),
|
||||
(['a', '>', 'p', '>', 'h2'], 'a > p > h2'),
|
||||
(['a', '~', 'p', '+', 'h2'], 'a ~ p + h2'),
|
||||
(['*', 'html'], '* html'),
|
||||
]:
|
||||
t, r = i
|
||||
id = Identifier(t, 0)
|
||||
self.assertEqual(id.parse(None), r, i)
|
||||
self.assertEqual(id.parse(None).format(fl), r, i)
|
||||
|
||||
def test_scope(self):
|
||||
fl = {'ws': ' '}
|
||||
sc = Scope()
|
||||
sc.push()
|
||||
sc.current = '.current'
|
||||
sc.push()
|
||||
sc.current = '.next'
|
||||
sc.current = Identifier(['.current'], 0).parse(sc)
|
||||
for i in [
|
||||
(['.scope', ' ', 'a'], '.current .scope a'),
|
||||
(['a', ' ', '.scope'], '.current a .scope'),
|
||||
(['a', '.scope'], '.current a.scope'),
|
||||
(['a', '>', 'p', '>', 'h2'], '.current a > p > h2'),
|
||||
(['a', '~', 'p', '+', 'h2'], '.current a ~ p + h2'),
|
||||
(['>', 'p', '+', 'h2'], '.current > p + h2'),
|
||||
]:
|
||||
t, r = i
|
||||
id = Identifier(t, 0)
|
||||
self.assertEqual(id.parse(sc), r, i)
|
||||
self.assertEqual(id.parse(sc).format(fl), r, i)
|
||||
|
||||
def test_combinators(self):
|
||||
fl = {'ws': ' '}
|
||||
sc = Scope()
|
||||
sc.push()
|
||||
sc.current = '.current'
|
||||
sc.push()
|
||||
sc.current = '.next'
|
||||
sc.current = Identifier(['.current'], 0).parse(sc)
|
||||
for i in [
|
||||
(['&.scope', ' ', 'a'], '.current.scope a'),
|
||||
(['&', '.scope', ' ', 'a'], '.current.scope a'),
|
||||
(['.scope', '&', ' ', 'a'], '.scope.current a'),
|
||||
(['.scope', ' ', 'a', '&'], '.scope a.current'),
|
||||
(['&', '>' ,'.scope', ' ', 'a'], '.current > .scope a'),
|
||||
(['.span', '&', '.scope', ' ', 'a', '&'], '.span.current.scope a.current'),
|
||||
]:
|
||||
t, r = i
|
||||
id = Identifier(t, 0)
|
||||
self.assertEqual(id.parse(sc), r, i)
|
||||
self.assertEqual(id.parse(sc).format(fl), r, i)
|
||||
sc.push()
|
||||
sc.current = Identifier(['&', '.next'], 0).parse(sc)
|
||||
id = Identifier(['&', '.top'], 0)
|
||||
self.assertEqual(id.parse(sc).format(fl), '.current.next.top')
|
||||
|
||||
def test_groups(self):
|
||||
fl = {'ws': ' '}
|
||||
sc = Scope()
|
||||
sc.push()
|
||||
sc.current = Identifier(['.a', ',', '.b'], 0).parse(sc)
|
||||
for i in [
|
||||
(['&', '.scope', ' ', 'a'], '.a.scope a, .b.scope a'),
|
||||
(['.scope', '&', ' ', 'a'], '.scope.a a, .scope.b a'),
|
||||
(['.scope', ' ', 'a', '&'], '.scope a.a, .scope a.b'),
|
||||
(['>' ,'&', '.scope', ' ', 'a'], ' > .a.scope a, > .b.scope a'),
|
||||
]:
|
||||
t, r = i
|
||||
id = Identifier(t, 0)
|
||||
self.assertEqual(id.parse(sc).format(fl), r, i)
|
||||
sc.current = Identifier(['.next'], 0).parse(sc)
|
||||
sc.push()
|
||||
sc.current = Identifier(['.c', ',', '.d'], 0).parse(sc)
|
||||
id = Identifier(['.deep'], 0)
|
||||
self.assertEqual(id.parse(sc).format(fl), '.a .next .c .deep, '
|
||||
'.a .next .d .deep, '
|
||||
'.b .next .c .deep, '
|
||||
'.b .next .d .deep')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user