Import Jupyter Notebooks (IPYNB) as HTML with Embedded Images

156 views
Skip to first unread message

Miki

unread,
Apr 1, 2018, 6:42:11 PM4/1/18
to nikola-discuss
Hello,
I wonder if it would be possible to configure Nikola's importer for IPYNB to include all images as embedded (now only generated figures are embedded).

The reason I ask for this option:
- I have images with relative paths in the notebook, but after conversion by Nikola, the image paths are no longer valid in the generated HTML, because the output HTML is in different folder <slug>.
- So, the option to embed all images in the produced HTML could fix this issue.

There is an extension for Jupyter's nbconvert here
https://github.com/ipython-contrib/jupyter_contrib_nbextensions/tree/master/src/jupyter_contrib_nbextensions/nbextensions/export_embedded

which works fine and generates a single html with embedded images as follows: jupyter nbconvert --to html_embed notebook.ipynb

The question is how to use this nbconvert settings with Nikola? I know there is the IPYNB_CONFIG in the Nikola's settings, but have no idea if it can help in this case.

Thank you

Damián Avila

unread,
Dec 6, 2018, 10:11:48 AM12/6/18
to nikola-discuss
Hi,

I do not think there is an easy way to do this without changing the codebase. The html_embed is a 3rd party extension (it is not provided in nbconvert) so there is not a config setting that you could pass to the IPYNB_CONFIG to make it work. We are not using nbconvert as a CLI tool, we are using it as a library: https://github.com/getnikola/nikola/blob/master/nikola/plugins/compile/ipynb.py#L64

Thanks!

--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Damián Avila

Roberto Alsina

unread,
Dec 6, 2018, 10:40:57 AM12/6/18
to Nikola—Discuss
Wellllll it *is* possible to fix that in the HTML after it's generated. Not trivial, and would need to be implemented as a filter, and it will make the page painful to load.
Reply all
Reply to author
Forward
0 new messages