From: Vladimír Vondruš Date: Wed, 19 Sep 2018 11:04:06 +0000 (+0200) Subject: math: update tests for dvisvgm > 2.2.2. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=f67485628317077d3c83bf292ea94dabca697504;p=blog.git math: update tests for dvisvgm > 2.2.2. This is not a welcome change, unfortunately. It only bloats the output. --- diff --git a/doxygen/test/contents_custom/math.html b/doxygen/test/contents_custom/math.html index 49b9c541..224f8fb9 100644 --- a/doxygen/test/contents_custom/math.html +++ b/doxygen/test/contents_custom/math.html @@ -22,24 +22,24 @@

Math

-

A green formula:

+

A green formula:

\[ \pi^2 \] - - + + - - + + -

A yellow +

A yellow $ \Sigma $ - + diff --git a/doxygen/test/contents_math/index.html b/doxygen/test/contents_math/index.html index f7cc6df0..49f733c8 100644 --- a/doxygen/test/contents_math/index.html +++ b/doxygen/test/contents_math/index.html @@ -22,136 +22,136 @@

My Project

-

Here's a block formula:

+

Here's a block formula:

\[ \hat q = [\boldsymbol 0, 1] + \epsilon [\frac{\boldsymbol v}{2}, 0] \] - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + -

And +

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

+ 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:

+ 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/doxygen/test/contents_math_cached/math.html b/doxygen/test/contents_math_cached/math.html index d1a28679..7c7b6168 100644 --- a/doxygen/test/contents_math_cached/math.html +++ b/doxygen/test/contents_math_cached/math.html @@ -22,42 +22,42 @@

Math

-

In order to actually test use of the cache, I need to cheat a bit. Inline formula which is pi in the source but +

In order to actually test use of the cache, I need to cheat a bit. Inline formula which is pi in the source but $ \pi $ - - + + - - - + + + - here. Then a block formula which is a Pythagorean theorem in source but not in the output:

+ 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/doxygen/test/test_contents.py b/doxygen/test/test_contents.py index 6b93c0b2..3e1d8433 100644 --- a/doxygen/test/test_contents.py +++ b/doxygen/test/test_contents.py @@ -124,49 +124,49 @@ class MathCached(IntegrationTestCase): # 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 = """ - - + + - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + + """ # This is using the cache, so doesn't matter if LaTeX is found or not def test(self): math_cache = (0, 5, { - self.tau_half_hash: (5, 0.3448408333333333, self.tau_half), + self.tau_half_hash: (5, 0.344841, self.tau_half), self.fermat_hash: (5, 0.0, self.fermat), b'does not exist': (5, 0.0, 'something')}) with open(os.path.join(self.path, 'xml/math.cache'), 'wb') as f: @@ -180,7 +180,7 @@ class MathCached(IntegrationTestCase): with open(os.path.join(self.path, 'xml/math.cache'), 'rb') as f: math_cache_actual = pickle.load(f) math_cache_expected = (0, 6, { - self.tau_half_hash: (6, 0.3448408333333333, self.tau_half), + self.tau_half_hash: (6, 0.344841, self.tau_half), self.fermat_hash: (6, 0.0, self.fermat)}) self.assertEqual(math_cache_actual, math_cache_expected) @@ -207,7 +207,7 @@ class MathCached(IntegrationTestCase): math_cache_actual = pickle.load(f) math_cache_expected = (0, 0, { sha1("$ \\frac{\\tau}{2} $".encode('utf-8')).digest(): - (0, 0.3448408333333333, self.tau_half), + (0, 0.344841, self.tau_half), sha1("\\[ a^3 + b^3 \\neq c^3 \\]".encode('utf-8')).digest(): (0, 0.0, self.fermat)}) self.assertEqual(math_cache_actual, math_cache_expected) diff --git a/pelican-plugins/latex2svgextra.py b/pelican-plugins/latex2svgextra.py index a71a2a03..adcf4509 100644 --- a/pelican-plugins/latex2svgextra.py +++ b/pelican-plugins/latex2svgextra.py @@ -53,7 +53,15 @@ params.update({ \definecolor{m-info}{HTML}{cafe08} \definecolor{m-dim}{HTML}{cafe09} """, - # Zoom the letters a bit to match page font size + # Zoom the letters a bit to match page font size. + # TODO dvisvgm 2.2.2 was changed to "avoid scientific notation of floating + # point numbers" (https://github.com/mgieseki/dvisvgm/blob/3facb925bfe3ab47bf40d376d567a114b2bee3a5/NEWS#L90), + # meaning the default precision (6) is now used for the decimal points, so + # you'll often get numbers like 194.283203, which is a bit too much + # precision. Could be enough to have 4 decimal points max, but that would + # be too little for <2.2.2, where it would mean you get just 194.28. We + # need to detect the version somehow and then apply reasonable precision + # based on that. 'dvisvgm_cmd': 'dvisvgm --no-fonts -Z 1.25', }) diff --git a/pelican-plugins/m/test/math/page.html b/pelican-plugins/m/test/math/page.html index cc983702..41f2b3c2 100644 --- a/pelican-plugins/m/test/math/page.html +++ b/pelican-plugins/m/test/math/page.html @@ -23,270 +23,270 @@

m.math

-

Inline colored math +

Inline colored math a^2 - - + + - + and colored math block:

- + a^2 + b^2 = c^2 - - - - - - + + + + + + - - - - - - - - + + + + + + + +
-

Colored parts of inline +

Colored parts of inline b^2 - \color{m-info}{4ac} - - - - - - + + + + + + - - + + - - - + + + and block formulas:

- + \frac{-b \pm \color{m-success} \sqrt{D}}{2a} - - - - - - - + + + + + + + - - - + + + - + - + - + - - - + + +

Properly align huge formulas vertically on a line: - + \hat q^{-1} = \frac{\hat q^*}{|\hat q|^2} - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + -and make sure there's enough space for all the complex +and make sure there's enough space for all the complex W - + things between -the lines +the lines W = \sum_{i=0}^{n} \frac{w_i}{h_i} - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + because - + 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:

- + \begin{array}{rcl} x & = & 1 \end{array} - - - + + + - - - + + +
-

Formulas +

Formulas a^2 - - + + - + in big text are big.

-

Formulas +

Formulas a^2 - - + + - + in small text are small.

@@ -296,4 +296,4 @@ a^2 - \ No newline at end of file + diff --git a/pelican-plugins/m/test/math_cached/page.html b/pelican-plugins/m/test/math_cached/page.html index 5c438ab5..803b3f70 100644 --- a/pelican-plugins/m/test/math_cached/page.html +++ b/pelican-plugins/m/test/math_cached/page.html @@ -24,45 +24,45 @@

Math

In order to actually test use of the cache, I need to cheat a bit. Inline -formula which is pi in the source but +formula which is pi in the source but \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/pelican-plugins/m/test/test_math.py b/pelican-plugins/m/test/test_math.py index ba4130a9..272d35af 100644 --- a/pelican-plugins/m/test/test_math.py +++ b/pelican-plugins/m/test/test_math.py @@ -65,47 +65,47 @@ class Math(PluginTestCase): # Actually generated from $\frac{\tau}{2}$ tho tau_half_hash = sha1("""$\pi$""".encode('utf-8')).digest() tau_half = """ - - + + - - + + - - - + + + """ # 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 = """ - - + + - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + + """ -class MathCached(PluginTestCase): +class Cached(PluginTestCase): def __init__(self, *args, **kwargs): super().__init__(__file__, 'cached', *args, **kwargs) @@ -114,7 +114,7 @@ class MathCached(PluginTestCase): cache_file = os.path.join(self.path, 'math.cache') math_cache = (0, 5, { - tau_half_hash: (5, 0.3448408333333333, tau_half), + tau_half_hash: (5, 0.344841, tau_half), fermat_hash: (5, 0.0, fermat), b'does not exist': (5, 0.0, 'something')}) with open(cache_file, 'wb') as f: @@ -132,11 +132,11 @@ class MathCached(PluginTestCase): with open(cache_file, 'rb') as f: math_cache_actual = pickle.load(f) math_cache_expected = (0, 6, { - tau_half_hash: (6, 0.3448408333333333, tau_half), + tau_half_hash: (6, 0.344841, tau_half), fermat_hash: (6, 0.0, fermat)}) self.assertEqual(math_cache_actual, math_cache_expected) -class MathUncached(PluginTestCase): +class Uncached(PluginTestCase): def __init__(self, *args, **kwargs): super().__init__(__file__, 'uncached', *args, **kwargs) @@ -168,7 +168,7 @@ class MathUncached(PluginTestCase): math_cache_actual = pickle.load(f) math_cache_expected = (0, 0, { sha1("$\\frac{\\tau}{2}$".encode('utf-8')).digest(): - (0, 0.3448408333333333, tau_half), + (0, 0.344841, tau_half), sha1("$$a^3 + b^3 \\neq c^3$$".encode('utf-8')).digest(): (0, 0.0, fermat)}) self.assertEqual(math_cache_actual, math_cache_expected)