Python Markdown代码未在输出中编译

时间:2018-09-21 20:07:26

标签: jupyter-notebook python-markdown

在Jupyter笔记本中,我正在使用Python-Markdown库在Jupyter Notebook降价模块中编译代码。 markdown块中的Python代码块(即大括号{{}}中的代码)可以在笔记本中编译并正常工作。但是,当我将笔记本作为HTML文件下载时,代码块无法编译,结果文本只是原始的Python代码。

在转换过程中似乎缺少一个步骤。也就是说,转换过程无法识别它需要先转换为markdown的Python代码,然后再转换为HTML。

有人知道什么处理文件可能丢失吗?这是安装错误吗?

1 个答案:

答案 0 :(得分:0)

需要启用pre_pymarkdown.PyMarkdownPreprocessor。此问题的解决方案在这里给出:

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

总结,当您使用nbconvert时,您需要一个配置文件:

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 }

使用导出菜单时,需要将以上内容添加到jupyter_notebook_config.json