more tests

This commit is contained in:
jtm
2012-03-13 21:12:09 +00:00
parent 6ca9dfba04
commit efdca1e9f8
6 changed files with 25 additions and 14 deletions

View File

@@ -98,11 +98,12 @@ class LessLexer:
t.type = 'css_class'
elif c == '#':
t.type = 'css_id'
try:
int(v[1:], 16)
t.type = 'css_color'
except ValueError:
pass
if len(v) in [4, 7]:
try:
int(v[1:], 16)
t.type = 'css_color'
except ValueError:
pass
elif v in css.propertys:
t.type = 'css_property'
t.value = t.value.strip()

View File

@@ -98,9 +98,6 @@ class LessParser(object):
else:
print(pad, t)
self._scopemap_aux(list(utility.flatten(ll.tokens)), lvl+1)
# else:
# print(pad, t)
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -582,7 +579,11 @@ class LessParser(object):
def p_color(self, p):
""" color : css_color
"""
p[0] = Color().fmt(p[1])
try:
p[0] = Color().fmt(p[1])
except ValueError:
self.handle_error('Illegal color value `%s`' % p[1], p.lineno(1), 'W')
p[0] = p[1]
def p_number(self, p):
""" number : css_number

View File

@@ -10,6 +10,7 @@
import os
import sys
import glob
import copy
import argparse
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
from lesscpy.lessc import parser
@@ -121,9 +122,7 @@ def run():
if not scope:
scope = p.scope
else:
scope[0].update(p.scope[0])
else:
scope = None
scope.update(p.scope)
p = None
f = formatter.Formatter()
if not os.path.exists(args.target):
@@ -136,7 +135,7 @@ def run():
p = parser.LessParser(yacc_debug=(args.debug),
lex_optimize=True,
yacc_optimize=(not args.debug),
scope=scope,
scope=copy.deepcopy(scope),
verbose=args.verbose)
p.parse(filename=args.target, debuglevel=0)
if args.scopemap:

View File

@@ -202,3 +202,6 @@ nav,
section {
padding: 0;
}
#f7 {
color: #fff777;
}

View File

@@ -30,3 +30,4 @@ a.one,a.two,a.three,a.four,a.five,a.six,a.seven,a.eight,a.nine,a.ten{max-width:1
a.longclassname.one,a.longclassname.two,a.longclassname.three,a.longclassname.four,a.longclassname.five,a.longclassname.six,a.longclassname.seven,a.longclassname.eight,a.longclassname.nine,a.longclassname.ten{max-height:12px;}
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{padding:0;}
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{padding:0;}
#f7{color:#fff777;}

View File

@@ -120,4 +120,10 @@ time, mark, audio, video {
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
padding: 0;
}
}
/*
...
*/
#f7 {
color: #fff777;
}