Merge 5bcaaa4fdb into 0609c59676
This commit is contained in:
commit
30e5ad5629
3 changed files with 14 additions and 2 deletions
|
|
@ -3390,7 +3390,9 @@ def properlySizeDoc(docElement, options):
|
|||
# else we have a statically sized image and we should try to remedy that
|
||||
|
||||
# parse viewBox attribute
|
||||
vbSep = RE_COMMA_WSP.split(docElement.getAttribute('viewBox'))
|
||||
viewBox = docElement.getAttribute('viewBox')
|
||||
lengths = RE_COMMA_WSP.split(viewBox)
|
||||
vbSep = [length for length in lengths if length.strip()]
|
||||
# if we have a valid viewBox we need to check it
|
||||
if len(vbSep) == 4:
|
||||
try:
|
||||
|
|
@ -3819,7 +3821,7 @@ def scourString(in_string, options=None, stats=None):
|
|||
viewBox = doc.documentElement.getAttribute('viewBox')
|
||||
if viewBox:
|
||||
lengths = RE_COMMA_WSP.split(viewBox)
|
||||
lengths = [scourUnitlessLength(length) for length in lengths]
|
||||
lengths = [scourUnitlessLength(length) for length in lengths if length.strip()]
|
||||
doc.documentElement.setAttribute('viewBox', ' '.join(lengths))
|
||||
|
||||
# more length scouring in this function
|
||||
|
|
|
|||
|
|
@ -2786,6 +2786,13 @@ class ViewBox(unittest.TestCase):
|
|||
self.assertEqual(width, '', "width not removed with '--enable-viewboxing'.")
|
||||
self.assertEqual(height, '', "height not removed with '--enable-viewboxing'.")
|
||||
|
||||
def test_viewbox_remove_width_and_height_ws(self):
|
||||
doc = scourXmlFile('unittests/viewbox-remove-ws.svg', parse_args(['--enable-viewboxing']))
|
||||
width = doc.documentElement.getAttribute('width')
|
||||
height = doc.documentElement.getAttribute('height')
|
||||
self.assertEqual(width, '', "width not removed with '--enable-viewboxing'.")
|
||||
self.assertEqual(height, '', "height not removed with '--enable-viewboxing'.")
|
||||
|
||||
|
||||
# TODO: write tests for --keep-editor-data
|
||||
|
||||
|
|
|
|||
3
unittests/viewbox-remove-ws.svg
Normal file
3
unittests/viewbox-remove-ws.svg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="123.456" height="654.321" viewBox=" 0 0 123.456 654.321 ">
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 152 B |
Loading…
Add table
Add a link
Reference in a new issue