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

@ -154,8 +154,115 @@
"</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=\"196pt\" height=\"355pt\"\n",
" viewBox=\"0.00 0.00 196.00 355.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 351)\">\n",
"<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-351 192,-351 192,4 -4,4\"/>\n",
"<text text-anchor=\"start\" x=\"48.5\" y=\"-332.8\" font-family=\"Lato\" font-size=\"14.00\">Inf(</text>\n",
"<text text-anchor=\"start\" x=\"69.5\" y=\"-332.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"85.5\" y=\"-332.8\" font-family=\"Lato\" font-size=\"14.00\">)&amp;Inf(</text>\n",
"<text text-anchor=\"start\" x=\"119.5\" y=\"-332.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"<text text-anchor=\"start\" x=\"135.5\" y=\"-332.8\" font-family=\"Lato\" font-size=\"14.00\">)</text>\n",
"<text text-anchor=\"start\" x=\"51.5\" y=\"-318.8\" font-family=\"Lato\" font-size=\"14.00\">[gen. Büchi 2]</text>\n",
"<!-- I -->\n",
"<!-- 0 -->\n",
"<g id=\"node2\" class=\"node\">\n",
"<title>0</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"56\" cy=\"-68\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"56\" y=\"-64.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,-68C2.79,-68 17.15,-68 30.63,-68\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"37.94,-68 30.94,-71.15 34.44,-68 30.94,-68 30.94,-68 30.94,-68 34.44,-68 30.94,-64.85 37.94,-68 37.94,-68\"/>\n",
"</g>\n",
"<!-- 0&#45;&gt;0 -->\n",
"<g id=\"edge2\" class=\"edge\">\n",
"<title>0&#45;&gt;0</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M49.62,-85.04C48.32,-94.86 50.45,-104 56,-104 60.17,-104 62.4,-98.86 62.71,-92.14\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"62.38,-85.04 65.85,-91.88 62.54,-88.53 62.71,-92.03 62.71,-92.03 62.71,-92.03 62.54,-88.53 59.56,-92.18 62.38,-85.04 62.38,-85.04\"/>\n",
"<text text-anchor=\"start\" x=\"51.5\" y=\"-107.8\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
"</g>\n",
"<!-- 1 -->\n",
"<g id=\"node3\" class=\"node\">\n",
"<title>1</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"168\" cy=\"-118\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"start\" x=\"163.5\" y=\"-114.3\" font-family=\"Lato\" font-size=\"14.00\">1</text>\n",
"</g>\n",
"<!-- 0&#45;&gt;1 -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>0&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M72.76,-75.16C91.63,-83.74 123.36,-98.16 144.72,-107.87\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"151.27,-110.85 143.59,-110.82 148.08,-109.4 144.9,-107.95 144.9,-107.95 144.9,-107.95 148.08,-109.4 146.2,-105.09 151.27,-110.85 151.27,-110.85\"/>\n",
"<text text-anchor=\"start\" x=\"99\" y=\"-104.8\" font-family=\"Lato\" font-size=\"14.00\">a | b</text>\n",
"</g>\n",
"<!-- 2 -->\n",
"<g id=\"node4\" class=\"node\">\n",
"<title>2</title>\n",
"<ellipse fill=\"#ffffaa\" stroke=\"black\" cx=\"168\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"168\" y=\"-14.3\" font-family=\"Lato\" font-size=\"14.00\">2</text>\n",
"</g>\n",
"<!-- 0&#45;&gt;2 -->\n",
"<g id=\"edge4\" class=\"edge\">\n",
"<title>0&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M72.76,-60.84C91.63,-52.26 123.36,-37.84 144.72,-28.13\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"151.27,-25.15 146.2,-30.91 148.08,-26.6 144.9,-28.05 144.9,-28.05 144.9,-28.05 148.08,-26.6 143.59,-25.18 151.27,-25.15 151.27,-25.15\"/>\n",
"<text text-anchor=\"start\" x=\"92\" y=\"-54.8\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; !b</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;1 -->\n",
"<g id=\"edge5\" class=\"edge\">\n",
"<title>1&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M165.47,-136.15C165.08,-145.54 165.92,-154 168,-154 169.53,-154 170.39,-149.44 170.58,-143.3\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"170.53,-136.15 173.73,-143.13 170.56,-139.65 170.58,-143.15 170.58,-143.15 170.58,-143.15 170.56,-139.65 167.43,-143.17 170.53,-136.15 170.53,-136.15\"/>\n",
"<text text-anchor=\"start\" x=\"148\" y=\"-157.8\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; !b</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;1 -->\n",
"<g id=\"edge6\" class=\"edge\">\n",
"<title>1&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M163.83,-135.7C161.52,-153 162.91,-172 168,-172 172.37,-172 174.01,-157.96 172.93,-143.04\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"172.17,-135.7 176.02,-142.34 172.53,-139.18 172.89,-142.66 172.89,-142.66 172.89,-142.66 172.53,-139.18 169.75,-142.98 172.17,-135.7 172.17,-135.7\"/>\n",
"<text text-anchor=\"start\" x=\"150\" y=\"-190.8\" font-family=\"Lato\" font-size=\"14.00\">a &amp; !b</text>\n",
"<text text-anchor=\"start\" x=\"160\" y=\"-175.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;1 -->\n",
"<g id=\"edge7\" class=\"edge\">\n",
"<title>1&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M163.05,-135.47C157.9,-163.15 159.55,-202 168,-202 175.76,-202 177.78,-169.26 174.08,-142.48\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"172.95,-135.47 177.17,-141.88 173.51,-138.92 174.06,-142.38 174.06,-142.38 174.06,-142.38 173.51,-138.92 170.95,-142.88 172.95,-135.47 172.95,-135.47\"/>\n",
"<text text-anchor=\"start\" x=\"150\" y=\"-220.8\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; b</text>\n",
"<text text-anchor=\"start\" x=\"160\" y=\"-205.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;1 -->\n",
"<g id=\"edge8\" class=\"edge\">\n",
"<title>1&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M162.52,-135.24C154.33,-171.92 156.16,-232 168,-232 179.1,-232 181.4,-179.2 174.9,-142.37\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"173.48,-135.24 177.93,-141.49 174.16,-138.67 174.85,-142.1 174.85,-142.1 174.85,-142.1 174.16,-138.67 171.76,-142.72 173.48,-135.24 173.48,-135.24\"/>\n",
"<text text-anchor=\"start\" x=\"152\" y=\"-249.8\" font-family=\"Lato\" font-size=\"14.00\">a &amp; b</text>\n",
"<text text-anchor=\"start\" x=\"152\" y=\"-235.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"168\" y=\"-235.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</text>\n",
"</g>\n",
"<!-- 2&#45;&gt;2 -->\n",
"<g id=\"edge9\" class=\"edge\">\n",
"<title>2&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M158.43,-33.54C155.73,-43.91 158.92,-54 168,-54 174.95,-54 178.45,-48.08 178.5,-40.66\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"177.57,-33.54 181.6,-40.08 178.03,-37.01 178.48,-40.48 178.48,-40.48 178.48,-40.48 178.03,-37.01 175.35,-40.89 177.57,-33.54 177.57,-33.54\"/>\n",
"<text text-anchor=\"start\" x=\"148\" y=\"-71.8\" font-family=\"Lato\" font-size=\"14.00\">!a &amp; !b</text>\n",
"<text text-anchor=\"start\" x=\"152\" y=\"-57.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#1f78b4\">⓿</text>\n",
"<text text-anchor=\"start\" x=\"168\" y=\"-57.8\" font-family=\"Lato\" font-size=\"14.00\" fill=\"#ff4da0\">❶</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 0x7f12cf944300> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fdd801ca760> >"
]
},
"execution_count": 3,
@ -224,7 +331,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@ -238,7 +345,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1+"
"version": "3.11.7"
}
},
"nbformat": 4,