From: Vladimír Vondruš Date: Thu, 8 Oct 2020 14:27:21 +0000 (+0200) Subject: m.plots: update the regex hell for matplotlib 3.3. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=de86049b87f8dc12c022406c201abb533bc78f68;p=blog.git m.plots: update the regex hell for matplotlib 3.3. --- diff --git a/documentation/test_python/page_plugins/plots.html b/documentation/test_python/page_plugins/plots.html index f60ed497..c1f9746c 100644 --- a/documentation/test_python/page_plugins/plots.html +++ b/documentation/test_python/page_plugins/plots.html @@ -27,9 +27,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + diff --git a/plugins/m/plots.py b/plugins/m/plots.py index 83429905..df8fea46 100644 --- a/plugins/m/plots.py +++ b/plugins/m/plots.py @@ -72,14 +72,25 @@ style_mapping = { } # Patch to remove preamble and hardcoded sizes. Matplotlib 2.2 has a http URL -# while matplotlib 3 has a https URL, check for both. +# while matplotlib 3 has a https URL, check for both. Matplotlib 3.3 has a new +# field (which we're not interested in) and slightly different +# formatting of the global style after (which we unify to the compact version). _patch_src = re.compile(r"""<\?xml version="1\.0" encoding="utf-8" standalone="no"\?> -viewBox="0 0 \d+ \d+(\.\d+)?") width="\d+(\.\d+)?pt" xmlns="http://www\.w3\.org/2000/svg" xmlns:xlink="http://www\.w3\.org/1999/xlink"> -""") +viewBox="0 0 \d+ \d+(\.\d+)?") width="\d+(\.\d+)?pt" xmlns="http://www\.w3\.org/2000/svg" xmlns:xlink="http://www\.w3\.org/1999/xlink">( + .+)? + + + +""", re.DOTALL) _patch_dst = r"""> + + + """ # Remove needless newlines and trailing space in path data @@ -98,14 +109,21 @@ _class_mapping = [ # , everything is defined in , no need to repeat ('
- + @@ -163,9 +161,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + @@ -341,9 +337,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + @@ -516,9 +510,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + diff --git a/plugins/m/test/plots/page-30.html b/plugins/m/test/plots/page-30.html index 6939e60d..2d6674ed 100644 --- a/plugins/m/test/plots/page-30.html +++ b/plugins/m/test/plots/page-30.html @@ -30,9 +30,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + @@ -163,9 +161,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + @@ -341,9 +337,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + @@ -516,9 +510,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + diff --git a/plugins/m/test/plots/page-py35.html b/plugins/m/test/plots/page-py35.html index 3fa7caf9..0d64be21 100644 --- a/plugins/m/test/plots/page-py35.html +++ b/plugins/m/test/plots/page-py35.html @@ -30,9 +30,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + @@ -165,9 +163,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + @@ -344,9 +340,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + @@ -519,9 +513,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + diff --git a/plugins/m/test/plots/page.html b/plugins/m/test/plots/page.html index 4ece1575..836e2966 100644 --- a/plugins/m/test/plots/page.html +++ b/plugins/m/test/plots/page.html @@ -30,9 +30,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + @@ -165,9 +163,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + @@ -344,9 +340,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- + @@ -519,9 +513,7 @@ div.m-plot svg { font-family: DejaVu Sans; }
- +