Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def html_format(source, language, css_class, options, md):
function = reduce(getattr, [lq, *source.split(".")])
fig = plot(function)
tmp = StringIO()
fig.savefig(tmp, format="svg", bbox_inches="tight", pad_inches=0)
return scour.scourString(tmp.getvalue().replace("DejaVu Sans", "sans-serif"))
process = subprocess.run(command, capture_output=True)
if not process.stderr:
available_optimizers.append('svgo')
output = process.stdout.decode("ascii").split()
if __name__ == '__main__':
print("Found 'svgo' version", output[0])
# Check if we have scour
try:
from scour import scour
except ImportError:
pass
else:
available_optimizers.append('scour')
if __name__ == '__main__':
print("Found 'scour' version", scour.__version__)
return available_optimizers
def optimize_with_scour(files):
from scour import scour
"""
Optimize SVG files using Scour.
"""
# Configure scour
options = scour.parse_args()
options.digits = 4
# values lower than 4 for '.digits' led to visilble differences between
# the original and 'optimized' file
options.indent_depth = 2
options.simple_colors = False
options.enable_viewboxing = True
options.embed_rasters = True
options.group_create = True
options.group_collapse = True
options.shorten_ids = True
options.strip_comments = True
options.strip_ids = True
options.strip_xml_prolog = True
options.strip_xml_space_attribute = True
options.remove_titles = True