diff --git a/scour.py b/scour.py
index 60d0311..94088fd 100755
--- a/scour.py
+++ b/scour.py
@@ -34,7 +34,6 @@
# at rounded corners)
# Next Up:
-# - Bug 511186: option to keep XML comments between prolog and root element
# - only remove unreferenced elements if they are not children of a referenced element
# - add an option to remove ids if they match the Inkscape-style of IDs
# - investigate point-reducing algorithms
@@ -1355,7 +1354,7 @@ def cleanPath(element) :
else:
# we have a move and then 1 or more coords for lines
N = len(path[0][1])
- if path[0] == 'M':
+ if path[0][0] == 'M':
# take the last pair of coordinates for the starting point
x = path[0][1][N-2]
y = path[0][1][N-1]
@@ -1624,13 +1623,14 @@ def cleanPath(element) :
for (cmd,data) in path[1:]:
# flush the previous command if it is not the same type as the current command
if prevCmd != '':
- if cmd != prevCmd:
+ if cmd != prevCmd or cmd == 'm':
newPath.append( (prevCmd, prevData) )
prevCmd = ''
prevData = []
# if the previous and current commands are the same type, collapse
- if cmd == prevCmd:
+ # but only if they are not move commands (since move can contain implicit lineto commands)
+ if cmd == prevCmd and cmd != 'm':
for coord in data:
prevData.append(coord)
@@ -1757,13 +1757,13 @@ def cleanPath(element) :
for (cmd,data) in path[1:]:
# flush the previous command if it is not the same type as the current command
if prevCmd != '':
- if cmd != prevCmd:
+ if cmd != prevCmd or cmd == 'm':
newPath.append( (prevCmd, prevData) )
prevCmd = ''
prevData = []
# if the previous and current commands are the same type, collapse
- if cmd == prevCmd:
+ if cmd == prevCmd and cmd != 'm':
for coord in data:
prevData.append(coord)
@@ -2480,5 +2480,3 @@ if __name__ == '__main__':
sizediff = (newsize / oldsize) * 100
print >>sys.stderr, ' Original file size:', oldsize, 'bytes;', \
'new file size:', newsize, 'bytes (' + str(sizediff)[:5] + '%)'
-
-
diff --git a/testscour.py b/testscour.py
index a1a1105..c2f8969 100755
--- a/testscour.py
+++ b/testscour.py
@@ -1019,6 +1019,12 @@ class DoNotStripDoctype(unittest.TestCase):
self.assertEquals( doc.childNodes[1].nodeType, 10, 'Second node not a doctype')
self.assertEquals( doc.childNodes[2].nodeType, 1, 'Third node not the root node')
+class PathImplicitLineWithMoveCommands(unittest.TestCase):
+ def runTest(self):
+ path = scour.scourXmlFile('unittests/path-implicit-line.svg').getElementsByTagNameNS(SVGNS, 'path')[0]
+ self.assertEquals( path.getAttribute('d'), "M100,100,100,200m200-100-200,0m200,100,0-100",
+ "Implicit line segments after move not preserved")
+
# TODO: write tests for --enable-viewboxing
# TODO; write a test for embedding rasters
# TODO: write a test for --disable-embed-rasters
diff --git a/unittests/path-implicit-line.svg b/unittests/path-implicit-line.svg
new file mode 100644
index 0000000..ecbbe9a
--- /dev/null
+++ b/unittests/path-implicit-line.svg
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file