python: render <svg> via _repr_html_

Work around a recent decision in Jupyter Lab and Notebook to render
<svg> is inline <img>, breaking tooltips or text selection.

(Rerendering all notebooks was painful.)

* NEWS: Mention the change.
* python/spot/__init__.py: Add a _repr_html_ method to all
classes that had a _repr_svg_.  It seems Jupyter will use
_repr_html_ by default.
* python/spot/jupyter.py: SVG replace the _repr_svg_ method
by a _repr_html.
* tests/python/_altscc.ipynb, tests/python/_autparserr.ipynb,
tests/python/_aux.ipynb, tests/python/_mealy.ipynb,
tests/python/_partitioned_relabel.ipynb,
tests/python/_product_susp.ipynb, tests/python/_product_weak.ipynb,
tests/python/_synthesis.ipynb, tests/python/aliases.ipynb,
tests/python/alternation.ipynb, tests/python/atva16-fig2a.ipynb,
tests/python/atva16-fig2b.ipynb, tests/python/automata-io.ipynb,
tests/python/automata.ipynb, tests/python/cav22-figs.ipynb,
tests/python/contains.ipynb, tests/python/decompose.ipynb,
tests/python/formulas.ipynb, tests/python/games.ipynb,
tests/python/gen.ipynb, tests/python/highlighting.ipynb,
tests/python/ltsmin-dve.ipynb, tests/python/ltsmin-pml.ipynb,
tests/python/parity.ipynb, tests/python/product.ipynb,
tests/python/randaut.ipynb, tests/python/satmin.ipynb,
tests/python/stutter-inv.ipynb, tests/python/synthesis.ipynb,
tests/python/testingaut.ipynb, tests/python/twagraph-internals.ipynb,
tests/python/word.ipynb, tests/python/zlktree.ipynb: Update all
notebooks.
This commit is contained in:
Alexandre Duret-Lutz 2024-02-09 15:06:07 +01:00
parent 4cf7503fff
commit 3034e8fcc3
36 changed files with 43249 additions and 8585 deletions

View file

@ -3340,7 +3340,7 @@
"<text text-anchor=\"start\" x=\"232.75\" y=\"-116.48\" font-family=\"Lato\" font-size=\"14.00\">) | Fin(</text>\n",
"<text text-anchor=\"start\" x=\"270.75\" y=\"-116.48\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"286.75\" y=\"-116.48\" font-family=\"Lato\" font-size=\"14.00\">)</text>\n",
"<text text-anchor=\"start\" x=\"211.75\" y=\"-102.48\" font-family=\"Lato\" font-size=\"14.00\">[Streett 1]</text>\n",
"<text text-anchor=\"start\" x=\"211.25\" y=\"-102.48\" font-family=\"Lato\" font-size=\"14.00\">[Streett 1]</text>\n",
"<!-- I -->\n",
"<!-- 0 -->\n",
"<g id=\"node2\" class=\"node\">\n",
@ -4105,7 +4105,7 @@
"<text text-anchor=\"start\" x=\"230.5\" y=\"-149.8\" font-family=\"Lato\" font-size=\"14.00\">) | Fin(</text>\n",
"<text text-anchor=\"start\" x=\"268.5\" y=\"-149.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"284.5\" y=\"-149.8\" font-family=\"Lato\" font-size=\"14.00\">)</text>\n",
"<text text-anchor=\"start\" x=\"209.5\" y=\"-135.8\" font-family=\"Lato\" font-size=\"14.00\">[Streett 1]</text>\n",
"<text text-anchor=\"start\" x=\"209\" y=\"-135.8\" font-family=\"Lato\" font-size=\"14.00\">[Streett 1]</text>\n",
"<!-- I -->\n",
"<!-- 0 -->\n",
"<g id=\"node2\" class=\"node\">\n",
@ -4832,8 +4832,124 @@
"</g>\n",
"</svg>\n"
],
"text/html": [
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
"<!-- Generated by graphviz version 2.43.0 (0)\n",
" -->\n",
"<!-- Pages: 1 -->\n",
"<svg width=\"490pt\" height=\"169pt\"\n",
" viewBox=\"0.00 0.00 490.00 169.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1.0 1.0) rotate(0) translate(4 165)\">\n",
"<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-165 486,-165 486,4 -4,4\"/>\n",
"<text text-anchor=\"start\" x=\"126.5\" y=\"-146.8\" font-family=\"Lato\" font-size=\"14.00\">Fin(</text>\n",
"<text text-anchor=\"start\" x=\"149.5\" y=\"-146.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#6a3d9a\">❸</text>\n",
"<text text-anchor=\"start\" x=\"165.5\" y=\"-146.8\" font-family=\"Lato\" font-size=\"14.00\">) &amp; (Inf(</text>\n",
"<text text-anchor=\"start\" x=\"211.5\" y=\"-146.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff7f00\">❷</text>\n",
"<text text-anchor=\"start\" x=\"227.5\" y=\"-146.8\" font-family=\"Lato\" font-size=\"14.00\">) | (Fin(</text>\n",
"<text text-anchor=\"start\" x=\"269.5\" y=\"-146.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"<text text-anchor=\"start\" x=\"285.5\" y=\"-146.8\" font-family=\"Lato\" font-size=\"14.00\">) &amp; Inf(</text>\n",
"<text text-anchor=\"start\" x=\"327.5\" y=\"-146.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"343.5\" y=\"-146.8\" font-family=\"Lato\" font-size=\"14.00\">)))</text>\n",
"<text text-anchor=\"start\" x=\"182.5\" y=\"-132.8\" font-family=\"Lato\" font-size=\"14.00\">[parity max even 4]</text>\n",
"<!-- I -->\n",
"<!-- 0 -->\n",
"<g id=\"node2\" class=\"node\">\n",
"<title>0</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"56\" cy=\"-50\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"56\" y=\"-46.3\" font-family=\"Lato\" font-size=\"14.00\">0</text>\n",
"</g>\n",
"<!-- I&#45;&gt;0 -->\n",
"<g id=\"edge1\" class=\"edge\">\n",
"<title>I&#45;&gt;0</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M1.15,-50C2.79,-50 17.15,-50 30.63,-50\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"37.94,-50 30.94,-53.15 34.44,-50 30.94,-50 30.94,-50 30.94,-50 34.44,-50 30.94,-46.85 37.94,-50 37.94,-50\"/>\n",
"</g>\n",
"<!-- 2 -->\n",
"<g id=\"node3\" class=\"node\">\n",
"<title>2</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"335\" cy=\"-51\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"335\" y=\"-47.3\" font-family=\"Lato\" font-size=\"14.00\">2</text>\n",
"</g>\n",
"<!-- 0&#45;&gt;2 -->\n",
"<g id=\"edge2\" class=\"edge\">\n",
"<title>0&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M69.99,-61.47C76.33,-66.68 84.24,-72.63 92,-77 123.14,-94.54 131.87,-99.44 167,-106 225.87,-116.98 246.74,-108.24 299,-79 304.66,-75.83 310.35,-71.76 315.44,-67.7\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"321.11,-63.01 317.73,-69.9 318.42,-65.24 315.72,-67.47 315.72,-67.47 315.72,-67.47 318.42,-65.24 313.71,-65.05 321.11,-63.01 321.11,-63.01\"/>\n",
"<text text-anchor=\"start\" x=\"167\" y=\"-113.8\" font-family=\"Lato\" font-size=\"14.00\">!p0 &amp; !p1</text>\n",
"</g>\n",
"<!-- 3 -->\n",
"<g id=\"node4\" class=\"node\">\n",
"<title>3</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"195.5\" cy=\"-31\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"195.5\" y=\"-27.3\" font-family=\"Lato\" font-size=\"14.00\">3</text>\n",
"</g>\n",
"<!-- 0&#45;&gt;3 -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>0&#45;&gt;3</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M73.9,-53.85C92.57,-57.43 123.38,-61.34 149,-55 157.5,-52.9 166.15,-48.89 173.61,-44.74\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"180.07,-40.94 175.63,-47.2 177.05,-42.71 174.04,-44.49 174.04,-44.49 174.04,-44.49 177.05,-42.71 172.44,-41.77 180.07,-40.94 180.07,-40.94\"/>\n",
"<text text-anchor=\"start\" x=\"92\" y=\"-61.8\" font-family=\"Lato\" font-size=\"14.00\">!p0 &amp; !p1</text>\n",
"</g>\n",
"<!-- 1 -->\n",
"<g id=\"node5\" class=\"node\">\n",
"<title>1</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"464\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"464\" y=\"-14.3\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
"</g>\n",
"<!-- 2&#45;&gt;1 -->\n",
"<g id=\"edge6\" class=\"edge\">\n",
"<title>2&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M352.92,-49.14C371.61,-46.8 402.44,-42.07 428,-34 432.35,-32.63 436.87,-30.85 441.15,-28.98\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"447.64,-26.01 442.59,-31.79 444.46,-27.47 441.28,-28.92 441.28,-28.92 441.28,-28.92 444.46,-27.47 439.97,-26.06 447.64,-26.01 447.64,-26.01\"/>\n",
"<text text-anchor=\"start\" x=\"373\" y=\"-49.8\" font-family=\"Lato\" font-size=\"14.00\">!p0 &amp; p1</text>\n",
"</g>\n",
"<!-- 3&#45;&gt;0 -->\n",
"<g id=\"edge8\" class=\"edge\">\n",
"<title>3&#45;&gt;0</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M178.34,-25.22C157.68,-18.77 121.1,-10.51 92,-21 85.46,-23.36 79.27,-27.53 73.97,-31.99\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"68.6,-36.86 71.67,-29.83 71.19,-34.51 73.78,-32.16 73.78,-32.16 73.78,-32.16 71.19,-34.51 75.9,-34.49 68.6,-36.86 68.6,-36.86\"/>\n",
"<text text-anchor=\"start\" x=\"94\" y=\"-39.8\" font-family=\"Lato\" font-size=\"14.00\">p0 &amp; !p1</text>\n",
"<text text-anchor=\"start\" x=\"112.5\" y=\"-24.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff7f00\">❷</text>\n",
"</g>\n",
"<!-- 3&#45;&gt;2 -->\n",
"<g id=\"edge7\" class=\"edge\">\n",
"<title>3&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M213.36,-33.45C237.59,-36.98 282.36,-43.49 310.02,-47.51\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"317,-48.53 309.62,-50.64 313.54,-48.02 310.07,-47.52 310.07,-47.52 310.07,-47.52 313.54,-48.02 310.53,-44.4 317,-48.53 317,-48.53\"/>\n",
"<text text-anchor=\"start\" x=\"242\" y=\"-63.8\" font-family=\"Lato\" font-size=\"14.00\">!p0 &amp; !p1</text>\n",
"<text text-anchor=\"start\" x=\"262.5\" y=\"-48.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#6a3d9a\">❸</text>\n",
"</g>\n",
"<!-- 3&#45;&gt;3 -->\n",
"<g id=\"edge9\" class=\"edge\">\n",
"<title>3&#45;&gt;3</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M183.58,-44.67C178.81,-55.66 182.78,-67 195.5,-67 205.44,-67 210.04,-60.08 209.3,-51.81\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"207.42,-44.67 212.25,-50.64 208.31,-48.05 209.2,-51.44 209.2,-51.44 209.2,-51.44 208.31,-48.05 206.15,-52.24 207.42,-44.67 207.42,-44.67\"/>\n",
"<text text-anchor=\"start\" x=\"169\" y=\"-85.8\" font-family=\"Lato\" font-size=\"14.00\">!p0 &amp; p1</text>\n",
"<text text-anchor=\"start\" x=\"187.5\" y=\"-70.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff7f00\">❷</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;0 -->\n",
"<g id=\"edge4\" class=\"edge\">\n",
"<title>1&#45;&gt;0</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M446.81,-12.43C440.96,-10.67 434.25,-8.94 428,-8 386.76,-1.81 239.1,-0.64 167,-4 133.56,-5.56 121.91,4.05 92,-11 83.75,-15.15 76.53,-22.15 70.83,-29.08\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"66.41,-34.82 68.19,-27.35 68.55,-32.05 70.68,-29.27 70.68,-29.27 70.68,-29.27 68.55,-32.05 73.18,-31.2 66.41,-34.82 66.41,-34.82\"/>\n",
"<text text-anchor=\"start\" x=\"244\" y=\"-19.8\" font-family=\"Lato\" font-size=\"14.00\">!p0 &amp; p1</text>\n",
"<text text-anchor=\"start\" x=\"254.5\" y=\"-5.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"270.5\" y=\"-5.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff7f00\">❷</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;2 -->\n",
"<g id=\"edge5\" class=\"edge\">\n",
"<title>1&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M446.03,-14.68C427.03,-11.74 395.67,-9.27 371,-19 363.88,-21.81 357.31,-26.8 351.84,-32.02\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"346.75,-37.24 349.38,-30.03 349.19,-34.73 351.63,-32.23 351.63,-32.23 351.63,-32.23 349.19,-34.73 353.89,-34.43 346.75,-37.24 346.75,-37.24\"/>\n",
"<text text-anchor=\"start\" x=\"371\" y=\"-22.8\" font-family=\"Lato\" font-size=\"14.00\">!p0 &amp; !p1</text>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f2c282eb960> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fc0d6bea0d0> >"
]
},
"metadata": {},
@ -5344,7 +5460,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.7"
"version": "3.11.7"
}
},
"nbformat": 4,