How to extract bokeh figure without coding inside ipynb


Im currently trying to save all figures from notebooks without opening them into lab/hub in order to get a “thumbnail” of my notebooks.

For matplotlib figure, it is pretty straight forward :
i use :

rst_exporter = RSTExporter() # 
(_, resources) = rst_exporter.from_notebook_node(myNb)

But for holoview/bokeh, it is a bit more tricky
i tried to use HTMLExporter with selecting the figure cell. But then nothing appears in the html file
So i also included the cell with the holoview import like this :

 html_exporter_with_figs = HTMLExporter()

 nb ="ExempleBokeh.ipynb", as_version=4)
 (s, resources_with_fig) = html_exporter_with_figs.from_notebook_node(nb)
 with open("test2.html","w") as file:

it is working, i got my holoview figure correctly displayed. But i also got all the cell decoration, code … etc … like a classic notebook. By hand, i can remove all the “div” i dont want, but i think there is a better solution.

What i would like is ONLY the figure :
Is there example somewhere of preprocessor or postprocessor to “convert” into html div only the output ?

was not easy to find but options in Exporter did the trick :

c = Config()
c.HTMLExporter.exclude_input_prompt =True
c.HTMLExporter.exclude_output_prompt =True
c.HTMLExporter.exclude_input =True
# create the new exporter using the custom config
html_exporter_with_figs = HTMLExporter(config = c)

1 Like