How to embed HTML into IPython output?

Is it possible to embed rendered HTML output into IPython output?

One way is to use

from IPython.core.display import HTML
HTML('<a href="http://example.com">link</a>')

or (IPython multiline cell alias)

%%html
<a href="http://example.com">link</a>

Which return a formatted link, but

  1. This link doesn’t open a browser with the webpage itself from the console. IPython notebooks support honest rendering, though.
  2. I’m unaware of how to render HTML() object within, say, a list or pandas printed table. You can do df.to_html(), but without making links inside cells.
  3. This output isn’t interactive in the PyCharm Python console (because it’s not QT).

How can I overcome these shortcomings and make IPython output a bit more interactive?

6 Answers
6

Leave a Comment