From: Vladimír Vondruš Date: Sun, 14 Jul 2019 21:45:03 +0000 (+0200) Subject: m.math, documentation: update math support for dvisvgm 2.6.3. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=3594c845adb66901fed674216f494545ba230b0a;p=blog.git m.math, documentation: update math support for dvisvgm 2.6.3. It reorders all XML attributes for no reason. Ugh I hate this. --- diff --git a/documentation/test_doxygen/contents_custom/math.html b/documentation/test_doxygen/contents_custom/math.html index 36fa4983..c2d00d11 100644 --- a/documentation/test_doxygen/contents_custom/math.html +++ b/documentation/test_doxygen/contents_custom/math.html @@ -27,22 +27,22 @@ \[ \pi^2 \] - - + + - - + +

A yellow $ \Sigma $ - + - + inline formula.

diff --git a/documentation/test_doxygen/contents_math/index.html b/documentation/test_doxygen/contents_math/index.html index c00823f3..e4e4c0fa 100644 --- a/documentation/test_doxygen/contents_math/index.html +++ b/documentation/test_doxygen/contents_math/index.html @@ -27,131 +27,131 @@ \[ \hat q = [\boldsymbol 0, 1] + \epsilon [\frac{\boldsymbol v}{2}, 0] \] - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + +

And $ \hat q $ - - + + - - + + is how quaternion is denoted.

\[ a^2 + b^2 = c^2 \] - - - - - - + + + + + + - - - - - - - - + + + + + + + +

$c^2$ - - + + - - + + should be part of a new paragraph, not stuck out of it. The following formula has a custom environment:

\begin{eqnarray*} g &=& \frac{Gm_2}{r^2} \\ &=& 9.82066032\,\mbox{m/s}^2 \end{eqnarray*} - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/documentation/test_doxygen/contents_math_cached/math.html b/documentation/test_doxygen/contents_math_cached/math.html index 5eec8825..26b4db20 100644 --- a/documentation/test_doxygen/contents_math_cached/math.html +++ b/documentation/test_doxygen/contents_math_cached/math.html @@ -27,37 +27,37 @@ $ \pi $ - - + + - - - + + + here. Then a block formula which is a Pythagorean theorem in source but not in the output:

\[ a^2 + b^2 = c^2 \] - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + +
diff --git a/documentation/test_doxygen/test_contents.py b/documentation/test_doxygen/test_contents.py index e5f857d7..1b1ff18c 100644 --- a/documentation/test_doxygen/test_contents.py +++ b/documentation/test_doxygen/test_contents.py @@ -151,45 +151,45 @@ class MathCached(IntegrationTestCase): def __init__(self, *args, **kwargs): super().__init__(__file__, 'math_cached', *args, **kwargs) - # Actually generated from $ \frac{\tau}{2} $ tho + # Actually generated from $ \frac{\tau}{2} $ tho self.tau_half_hash = sha1("""$ \pi $""".encode('utf-8')).digest() self.tau_half = """ - - + + - - + + - - - + + + """ # Actually generated from \[ a^3 + b^3 \neq c^3 \] tho self.fermat_hash = sha1("""\[ a^2 + b^2 = c^2 \]""".encode('utf-8')).digest() self.fermat = """ - - + + - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + + """ diff --git a/plugins/latex2svgextra.py b/plugins/latex2svgextra.py index 2434e016..df707181 100644 --- a/plugins/latex2svgextra.py +++ b/plugins/latex2svgextra.py @@ -89,6 +89,14 @@ _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. +_patch26_src = re.compile(r"""<\?xml version='1\.0' encoding='UTF-8'\?> + + +""") + # version ignored by all UAs, safe to drop https://stackoverflow.com/a/18468348 _patch_dst = r""" @@ -176,7 +184,11 @@ def patch(formula, svg, depth, attribs): viewBox=match.group('viewBox'), attribs=attribs, formula=html.escape(formula)) - svg = _patch_src.sub(repl, svg) + # 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 # Make element IDs unique global counter diff --git a/plugins/m/test/math/page.html b/plugins/m/test/math/page.html index b93fc724..0a91a683 100644 --- a/plugins/m/test/math/page.html +++ b/plugins/m/test/math/page.html @@ -28,12 +28,12 @@ a^2 - - + + - - + + and colored math block:

@@ -42,22 +42,22 @@ a^2 a^2 + b^2 = c^2 - - - - - - + + + + + + - - - - - - - - + + + + + + + +

Colored parts of inline @@ -65,21 +65,21 @@ a^2 + b^2 = c^2 b^2 - \color{m-info}{4ac} - - - - - - + + + + + + - - - + + + - - - + + + and block formulas:

@@ -89,28 +89,28 @@ b^2 - \color{m-info}{4ac} \frac{-b \pm \color{m-success} \sqrt{D}}{2a} - - - - - - - + + + + + + + - - - + + + - + - + - + - - - + + +

Properly align huge formulas vertically on a line: @@ -119,32 +119,32 @@ b^2 - \color{m-info}{4ac} \hat q^{-1} = \frac{\hat q^*}{|\hat q|^2} - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + and make sure there's enough space for all the complex @@ -152,10 +152,10 @@ and make sure there's enough space for all the complex - + - + things between the lines @@ -163,30 +163,30 @@ the lines @@ -194,54 +194,54 @@ W = \sum_{i=0}^{n} \frac{w_i}{h_i} Y = \sum_{i=0}^{n} B - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + +

-

The \cfrac thing doesn't align well: +

The \cfrac thing doesn't align well: W = \sum_{i=0}^{n} \cfrac{w_i}{h_i} - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + +

Properly escape the formula source:

@@ -253,14 +253,14 @@ W = \sum_{i=0}^{n} \cfrac{w_i}{h_i} \end{array} - - - + + + - - - + + +

Formulas @@ -268,12 +268,12 @@ W = \sum_{i=0}^{n} \cfrac{w_i}{h_i} a^2 - - + + - - + + in big text are big.

Formulas @@ -281,12 +281,12 @@ a^2 a^2 - - + + - - + + in small text are small.

@@ -295,22 +295,22 @@ a^2 a^2 + b^2 = c^2 - - - - - - + + + + + + - - - - - - - - + + + + + + + +
This is a title.

This is a description.

@@ -321,22 +321,22 @@ a^2 + b^2 = c^2 a^2 + b^2 = c^2 - - - - - - + + + + + + - - - - - - - - + + + + + + + +

The math below should not be styled as a part of the figure:

@@ -345,22 +345,22 @@ a^2 + b^2 = c^2 a^2 + b^2 = c^2 - - - - - - + + + + + + - - - - - - - - + + + + + + + +
diff --git a/plugins/m/test/math_cached/page.html b/plugins/m/test/math_cached/page.html index 01c875ae..9755bc6a 100644 --- a/plugins/m/test/math_cached/page.html +++ b/plugins/m/test/math_cached/page.html @@ -29,13 +29,13 @@ formula which is pi in the source but - - + + - - + + - - - + + + """ # Actually generated from $$a^3 + b^3 \neq c^3$$ tho fermat_hash = sha1("""$$a^2 + b^2 = c^2$$""".encode('utf-8')).digest() fermat = """ - - + + - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + + """