Open psychemedia opened 4 years ago
This framework for creating new templates could be handy?
https://github.com/timkpaine/nbcx
UPDATE: from a recent tweet, it looks like this may be about to be deprecated.
Also, changes moving to nbconvert 6: https://blog.jupyter.org/the-templating-system-of-nbconvert-6-47ea781eacd2
If we tag cells, the
nbconvert
docs describe a way for customising templates that can add additional style based on the cell tags.For example:
And then run with:
example = !jupyter nbconvert --to html 'example.ipynb' --template=mytemplate.tpl --stdout
In the
jupyter_contrib_nbextensions
package, template files are in thejupyter_contrib_nbextensions/templates/
directory.We can define in an init.py file something like:
As an example, in
jupyter_contrib_nbextensions
, thetoc2
exporter has a template filetoc2.tpl
in thetemplates
directory. Exporters are defined in anbconvert_support
directory according the form:and imported via the
__init__.py
in the same directory as that file using egfrom .toc2 import TocExporter
.The package
setup.py
then has an entry point defined as:which supports the CLI call:
jupyter nbconvert --to html_toc FILE.ipynb
Ah.. docs for writing a custom exporter.