keyframes

This commit is contained in:
jtm
2012-03-23 16:45:28 +00:00
parent a89f65dd4d
commit 73949b9740
7 changed files with 68 additions and 4 deletions

View File

@@ -52,7 +52,7 @@ class LessParser(object):
tabfile = 'yacctab'
self.ignored = ('css_comment', 'less_comment',
'css_vendor_hack', 'css_keyframes')
'css_vendor_hack')
self.tokens = [t for t in self.lex.tokens
if t not in self.ignored]
@@ -398,6 +398,12 @@ class LessParser(object):
"""
p[0] = p[1]
def p_identifier_list_keyframe(self, p):
""" identifier_list : css_keyframes t_ws css_ident
| css_keyframes t_ws css_ident t_ws
"""
p[0] = list(p)[1:]
def p_identifier_group_op(self, p):
""" identifier_group : identifier_group child_selector ident_parts
| identifier_group '+' ident_parts

View File

@@ -102,6 +102,8 @@ html4 = [
'screen',
'all',
'projection',
'from',
'to'
]
html5 = [
'article',

View File

@@ -46,7 +46,7 @@ class Block(Node):
})
out.append(f % fills)
if self.inner:
if name.startswith('@media'):
if self.name.subparse: # @media
inner = ''.join([p.fmt(fills) for p in self.inner])
inner = inner.replace(fills['nl'],
fills['nl'] + fills['tab']).rstrip(fills['tab'])

View File

@@ -9,9 +9,15 @@ class Identifier(Node):
"""
names = []
name = []
if self.tokens and self.tokens[0] == '@media':
self._subp = (
'@media', '@keyframes',
'@-moz-keyframes', '@-webkit-keyframes'
)
if self.tokens and self.tokens[0] in self._subp:
name = list(utility.flatten(self.tokens))
self.subparse = True
else:
self.subparse = False
for n in utility.flatten(self.tokens):
if n == '*':
name.append('* ')
@@ -38,7 +44,7 @@ class Identifier(Node):
if parent:
parent = parent[-1]
return [self._pscn(part, n)
if part[0] != '@media'
if part[0] not in self._subp
else n
for part in parent.parsed
for n in names]

View File

@@ -0,0 +1,24 @@
@-webkit-keyframes progress-bar-stripes {
from {
background-position: 0 0;
}
to {
background-position: 40px 0;
}
}
@-moz-keyframes progress-bar-stripes {
from {
background-position: 0 0;
}
to {
background-position: 40px 0;
}
}
@keyframes progress-bar-stripes {
from {
background-position: 0 0;
}
to {
background-position: 40px 0;
}
}

9
lesscpy/test/css/keyframes.min.css vendored Normal file
View File

@@ -0,0 +1,9 @@
@-webkit-keyframes progress-bar-stripes{from{background-position:0 0;}
to{background-position:40px 0;}
}
@-moz-keyframes progress-bar-stripes{from{background-position:0 0;}
to{background-position:40px 0;}
}
@keyframes progress-bar-stripes{from{background-position:0 0;}
to{background-position:40px 0;}
}

View File

@@ -0,0 +1,17 @@
// Webkit
@-webkit-keyframes progress-bar-stripes {
from { background-position: 0 0; }
to { background-position: 40px 0; }
}
// Firefox
@-moz-keyframes progress-bar-stripes {
from { background-position: 0 0; }
to { background-position: 40px 0; }
}
// Spec
@keyframes progress-bar-stripes {
from { background-position: 0 0; }
to { background-position: 40px 0; }
}