Fix whitespace collapsing when it shouldn't on non-textual elements that have xml:space=preserve
This commit is contained in:
parent
6482314390
commit
99dfb0f819
4 changed files with 17 additions and 3 deletions
|
|
@ -16,6 +16,7 @@
|
|||
<p>TBD</p>
|
||||
<ul>
|
||||
<li>Fix <a href="https://bugs.launchpad.net/scour/+bug/449803">Bug 449803</a> by ensuring input and output filenames differ.</li>
|
||||
<li>Fix <a href="https://bugs.launchpad.net/scour/+bug/453737">Bug 453737</a> by updated Inkscape's scour extension with a UI</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
|
|
|||
3
scour.py
3
scour.py
|
|
@ -2098,8 +2098,7 @@ def serializeXML(element, options, ind = 0, preserveWhitespace = False):
|
|||
elif child.nodeType == 3:
|
||||
# trim it only in the case of not being a child of an element
|
||||
# where whitespace might be important
|
||||
if element.nodeName in ["text", "tspan", "textPath", "tref", "title", "desc", "textArea",
|
||||
"flowRoot", "flowDiv", "flowSpan", "flowPara", "flowRegion"]:
|
||||
if preserveWhitespace:
|
||||
outString += makeWellFormed(child.nodeValue)
|
||||
else:
|
||||
outString += makeWellFormed(child.nodeValue.strip())
|
||||
|
|
|
|||
|
|
@ -949,7 +949,13 @@ class GetAttrPrefixRight(unittest.TestCase):
|
|||
def runTest(self):
|
||||
grad = scour.scourXmlFile('unittests/xml-namespace-attrs.svg').getElementsByTagNameNS(SVGNS, 'linearGradient')[1]
|
||||
self.assertEquals( grad.getAttributeNS('http://www.w3.org/1999/xlink', 'href'), '#linearGradient841',
|
||||
'Did not get xlink:href prefix right' )
|
||||
'Did not get xlink:href prefix right')
|
||||
|
||||
class EnsurePreserveWhitespaceOnNonTextElements(unittest.TestCase):
|
||||
def runTest(self):
|
||||
s = scour.scourString(open('unittests/no-collapse-lines.svg').read())
|
||||
self.assertEquals( s.count('\n'), 5,
|
||||
'Did not properly preserve whitespace on elements even if they were not textual')
|
||||
|
||||
# TODO; write a test for embedding rasters
|
||||
# TODO: write a test for --disable-embed-rasters
|
||||
|
|
|
|||
8
unittests/no-collapse-lines.svg
Normal file
8
unittests/no-collapse-lines.svg
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48"
|
||||
viewBox="0.1 -0.333 125 125" xml:space="preserve">
|
||||
<g id="Layer_1_2_">
|
||||
<path d="M24.599,16.542v27.584l-4.994-1.033L0,60.671l52.687,63.612l51.361-40.729l20.844-18.664c0,0-23.527-4.871-27.404-5.673
|
||||
c0-4.4,0-47.951,0-47.951L43.071,0L24.599,16.542z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 415 B |
Loading…
Add table
Add a link
Reference in a new issue