From f05937f57f17656772aff0315677c15447d05f4d Mon Sep 17 00:00:00 2001 From: Carlos Brito Date: Fri, 3 Dec 2021 11:19:48 +0100 Subject: [PATCH] latex2svgextra: adapt to minor changes in dvisvgm 2.12 preamble. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit And add an actually useful assert message. Co-authored-by: Vladimír Vondruš --- plugins/latex2svgextra.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 -- 2.30.2