Python Markdown 代码未在输出中编译

Python Markdown Code not Compiling in Output

在 Jupyter Notebook 中,我使用 Python-Markdown 库在 Jupyter Notebook markdown 块中编译代码。 markdown 块中的 Python 代码块,即大括号 {{}} 内的代码,编译并在笔记本中运行良好。但是,当我将笔记本下载为 HTML 文件时,代码块无法编译,生成的文本只是原始 Python 代码。

转换过程中好像少了一个步骤。也就是说,转换过程没有意识到在转换为 HTML.

之前需要先编译 markdown 中的 Python 代码

有谁知道可能丢失了哪些处理文件?这是安装错误吗?

需要启用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