Merge 03025e7fc2 into 0609c59676
This commit is contained in:
commit
d6d0c29aff
1 changed files with 17 additions and 1 deletions
|
|
@ -2766,6 +2766,17 @@ def clean_path(element, options, stats):
|
||||||
stats.num_bytes_saved_in_path_data += (len(oldPathStr) - len(newPathStr))
|
stats.num_bytes_saved_in_path_data += (len(oldPathStr) - len(newPathStr))
|
||||||
element.setAttribute('d', newPathStr)
|
element.setAttribute('d', newPathStr)
|
||||||
|
|
||||||
|
def clean_animated_path(element, options, stats):
|
||||||
|
"""
|
||||||
|
Cleans (precision only) the path strings (values that will replace a path's d attribute) of the animation element
|
||||||
|
These are ';' delimited path data that must keep the same number of nodes, so the only cleaning is via serializePath
|
||||||
|
"""
|
||||||
|
oldPathStr = element.getAttribute('values')
|
||||||
|
if oldPathStr=="":
|
||||||
|
return
|
||||||
|
oldPathStrs = oldPathStr.split(';')
|
||||||
|
newPathStr = ";".join(map(lambda s:serializePath(svg_parser.parse(s),options),oldPathStrs)
|
||||||
|
element.setAttribute('values', newPathStr)
|
||||||
|
|
||||||
def parseListOfPoints(s):
|
def parseListOfPoints(s):
|
||||||
"""
|
"""
|
||||||
|
|
@ -3804,6 +3815,11 @@ def scourString(in_string, options=None, stats=None):
|
||||||
else:
|
else:
|
||||||
clean_path(elem, options, stats)
|
clean_path(elem, options, stats)
|
||||||
|
|
||||||
|
# clean path based animation data
|
||||||
|
for elem in doc.documentElement.getElementsByTagName('animate'):
|
||||||
|
if elem.getAttribute('attributeName') == 'd':
|
||||||
|
clean_animated_path(elem, options, stats)
|
||||||
|
|
||||||
# shorten ID names as much as possible
|
# shorten ID names as much as possible
|
||||||
if options.shorten_ids:
|
if options.shorten_ids:
|
||||||
stats.num_bytes_saved_in_ids += shortenIDs(doc, options.shorten_ids_prefix, options)
|
stats.num_bytes_saved_in_ids += shortenIDs(doc, options.shorten_ids_prefix, options)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue