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

make a row or cell a hyperlink? #23

Open
clancychilds opened this issue Oct 9, 2017 · 1 comment
Open

make a row or cell a hyperlink? #23

clancychilds opened this issue Oct 9, 2017 · 1 comment

Comments

@clancychilds
Copy link

Is it possible to make a cell or a row a hyperlink to another URL? I tried using IPython.display.HTML() but to no effect.

@epmoyer
Copy link
Owner

epmoyer commented Oct 9, 2017

Hi Clancy!

Here is a workaround that you can use for now. It is possible to insert an html anchor tag into cell text, with the caveat that you must set wrap=True for that cell. The reason is because when wrap=False (which is the default) ipy_table converts all spaces in the cell to non-breaking spaces (" "), which causes the space in the anchor tag (specifically, the one between "<a" and "href=") to get replaced by " ", which causes browsers to choke on it.

Below is a working example, showing the behavior before and after setting wrap=True on the cell containing the hyperlink.

I will give some thought to a cleaner way to handle html tags which appear in cell content, but in the meantime maybe this is enough to get you going.

anchor_tags

Here's the code for make_anchor:

def make_anchor(link, text):
    return '<a href="' + link + '">' + text + '</a>'

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants