chiark / gitweb /
latex2svgextra: adapt to minor changes in dvisvgm 2.12 preamble.
authorCarlos Brito <carlos.brito524@gmail.com>
Fri, 3 Dec 2021 10:19:48 +0000 (11:19 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 10 Jan 2022 12:28:03 +0000 (13:28 +0100)
And add an actually useful assert message.

Co-authored-by: Vladimír Vondruš <mosra@centrum.cz>
plugins/latex2svgextra.py

index 6593c035dc71b75017136d9c4f70b6dc5c93322a..1a84b258ca1607af2703de33ef1cfabd9abe0ec6 100644 (file)
@@ -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'\?>
-<!-- This file was generated by dvisvgm \d+\.\d+\.\d+ -->
+<!-- This file was generated by dvisvgm \d+\.\d+(\.\d+)? -->
 <svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='(?P<width>[^']+)pt' height='(?P<height>[^']+)pt' viewBox='(?P<viewBox>[^']+)'>
 """)
 
@@ -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