How to export with codefolding in jupyter?

Viewed 374

I want to export jupyter notebook to html, with the codefolding extension enabled.

I've tried to follow the official docs

I've tried the following lines in ~/.jupyter/jupyter_nbconvert_config.py

# # not working, tried one line at a time
# Exporter.preprocessors += ['jupyter_contrib_nbextensions.nbconvert_support.CodeFoldingPreprocessor']
# Exporter.preprocessors += ['jupyter_contrib_nbextensions.nbconvert_support.pre_codefolding']
# c.Exporter.preprocessors.append('jupyter_contrib_nbextensions.nbconvert_support.pre_codefolding')

# working for cmd line, eg:
# jupyter nbconvert --to html my_nb.ipynbc.Exporter.preprocessors.append('jupyter_contrib_nbextensions.nbconvert_support.CodeFoldingPreprocessor')
c.Exporter.preprocessors += ['jupyter_contrib_nbextensions.nbconvert_support.CodeFoldingPreprocessor']
c.CodeFoldingPreprocessor.remove_folded_code=True

None of the above works in jupyter notebook File -> Download as -> HTML (.html)

However, jupyter nbconvert --to html my_nb.ipynb in command line does work.

Q: How can I make this work in jupyter notebook?

FYI, I'm running:

  • jupyter_client 5.1.0
  • jupyter_core 4.3.0
  • Python 3.6.2
0 Answers
Related