Optimise SVG compression
Actually strip out some tags and newlines
This commit is contained in:
parent
4d36f4f1e3
commit
61f0bd2a43
1 changed files with 12 additions and 1 deletions
|
@ -21,12 +21,23 @@ DIAGRAM_TYPES = {
|
|||
|
||||
DIAGRAM_CACHE_TIME = timedelta(days=7)
|
||||
|
||||
|
||||
class ScourOptions:
|
||||
"""
|
||||
Scour takes its options as a class with attributes, because reasons
|
||||
"""
|
||||
remove_descriptions = True
|
||||
remove_metadata = True
|
||||
strip_comments = True
|
||||
newlines = False
|
||||
|
||||
|
||||
def get_kroki_diagram(source, language):
|
||||
encoded_diagram = base64.urlsafe_b64encode(zlib.compress(source.encode(), 9)).decode()
|
||||
|
||||
svg = download_and_cache_url(f"https://kroki.io/{language}/svg/{encoded_diagram}", DIAGRAM_CACHE_TIME)
|
||||
|
||||
return scourString(filter_svg(svg)).encode()
|
||||
return scourString(filter_svg(svg), ScourOptions).encode()
|
||||
|
||||
|
||||
def fence_div_format(site_dir, source, language, *args, attrs, **kwargs):
|
||||
|
|
Loading…
Reference in a new issue