Thanks to Thomas K pushing I had some success to get this to work. Think, this is a proto-answer until I have the opportunity to get around all the nuances of the problem. There will probably be mistakes, but this is my understanding of what is happening.
To override the default behavior of ipython nbconvert --to html mynotebook.ipynb you need to specify the configuration file and call it like this: ipython nbconvert --config mycfg.py . Where mycfg.py is a file in the same directory as your laptops. My looks like this:
c = get_config() c.NbConvertApp.notebooks = ["mynotebook.ipynb"] c.NbConvertApp.export_format = 'html' c.Exporter.preprocessors = ['extractoutput.ExtractOutputPreprocessor']
Where ["mynotebook.ipynb"] is the file or list of files that I want to convert. In this case, the part that controls the conversion of the laptop is 'extractoutput.ExtractOutputPreprocessor' .
extractoutput .ExtractOutputPreprocessor refers to extractoutput.py , which is also in the same directory as notebooks (although I don't think it should be).
extractoutput .ExtractOutputPreprocessor refers to a function in extractoutput.py that indicates how the output will be processed.
In my case, the contents of this file are taken exactly from the IPython repo with a slight modification. Line 22 ( from .base import Preprocessor ) creates
ValueError: Attempted relative import in non-package
an error because he does not know where to look for a package. When changing to
from IPython.nbconvert.preprocessors .base import Preprocessor
then it works, and all image objects are placed in the mynotebook_files directory.
I did not need to edit the HTML output template in this case, he knew where to look anyway.
Ben
source share