ipy_table icon indicating copy to clipboard operation
ipy_table copied to clipboard

make a row or cell a hyperlink?

Open clancychilds opened this issue 8 years ago • 1 comments

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.

clancychilds avatar Oct 09 '17 11:10 clancychilds

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!

epmoyer avatar Oct 09 '17 16:10 epmoyer