diff --git a/hooks/kroki.py b/hooks/kroki.py index 39a2629..5cf1b15 100644 --- a/hooks/kroki.py +++ b/hooks/kroki.py @@ -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):