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

@ -502,7 +502,7 @@
},
{
"data": {
"image/svg+xml": [
"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",
@ -517,8 +517,8 @@
"<!-- 0 -->\n",
"<g id=\"node1\" class=\"node\">\n",
"<title>0</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"171\" cy=\"-557.48\" rx=\"50.09\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"171\" y=\"-553.78\" font-family=\"Times,serif\" font-size=\"14.00\">EConcat</text>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"170\" cy=\"-557.48\" rx=\"50.09\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"170\" y=\"-553.78\" font-family=\"Times,serif\" font-size=\"14.00\">EConcat</text>\n",
"</g>\n",
"<!-- 1 -->\n",
"<g id=\"node2\" class=\"node\">\n",
@ -529,9 +529,9 @@
"<!-- 0&#45;&gt;1 -->\n",
"<g id=\"edge11\" class=\"edge\">\n",
"<title>0&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M160.1,-539.89C154.54,-531.44 147.67,-520.97 141.48,-511.56\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"144.24,-509.39 135.82,-502.95 138.39,-513.23 144.24,-509.39\"/>\n",
"<text text-anchor=\"middle\" x=\"155.1\" y=\"-528.69\" font-family=\"Times,serif\" font-size=\"14.00\">L</text>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M159.34,-539.89C153.9,-531.44 147.17,-520.97 141.12,-511.56\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"143.94,-509.47 135.59,-502.95 138.05,-513.25 143.94,-509.47\"/>\n",
"<text text-anchor=\"middle\" x=\"154.34\" y=\"-528.69\" font-family=\"Times,serif\" font-size=\"14.00\">L</text>\n",
"</g>\n",
"<!-- 11 -->\n",
"<g id=\"node12\" class=\"node\">\n",
@ -542,9 +542,9 @@
"<!-- 0&#45;&gt;11 -->\n",
"<g id=\"edge16\" class=\"edge\">\n",
"<title>0&#45;&gt;11</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M175.09,-539.16C180.7,-515.09 190.88,-470.13 198,-431.48 207.22,-381.44 215.7,-322.68 220.33,-289.03\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"223.81,-289.41 221.69,-279.03 216.87,-288.47 223.81,-289.41\"/>\n",
"<text text-anchor=\"middle\" x=\"169.59\" y=\"-527.96\" font-family=\"Times,serif\" font-size=\"14.00\">R</text>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M174.06,-539.15C179.63,-515.07 189.76,-470.11 197,-431.48 206.38,-381.42 215.24,-322.67 220.12,-289.03\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"223.6,-289.42 221.56,-279.03 216.67,-288.43 223.6,-289.42\"/>\n",
"<text text-anchor=\"middle\" x=\"168.56\" y=\"-527.95\" font-family=\"Times,serif\" font-size=\"14.00\">R</text>\n",
"</g>\n",
"<!-- 2 -->\n",
"<g id=\"node3\" class=\"node\">\n",
@ -555,14 +555,14 @@
"<!-- 1&#45;&gt;2 -->\n",
"<g id=\"edge1\" class=\"edge\">\n",
"<title>1&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M98.53,-471.16C82.85,-462.01 63.81,-448.44 52,-431.48 28.52,-397.76 27,-383.57 27,-342.48 27,-342.48 27,-342.48 27,-178.74 27,-132.35 27,-78.38 27,-46.54\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M98.95,-471.04C83.52,-461.84 64.74,-448.27 53,-431.48 29.38,-397.71 27,-383.69 27,-342.48 27,-342.48 27,-342.48 27,-178.74 27,-132.35 27,-78.38 27,-46.54\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"30.5,-46.26 27,-36.26 23.5,-46.26 30.5,-46.26\"/>\n",
"<text text-anchor=\"middle\" x=\"93.53\" y=\"-459.96\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n",
"<text text-anchor=\"middle\" x=\"93.95\" y=\"-459.84\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n",
"</g>\n",
"<!-- 3 -->\n",
"<g id=\"node4\" class=\"node\">\n",
"<title>3</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"125\" cy=\"-413.48\" rx=\"63.89\" ry=\"18\"/>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"125\" cy=\"-413.48\" rx=\"63.09\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"125\" y=\"-409.78\" font-family=\"Times,serif\" font-size=\"14.00\">first_match</text>\n",
"</g>\n",
"<!-- 1&#45;&gt;3 -->\n",
@ -734,7 +734,7 @@
"outputs": [
{
"data": {
"image/svg+xml": [
"text/html": [
"\n",
"<svg height=\"210\" width=\"220\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
"<polygon points=\"20,0 200,120 200,210 20,210\" fill=\"cyan\" opacity=\".2\" />\n",
@ -1036,7 +1036,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@ -1050,7 +1050,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
"version": "3.11.7"
}
},
"nbformat": 4,