Fix Bug 503750: Update inkscape extension to include new --enable-viewboxing option
This commit is contained in:
parent
ed1c522caf
commit
6230682a01
4 changed files with 19 additions and 16 deletions
|
|
@ -37,10 +37,13 @@ class ScourInkscape (inkex.Effect):
|
|||
self.OptionParser.add_option("--indent",
|
||||
action="store", type="string", dest="indent_type", default="space",
|
||||
help="indentation of the output: none, space, tab (default: %default)")
|
||||
self.OptionParser.add_option("--enable-viewboxing", type="inkbool",
|
||||
action="store", dest="enable_viewboxing", default=False,
|
||||
help="changes document width/height to 100%/100% and creates viewbox coordinates")
|
||||
|
||||
|
||||
def effect(self):
|
||||
input = file(sys.argv[11], "r")
|
||||
input = file(sys.argv[12], "r")
|
||||
sys.stdout.write(scourString(input.read(), self.options).encode("UTF-8"))
|
||||
input.close()
|
||||
sys.stdout.close()
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
<param name="enable-id-stripping" type="boolean" _gui-text="Enable id stripping">false</param>
|
||||
<param name="embed-rasters" type="boolean" _gui-text="Embed rasters">true</param>
|
||||
<param name="keep-editor-data" type="boolean" _gui-text="Keep editor data">false</param>
|
||||
<param name="enable-viewboxing" type="boolean" _gui-text="Enable viewboxing">false</param>
|
||||
<param name="strip-xml-prolog" type="boolean" _gui-text="Strip xml prolog">false</param>
|
||||
<param name="set-precision" type="int" _gui-text="Set precision">5</param>
|
||||
<param name="indent" type="enum" _gui-text="Indent">
|
||||
|
|
@ -29,6 +30,7 @@
|
|||
* Enable id stripping: remove all un-referenced ID attributes.
|
||||
* Embed rasters: embed rasters as base64-encoded data.
|
||||
* Keep editor data: don't remove Inkscape, Sodipodi or Adobe Illustrator elements and attributes.
|
||||
* Enable viewboxing: size image to 100%/100% and introduce a viewBox
|
||||
* Strip xml prolog: don't output the xml prolog.
|
||||
* Set precision: set number of significant digits (default: 5).
|
||||
* Indent: indentation of the output: none, space, tab (default: space).</_param>
|
||||
|
|
|
|||
26
scour.py
26
scour.py
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Scour
|
||||
#
|
||||
# Copyright 2009 Jeff Schiller
|
||||
# Copyright 2010 Jeff Schiller
|
||||
#
|
||||
# This file is part of Scour, http://www.codedread.com/scour/
|
||||
#
|
||||
|
|
@ -73,7 +73,7 @@ except ImportError:
|
|||
|
||||
APP = 'scour'
|
||||
VER = '0.23'
|
||||
COPYRIGHT = 'Copyright Jeff Schiller, 2009'
|
||||
COPYRIGHT = 'Copyright Jeff Schiller, 2010'
|
||||
|
||||
NS = { 'SVG': 'http://www.w3.org/2000/svg',
|
||||
'XLINK': 'http://www.w3.org/1999/xlink',
|
||||
|
|
@ -510,19 +510,17 @@ def removeUnusedDefs(doc, defElem, elemsToRemove=None):
|
|||
|
||||
keepTags = ['font', 'style', 'metadata', 'script', 'title', 'desc']
|
||||
for elem in defElem.childNodes:
|
||||
# we only inspect the children of a group in a defs if the group
|
||||
# is not referenced anywhere else
|
||||
if elem.nodeName == 'g' and elem.namespaceURI == NS['SVG'] and \
|
||||
not elem.getAttribute('id') in referencedIDs:
|
||||
elemsToRemove = removeUnusedDefs(doc, elem, elemsToRemove)
|
||||
continue
|
||||
|
||||
# we only remove if it is an element with a blank id and it is
|
||||
# a direct child of the defs
|
||||
# only look at it if an element and not referenced anywhere else
|
||||
if elem.nodeType == 1 and (elem.getAttribute('id') == '' or \
|
||||
(not elem.getAttribute('id') in referencedIDs)) and \
|
||||
not elem.nodeName in keepTags:
|
||||
elemsToRemove.append(elem)
|
||||
(not elem.getAttribute('id') in referencedIDs)):
|
||||
|
||||
# we only inspect the children of a group in a defs if the group
|
||||
# is not referenced anywhere else
|
||||
if elem.nodeName == 'g' and elem.namespaceURI == NS['SVG']:
|
||||
elemsToRemove = removeUnusedDefs(doc, elem, elemsToRemove)
|
||||
# we only remove if it is not one of our tags we always keep (see above)
|
||||
elif not elem.nodeName in keepTags:
|
||||
elemsToRemove.append(elem)
|
||||
return elemsToRemove
|
||||
|
||||
def removeUnreferencedElements(doc):
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Test Harness for Scour
|
||||
#
|
||||
# Copyright 2009 Jeff Schiller
|
||||
# Copyright 2010 Jeff Schiller
|
||||
#
|
||||
# This file is part of Scour, http://www.codedread.com/scour/
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue