Skip to content
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

Skip processing svg anchor elements #5610

Merged
merged 1 commit into from Nov 11, 2018
Merged

Skip processing svg anchor elements #5610

merged 1 commit into from Nov 11, 2018

Conversation

@saulshanabrook
Copy link
Member

@saulshanabrook saulshanabrook commented Nov 11, 2018

EDIT: Also fixes #5610

Fixes #5589 by skipping
processing of a elements that are not HTMLAnchorElements, including
those within SVG elements. Currently, if you have a a element
inside an SVG element it will break HTML rendering since that element
does not have a href like other a elements do.

Screenshots

Before, this code (from issue #5589) will end up raising an exception while rendering and so will display no output:

from IPython.display import display, SVG

class A:
    def __init__(self):
        print("init A")
        
    def _repr_html_(self):
        return """
<svg height="44pt" viewBox="0.00 0.00 62.00 44.00" width="62pt">
<g class="graph" id="graph0" transform="scale(1 1) rotate(0) translate(4 40)">
<g class="node" id="node1">
<title>a</title>
<g id="a_node1"><a xlink:title="(0) a">
<ellipse cx="27" cy="-18" fill="#444444" rx="27" ry="18" stroke="#000000"/>
<text fill="#ffffff" font-family="Times,serif" font-size="14.00" text-anchor="middle" x="27" y="-14.3">A</text>
</a>
</g>
</g>
</g>
</svg>
"""
    
a=A()
a

screen shot 2018-11-11 at 10 25 34 am

After, this exception will not be raised since we skip processing the a elements in the svg element and so it will render correctly, as it does in Jupyter Notebook

screen shot 2018-11-11 at 10 25 09 am

Fixes #5589 by skipping
processing of a elements that are not `HTMLAnchorElement`s, including
those within SVG elements. Currently, if you have a `a` element
inside an SVG element it will break HTML rendering since that element
does not have a `href` like other `a` elements do.
@blink1073
Copy link
Member

@blink1073 blink1073 commented Nov 11, 2018

Thanks!

@blink1073 blink1073 merged commit 0f509a1 into master Nov 11, 2018
3 of 4 checks passed
@vidartf vidartf deleted the fix-svg-in-html branch Nov 27, 2018
@jasongrout jasongrout added this to the 1.0 milestone Feb 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants