diff --git a/scour.inkscape.py b/scour.inkscape.py
index 9e87757..f21e223 100755
--- a/scour.inkscape.py
+++ b/scour.inkscape.py
@@ -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()
diff --git a/scour.inx b/scour.inx
index d5cddee..ee310c5 100644
--- a/scour.inx
+++ b/scour.inx
@@ -13,6 +13,7 @@
false
true
false
+ false
false
5
@@ -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).
diff --git a/scour.py b/scour.py
index 6841b1b..700a034 100755
--- a/scour.py
+++ b/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):
diff --git a/testscour.py b/testscour.py
index edf459f..b618e1f 100755
--- a/testscour.py
+++ b/testscour.py
@@ -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/
#