From: acspike Date: Thu, 20 Jul 2006 04:23:59 +0000 (+0000) Subject: fix an old bug in the style splitting routine and add to the makefile X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=edaa38549078adfac0e05e7c9b4b6d9379ee60f9;p=inkscape.git fix an old bug in the style splitting routine and add to the makefile --- diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am index 1195266b1..fc4297abc 100644 --- a/share/extensions/Makefile.am +++ b/share/extensions/Makefile.am @@ -52,7 +52,8 @@ extensions = \ flatten.py \ measure.py \ gimp_xcf.py \ - eqtexsvg.py + eqtexsvg.py \ + markers_strokepaint.py otherstuff = \ aisvg.xslt @@ -103,7 +104,8 @@ modules = \ gimp_xcf.inx \ randompnt.inx \ randompos.inx \ - eqtexsvg.inx + eqtexsvg.inx \ + markers_strokepaint.inx extension_SCRIPTS = \ $(extensions) diff --git a/share/extensions/markers_strokepaint.py b/share/extensions/markers_strokepaint.py index f49a37a77..163767f1a 100644 --- a/share/extensions/markers_strokepaint.py +++ b/share/extensions/markers_strokepaint.py @@ -32,7 +32,7 @@ class MyEffect(inkex.Effect): self.ctx = inkex.xml.xpath.Context.Context(self.document,processorNss=inkex.NSS) defs = self.xpathSingle('/svg/defs') for id, node in self.selected.iteritems(): - mprops = ['marker-start','marker-mid','marker-end'] + mprops = ['marker','marker-start','marker-mid','marker-end'] style = simplestyle.parseStyle(node.attributes.getNamedItem('style').value) try: @@ -43,15 +43,16 @@ class MyEffect(inkex.Effect): for mprop in mprops: if style.has_key(mprop) and style[mprop] != 'none'and style[mprop][:5] == 'url(#': marker_id = style[mprop][5:-1] - old_mnode = self.xpathSingle('/svg/defs/marker[@id="%s"]' % marker_id) + old_mnode = self.xpathSingle('/svg//marker[@id="%s"]' % marker_id) mnode = old_mnode.cloneNode(True) new_id = "%s%s" % (marker_id,2) style[mprop] = "url(#%s)" % new_id mnode.attributes.getNamedItem('id').value = new_id defs.appendChild(mnode) - children = inkex.xml.xpath.Evaluate('/svg/defs/marker[@id="%s"]//*[@style]' % new_id,self.document,context=self.ctx) + children = inkex.xml.xpath.Evaluate('/svg//marker[@id="%s"]//*[@style]' % new_id,self.document,context=self.ctx) for child in children: + inkex.debug(child.attributes.getNamedItem('style').value) cstyle = simplestyle.parseStyle(child.attributes.getNamedItem('style').value) if (cstyle.has_key('stroke') and cstyle['stroke'] != 'none') or not cstyle.has_key('stroke'): cstyle['stroke'] = stroke diff --git a/share/extensions/simplestyle.py b/share/extensions/simplestyle.py index 22b4c3e8b..e11f91ae0 100755 --- a/share/extensions/simplestyle.py +++ b/share/extensions/simplestyle.py @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ def parseStyle(s): """Create a dictionary from the value of an inline style attribute""" - return dict([i.split(":") for i in s.split(";")]) + return dict([i.split(":") for i in s.split(";") if len(i)]) def formatStyle(a): """Format an inline style attribute from a dictionary""" return ";".join([":".join(i) for i in a.iteritems()])