From ddb1b7e0ed707a4da66e9686b00c82050757c98b Mon Sep 17 00:00:00 2001 From: jaraco Date: Tue, 1 Sep 2009 02:04:16 +0000 Subject: [PATCH] Adding support for an SVG profile in cssutils --- svg/charts/css.py | 22 ++++++++++++++++++++++ svg/charts/graph.py | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 svg/charts/css.py diff --git a/svg/charts/css.py b/svg/charts/css.py new file mode 100644 index 0000000..f11d923 --- /dev/null +++ b/svg/charts/css.py @@ -0,0 +1,22 @@ +import cssutils + +SVG = 'SVG 1.1' # http://www.w3.org/TR/SVG11/styling.html + +macros = cssutils.profile._MACROS.copy() +macros.update({ + 'paint': 'none|currentColor|{color}', + # spec actually says length, but our length macro requires units, so use positivenum + 'dasharray': '{positivenum}(\s*,\s*{positivenum})*', + }) +properties = { + 'stroke': '{paint}', + 'fill': '{paint}', + 'text-anchor': 'start|middle|end|inherit', + 'stroke-width': '{length}|inherit', + 'fill-opacity': '{num}|inherit', + 'stroke-dasharray': 'none|{dasharray}|inherit', + } + +cssutils.profile.addProfile(SVG, properties, macros) + +cssutils.profile.defaultProfiles = [SVG, cssutils.profile.CSS_LEVEL_2] \ No newline at end of file diff --git a/svg/charts/graph.py b/svg/charts/graph.py index 2088f81..1fe5612 100644 --- a/svg/charts/graph.py +++ b/svg/charts/graph.py @@ -8,6 +8,8 @@ import pkg_resources from lxml import etree +from svg.charts import css # causes the profile to be loaded + try: import zlib except ImportError: