mkdocs-jupyter
mkdocs-jupyter copied to clipboard
Images not getting exported to the correct location
Greetings - trying to get my images to show up in my mkdocs rendered pages. I saw https://github.com/danielfrg/mkdocs-jupyter/issues/53
And I did a little research. It looks like nbconvert has the ability to encode the image as part of the build process https://nbconvert.readthedocs.io/en/latest/config_options.html#exporter-options
HTMLExporter.embed_images : Bool
Default: False
Whether or not to embed images as base64 in markdown cells.
Perhaps we could expose this flag as a setting for the plugin?
The other option would be to add something in https://github.com/danielfrg/mkdocs-jupyter/blob/main/src/mkdocs_jupyter/nbconvert2.py that:
- Looks for image links in the notebook
- If present, grab the image and put it in the same directory where index.html will get written
- Rewrite the paths in the html to point to the new location
This solution would have the benefit of clearly organizing which images go with which notebook.
The HTMLExporter option seems like the easiest and least intrusive.
Yeah i think we should just support the nbconvert options. Are you able to make a quick PR? should be easy to test.
Hhhhmmmm, don't really have much knowledge about mkdocs plugins or nbconvert. Here is me thinking through it a bit with some questions at the end
So it seems like we would add the options to the mkdocs.yaml under the plugin part for this plugin.
My first guess is that this is a dict with entries like {HTMLExporter.attribute: value,} Probably should be the same in the mkdocs.yaml as well.
I see some of the plugin options from mkdocs.yaml are passed into the constructor for nb2html https://github.com/danielfrg/mkdocs-jupyter/blob/303343f063ac8be739657d10dae326011a173e59/src/mkdocs_jupyter/nbconvert2.py#L38
So we we would have a init parameter called HTMLExporter_options
But when I look at all the options, some of those are things that we handle explicitly as a separate init parameter.
For example:
HTMLExporter.exclude_input : Bool
Default: False
This allows you to exclude code cell inputs from all templates if set to True.
Seems to correspond to this parameter
https://github.com/danielfrg/mkdocs-jupyter/blob/303343f063ac8be739657d10dae326011a173e59/src/mkdocs_jupyter/nbconvert2.py#L46
Questions:
- Does the dict idea make the most sense
- Is this the line where the mkdocs.yaml configuration is passed to the HTMLExporter? https://github.com/danielfrg/mkdocs-jupyter/blob/303343f063ac8be739657d10dae326011a173e59/src/mkdocs_jupyter/nbconvert2.py#L119
- Where in that file would I actually write the code to do this?
Hey @danielfrg any updates on this?
Ping