How to capture IPython.display.display(html_object) in a panel pane?

I was playing with GitHub - robert-haas/gravis: Interactive graph visualizations with Python and HTML/CSS/JS..
It works nicely, but I would like to capture the output in panel.

The relevant code is in gravis/gravis/_internal/plotting/ at master · robert-haas/gravis · GitHub

def display(self, inline=False):
        if inline:
            import IPython

            html_text = self.to_html_partial()
            html_object = IPython.display.HTML(html_text)
            html_text = self.to_html_standalone()

anybody know how I would need to modify this?

# small examplt to produce a figure
import gravis as gv
import networkx as nx
G = nx.les_miserables_graph()
fig = gv.vis(G)
# fig.display()

Would you be able to just replace IPython.display.HTML(html_text) with pn.pane.HTML?

That was the first thing I tried. It gave me an empty pane :frowning:

This might be due to issues with creating and closing Matplotlib figures; see FAQ — Panel v1.3.8 (“why do I get no plot”). Not sure how to address it in this case, if so.

actually, gravis has 3 display functions, e.g., using D3.js

import IPython
fig = gv.d3(G)
html_text = '<div style="width:50%;height:1000px;">' +fig.to_html_partial()+"</div>"
#pn.pane.HTML( html_text )

displaying the div with IPython.display.HTML works, using pn.pane.HTML does not.