Compress and filter SVGs before saving
This commit is contained in:
parent
bbdaebfcb0
commit
fa3cfce34a
2 changed files with 7 additions and 1 deletions
|
@ -8,6 +8,8 @@ import hashlib
|
|||
from functools import partial
|
||||
from mkdocs.utils import write_file
|
||||
import os
|
||||
from py_svg_hush import filter_svg
|
||||
from scour.scour import scourString
|
||||
|
||||
logger = get_plugin_logger("kroki")
|
||||
|
||||
|
@ -16,7 +18,9 @@ DIAGRAM_CACHE_TIME = timedelta(days=7)
|
|||
def get_kroki_diagram(source, language):
|
||||
encoded_diagram = base64.urlsafe_b64encode(zlib.compress(source.encode(), 9)).decode()
|
||||
|
||||
return download_and_cache_url(f"https://kroki.io/{language}/svg/{encoded_diagram}", DIAGRAM_CACHE_TIME)
|
||||
svg = download_and_cache_url(f"https://kroki.io/{language}/svg/{encoded_diagram}", DIAGRAM_CACHE_TIME)
|
||||
|
||||
return scourString(filter_svg(svg)).encode()
|
||||
|
||||
|
||||
def fence_div_format(site_dir, source, language, *args, attrs, **kwargs):
|
||||
|
|
|
@ -4,3 +4,5 @@ pymdown-extensions
|
|||
pygments
|
||||
minify-html
|
||||
beautifulsoup4
|
||||
py-svg-hush
|
||||
scour
|
||||
|
|
Loading…
Reference in a new issue