将笔记本导出为docx文件的jupyter bundler扩展名
jupyter-docx-bundler的Python项目详细描述
Jupyter Docx捆绑器扩展
将笔记本导出为docx文件的jupyter bundler扩展名
安装
使用pip
安装确保已安装Pandoc,有关说明,请参见installing-pandoc。
pip install jupyter-docx-bundler
jupyter bundlerextension enable --py jupyter_docx_bundler --sys-prefix
使用conda
安装conda install -c mrossi jupyter-docx-bundler
用法
添加元数据
bundle扩展使用笔记本的元数据(如果您提供的话)。
"title": "Notebook title"
"authors": [{"name": "author1"}, {"name": "author2"}]
"subtitle": "Notebook subtitle"
"date": "Notebook date"
可以在edit->;edit notebook metadata下编辑笔记本元数据。
隐藏输入或完整的代码单元
通过定义单元格标记,可以隐藏单个代码单元格或仅隐藏其输入:
nbconvert-remove-cell
:删除整个单元格nbconvert-remove-input
:删除单元格的输入代码
(目前没有为这些标记配置默认值,上面列出的值是在我的代码中定义的,而不是在nbconvert中。这在未来可能会改变。)
可以通过激活view->;cell toolbar->;tags下的单元格工具栏来显示单元格标记。
从控制台直接呼叫(nbconvert)
要从控制台直接使用捆绑器,nbconvert实用程序可以与目标格式docx一起使用:
jupyter nbconvert --execute --to=docx <source notebook>.ipynb --output <target document>.docx
应该使用--execute
选项来确保在生成之前运行笔记本。
开发
测试
用pytest测试包。克隆存储库并安装需求,例如conda:
conda install --file requirements.txt --file requirements_test.txt
用
pytest .
建筑
要用conda-build构建包,需要调用
conda-build conda.recipe