ipython-contrib / jupyter_contrib_nbextensions

A collection of various notebook extensions for Jupyter
http://jupyter-contrib-nbextensions.readthedocs.io/en/latest
Other
5.24k stars 807 forks source link

Applying `python-markdown` rewrites in Exported HTML #1156

Open psychemedia opened 7 years ago

psychemedia commented 7 years ago

If I download as HTML a notebook containing python-markdown rendered variables in markdown cells, the {{..}} source appears in the HTML rather than the substituted content, presumably because the converter is converting the .ipynb JSON directly to HTML without execution.

If I use knitr to render an .Rmd document in RStudio, it executes the code throughout the document when generating the HTML.

I can render the HTML with rewrites from the commandline by executing the notebook as I convert it:

jupyter nbconvert --to html --execute mynotebook.ipynb

Would it make sense (or is there a way I've not seen for looking?!) to have a toolbar button or menu item (perhaps optionally, via a setting) that allows the user to generate the executed version of the HTML from the notebook UI?

tilusnet commented 6 years ago

Is anybody working on these bugs? see my comment below

tilusnet commented 6 years ago

After some more investigation I realise that for the export to work there's some additional configuration needed.

tilusnet commented 6 years ago

I got it to work from the command line only. E.g. by invoking jupyter nbconvert --to html --execute Untitled.ipynb. However the GUI export doesn't work still.

juhasch commented 6 years ago

Unfortunately, this is a little complicated, due to the different configuration options, as well as limitations of the notebook. Currently you cannot provide configuration options from the GUI to the export functionality .

What you can do is put options for nbconvert (being called from within the notebook) in your jupyter_notebook_config.py file:

c.Exporter.preprocessors = ['jupyter_contrib_nbextensions.nbconvert_support.PyMarkdownPreprocessor']
tilusnet commented 6 years ago

Thanks @juhasch, I was actually looking at the alternative with the jupyter config file; I actually didn't configure the notebook config. This now works!