Merge pull request #17 from saschpe/master-svg

Implement SVG stylesheets
This commit is contained in:
robotis
2013-08-08 03:16:09 -07:00
16 changed files with 212 additions and 24 deletions

View File

@@ -6,5 +6,4 @@ python:
# command to install dependencies
install: "pip install -r requirements.txt --use-mirrors"
# command to run tests
script: python lesscpy/test/__main__.py
script: python lesscpy/test/__main__.py -v

View File

@@ -129,7 +129,7 @@ class LessLexer:
elif v in css.propertys:
t.type = 'css_property'
t.value = t.value.strip()
elif v.lower() in dom.html:
elif v in dom.html or v.lower() in dom.html:
t.type = 'css_dom'
elif c == '@':
v = v.lower()

View File

@@ -272,6 +272,52 @@ css3 = [
'word-break',
'word-wrap'
]
# SVG only includes style not present in either css2 or css3:
svg = [
# clipping / masking / compositing:
'clip-path',
'clip-rule',
'mask',
# filter effects:
'enable-background',
'filter',
'flood-color',
'flood-opacity',
'lightning-color',
# gradient:
'stop-color',
'stop-opacity',
# interactivity:
'pointer-events',
# color / painting:
'color-interpolation',
'color-interpolation-filters',
'color-rendering',
'fill',
'fill-opacity',
'fill-rule',
'image-rendering',
'marker',
'marker-end',
'marker-mid',
'marker-start',
'shape-rendering',
'stroke',
'stroke-dasharray',
'stroke-dashoffset',
'stroke-linecap',
'stroke-linejoin',
'stroke-miterlimit',
'stroke-opacity',
'stroke-width',
'text-rendering',
# text:
'glyph-orientation-horizontal',
'glyph-orientation-vertical',
'kerning',
'text-anchor',
'writing-mode',
]
vendor_prefix = [
'-ms-',
'-moz-',
@@ -284,10 +330,8 @@ vendor_prefix = [
'mso-',
]
vendor_ugly = [
'filter',
'accelerator',
'behavior',
'filter',
'zoom',
]
propertys = css2 + css3 + vendor_ugly
propertys = css2 + css3 + svg + vendor_ugly

View File

@@ -140,5 +140,24 @@ html5 = [
'video',
'wbr',
]
svg = [
'altGlyph',
'altGlyphDef',
'altGlyphItem',
'circle',
'desc',
'ellipse',
'glyphRef',
'line',
'path',
'polygon',
'polyline',
'rect',
'text',
'textPath',
'tref',
'tspan',
]
html = html4
html.extend(html5)
html.extend(svg)

View File

@@ -196,7 +196,7 @@ class Call(Node):
str
"""
n, u = utility.analyze_number(value)
return utility.with_unit(round(float(n)), u)
return utility.with_unit(int(round(float(n))), u)
def ceil(self, value, *args):
""" Ceil number
@@ -206,7 +206,7 @@ class Call(Node):
str
"""
n, u = utility.analyze_number(value)
return utility.with_unit(math.ceil(n), u)
return utility.with_unit(int(math.ceil(n)), u)
def floor(self, value, *args):
""" Floor number
@@ -216,7 +216,7 @@ class Call(Node):
str
"""
n, u = utility.analyze_number(value)
return utility.with_unit(math.floor(n), u)
return utility.with_unit(int(math.floor(n)), u)
def percentage(self, value, *args):
""" Return percentage value

View File

@@ -75,7 +75,7 @@
}
.lighten {
color: #585858;
color: #6e6e6e;
color: #6f6f6f;
color: #888888;
color: #bbbbbb;
color: #eeeeee;

View File

@@ -12,7 +12,7 @@
.hsl{color:#ffffff;color:#ffffff;color:#000000;color:#000000;}
.saturate{color:#565454;color:#5e4c4c;color:#664444;color:#773333;color:#882222;color:#aa0000;color:#000000;color:#000000;color:#ffffff;color:#ffffff;color:#29332f;color:#243830;color:#203c31;color:#174533;color:#0d4f35;color:#005c37;}
.desaturate{color:#555555;color:#555555;color:#555555;color:#555555;color:#555555;color:#555555;color:#000000;color:#000000;color:#ffffff;color:#ffffff;color:#29332f;color:#2e2e2e;color:#2e2e2e;color:#2e2e2e;color:#2e2e2e;color:#2e2e2e;}
.lighten{color:#585858;color:#6e6e6e;color:#888888;color:#bbbbbb;color:#eeeeee;color:#ffffff;color:#ffffff;color:#000000;color:#ffffff;color:#ffffff;color:#2b3632;color:#404f49;color:#566c63;color:#88a096;color:#c1cdc8;color:#ffffff;}
.lighten{color:#585858;color:#6f6f6f;color:#888888;color:#bbbbbb;color:#eeeeee;color:#ffffff;color:#ffffff;color:#000000;color:#ffffff;color:#ffffff;color:#2b3632;color:#404f49;color:#566c63;color:#88a096;color:#c1cdc8;color:#ffffff;}
.lighten{color:#525252;color:#3b3b3b;color:#222222;color:#000000;color:#000000;color:#000000;color:#000000;color:#000000;color:#000000;color:#ffffff;color:#27302c;color:#121715;color:#000000;color:#000000;color:#000000;color:#000000;}
.spin{color:#555555;color:#555555;color:#555555;color:#555555;color:#555555;color:#555555;color:#000000;color:#000000;color:#ffffff;color:#ffffff;color:#29332f;color:#29332d;color:#293332;color:#2a3329;color:#292d33;color:#2c2933;}
.grayscale{color:#000000;color:#000000;color:#ffffff;color:#ffffff;color:#2e2e2e;color:#2e2e2e;color:#2e2e2e;color:#2e2e2e;color:#2e2e2e;color:#2e2e2e;}

View File

@@ -124,13 +124,13 @@
margin-left: 59.1;
}
.offset3 {
margin-left: 87.80000000000001;
margin-left: 87.8;
}
.offset4 {
margin-left: 116.5;
}
.offset5 {
margin-left: 145.20000000000002;
margin-left: 145.2;
}
.offset6 {
margin-left: 173.9;

View File

@@ -39,9 +39,9 @@
.span12,.container{width:342.7;}
.offset1{margin-left:30.4;}
.offset2{margin-left:59.1;}
.offset3{margin-left:87.80000000000001;}
.offset3{margin-left:87.8;}
.offset4{margin-left:116.5;}
.offset5{margin-left:145.20000000000002;}
.offset5{margin-left:145.2;}
.offset6{margin-left:173.9;}
.offset7{margin-left:202.6;}
.offset8{margin-left:231.3;}

62
lesscpy/test/css/svg.css Normal file
View File

@@ -0,0 +1,62 @@
svg {
color: red;
}
circle {
stroke: #006600;
fill: #00cc00;
}
circle .green {
stroke: #006600;
stroke-width: 9;
fill: #00cc00;
}
rect {
fill: blue;
fill-opacity: 0.1;
stroke: green;
opacity: 0.5;
}
ellipse {
fill: yellow;
}
line {
stroke: red;
}
path {
stroke: blue;
}
polygon {
fill: lime;
fill-rule: nonzero;
}
polygon {
fill: lime;
fill-rule: evenodd;
}
polyline {
fill: none;
}
.node text {
font: 12px sans-serif;
}
tref {
font-weight: bold;
}
text tref {
font-weight: bold;
}
tspan {
font-weight: bold;
}
text tspan {
font-weight: bold;
}
textPath {
font-weight: bold;
}
text textPath {
font-weight: bold;
}
svg text textPath {
font-weight: bold;
}

18
lesscpy/test/css/svg.min.css vendored Normal file
View File

@@ -0,0 +1,18 @@
svg{color:red;}
circle{stroke:#006600;fill:#00cc00;}
circle .green{stroke:#006600;stroke-width:9;fill:#00cc00;}
rect{fill:blue;fill-opacity:0.1;stroke:green;opacity:0.5;}
ellipse{fill:yellow;}
line{stroke:red;}
path{stroke:blue;}
polygon{fill:lime;fill-rule:nonzero;}
polygon{fill:lime;fill-rule:evenodd;}
polyline{fill:none;}
.node text{font:12px sans-serif;}
tref{font-weight:bold;}
text tref{font-weight:bold;}
tspan{font-weight:bold;}
text tspan{font-weight:bold;}
textPath{font-weight:bold;}
text textPath{font-weight:bold;}
svg text textPath{font-weight:bold;}

View File

@@ -0,0 +1,38 @@
svg {color: red;}
circle {
stroke: #006600;
fill: #00cc00;
}
circle .green {
stroke: #006600;
stroke-width: 9;
fill: #00cc00;
}
rect {
fill: blue;
fill-opacity: 0.1;
stroke: green;
opacity: 0.5;
}
ellipse { fill: yellow; }
line { stroke: red; }
path { stroke: blue; }
polygon {
fill: lime;
fill-rule: nonzero;
}
polygon {
fill: lime;
fill-rule: evenodd;
}
polyline { fill: none; }
.node text { font: 12px sans-serif; }
tref { font-weight: bold; }
text tref { font-weight: bold; }
tspan { font-weight: bold; }
text tspan { font-weight: bold; }
textPath { font-weight: bold; }
text textPath { font-weight: bold; }
svg text textPath { font-weight: bold; }

View File

@@ -51,12 +51,16 @@ def create_test(args):
return do_test_expected
LESS = glob.glob(os.path.join('less/issues', '*.less'))
_less_path = os.path.join(os.path.dirname(__file__), 'less', 'issues')
_css_path = os.path.join(os.path.dirname(__file__), 'css', 'issues')
LESS = glob.glob(os.path.join(_less_path, '*.less'))
for less in LESS:
lessf = less.split('.')[0].split('/')[-1]
css = 'css/issues/' + lessf + '.css'
mincss = 'css/issues/' + lessf + '.min.css'
css = os.path.join(_css_path, lessf + '.css')
mincss = os.path.join(_css_path, lessf + '.min.css')
test_method = create_test((less, css, mincss))
test_method.__name__ = 'test_%s' % less.replace('./-', '_')
test_method.__name__ = 'test_%s' % "_".join(reversed(os.path.basename(less).split('.')))
setattr(TestCase, test_method.__name__, test_method)
if __name__ == "__main__":

View File

@@ -72,13 +72,17 @@ def create_test(args):
self.fail("%s not found..." % minf)
return do_test_expected
LESS = glob.glob(os.path.join('less/', '*.less'))
_less_path = os.path.join(os.path.dirname(__file__), 'less')
_css_path = os.path.join(os.path.dirname(__file__), 'css')
LESS = glob.glob(os.path.join(_less_path, '*.less'))
for less in LESS:
lessf = less.split('.')[0].split('/')[-1]
css = 'css/' + lessf + '.css'
mincss = 'css/' + lessf + '.min.css'
css = os.path.join(_css_path, lessf + '.css')
mincss = os.path.join(_css_path, lessf + '.min.css')
test_method = create_test((less, css, mincss))
test_method.__name__ = 'test_%s' % less.replace('./-', '_')
test_method.__name__ = 'test_%s' % "_".join(reversed(os.path.basename(less).split('.')))
setattr(TestCase, test_method.__name__, test_method)
if __name__ == "__main__":

View File

@@ -6,7 +6,7 @@ from distutils.core import setup
setup(
name='lesscpy',
version='0.9h',
version='0.9i',
description='Lesscss compiler.',
author='Jóhann T Maríusson',
author_email='jtm@robot.is',

View File

@@ -3,7 +3,7 @@ envlist = py26,py27,py33,pep8
[testenv]
deps = -r{toxinidir}/requirements.txt
commands = python lesscpy/test/__main__.py
commands = python lesscpy/test/__main__.py -v
[testenv:pep8]
deps = pep8