Python Markdown Code not Compiling in Output

1k views Asked by At

In the Jupyter Notebook I am using the Python-Markdown library to compile code in the Jupyter Notebook markdown blocks. The Python code chunks in the markdown block, that is the code within the curly brackets {{}}, compiles and works fine in the notebook. However, when I download the notebook as an HTML file, the code chunk does not compile and the resulting text is simply the raw Python code.

It seems like a step is missing in the conversion process. That is, the convert process is not recognizing that it needs to first compile the Python code in the markdown before converting to HTML.

Does anyone know what processing files could be missing? Is this an installation error?

1

There are 1 answers

0
dwjbosman On BEST ANSWER

The pre_pymarkdown.PyMarkdownPreprocessor needs to be enabled. A solution to this problem is given here:

https://github.com/ipython-contrib/jupyter_contrib_nbextensions/issues/585

Summarized when you use nbconvert you need a config file:

jupyter_nbconvert_config.json:

{ "Exporter": { "preprocessors": [ "pre_codefolding.CodeFoldingPreprocessor", "pre_pymarkdown.PyMarkdownPreprocessor" ], "template_path": [ ".", "/Users/rfenner/Library/Jupyter/templates" ] }, "NbConvertApp": { "postprocessor_class": "post_embedhtml.EmbedPostProcessor" }, "version": 1 }

When you use the export menu then you need to add the above to jupyter_notebook_config.json