New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_repr_svg_ broken WRT classic notebook #6295
Comments
Because we use an image tag, rather than embedding the svg inline, you must include the xmlns attribute: from IPython.display import (
display_svg
)
class MyCircle(object):
def __init__(self, center=(0.0,0.0), radius=1.0, color='blue'):
self.center = center
self.radius = radius
self.color = color
def _repr_svg_(self):
return """<svg xmlns="http://www.w3.org/2000/svg" width="100px" height="100px">
<circle cx="50" cy="50" r="20" stroke="black" stroke-width="1" fill="blue"/>
</svg>"""
display_svg(MyCircle()) Should we try to modify the user code to add that, or should we rely on the user providing that? |
If it's not too error-prone, we should probably modify the svg data, otherwise there may be lots of notebooks from the past that won't render svg. We may be able to get away with just replacing an initial |
Setting to good first issue, since I think a workaround is straightforward, as noted in the last comment above. The code to be modified is at jupyterlab/packages/rendermime/src/renderers.ts Lines 404 to 430 in 8c72b12
|
If we don't add this workaround, It would be great to have a warning printed. At least we should update all the tutorial material; examples, and reach to libraries to actually include the |
I suspect using something like |
I am SO torn here: on the one hand, I love being able to do things with the actual SVG DOM (like tweaking style from generated things). On the other, generated SVG has a nasty habit of including @ian-r-rose the issue with trying to parse first, namespace later, is that an |
Quick fix: Replace |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related discussion. |
The
_repr_svg_
rendering seem to be incorrect:Works in classic notebook (taken from ipython-in-depth tutorial)
Both in latest alpha and 0.35.
The text was updated successfully, but these errors were encountered: