From: Carlos Brito Date: Fri, 3 Dec 2021 10:19:48 +0000 (+0100) Subject: latex2svgextra: adapt to minor changes in dvisvgm 2.12 preamble. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=f05937f57f17656772aff0315677c15447d05f4d;p=blog.git latex2svgextra: adapt to minor changes in dvisvgm 2.12 preamble. And add an actually useful assert message. Co-authored-by: Vladimír Vondruš --- diff --git a/plugins/latex2svgextra.py b/plugins/latex2svgextra.py index 6593c035..1a84b258 100644 --- a/plugins/latex2svgextra.py +++ b/plugins/latex2svgextra.py @@ -93,8 +93,10 @@ _patch_src = re.compile(r"""<\?xml version='1\.0'( encoding='UTF-8')?\?> # dvisvgm 2.6 has a different order of attributes. According to the changelog, # the SVGs can be now hashed, which hopefully means that the output won't # change every second day again. Hopefully. +# +# dvisvgm 2.12 does not necessarily specify the patch version number. _patch26_src = re.compile(r"""<\?xml version='1\.0' encoding='UTF-8'\?> - + """) @@ -185,11 +187,12 @@ def patch(formula, svg, depth, attribs): viewBox=match.group('viewBox'), attribs=attribs, formula=html.escape(formula)) + # There are two incompatible preambles, if the first fails try the second svg, found = _patch_src.subn(repl, svg) if not found: svg, found = _patch26_src.subn(repl, svg) - assert found + assert found, "dvisgm preamble is incompatible with this version of m.css" # Make element IDs unique global counter