Jupyter Notebook导出时省略了Markdown。

huangapple go评论81阅读模式
英文:

jupyter notebook export omits markdown

问题

The markdown sections are being omitted in the asciidoc export when using the base-notebook and minimal-notebook images because these images are designed to be minimalistic and may not include the necessary configurations or extensions to handle markdown cells during the conversion to asciidoc format.

On the other hand, the datascience-notebook image likely includes additional extensions and configurations that enable the correct export of markdown cells to asciidoc format.

To ensure that markdown sections are correctly exported to asciidoc, you may consider using the datascience-notebook image or explore the possibility of customizing the minimal-notebook image by adding the required extensions or configurations for asciidoc export of markdown cells.

英文:

Given a jupyter notebook (here Test_Export.ipynb) with the following content:

{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is markdown."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print('This is code.')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

I'd like to export the executed notebook without input code to asciidoc format. In order to do that, I use the offical docker image and execute:

docker run --rm -it --entrypoint /bin/bash -P -v ${PWD}:/home/jovyan/ jupyter/minimal-notebook:notebook-6.5.4 -c "jupyter nbconvert --execute --to asciidoc --no-input Test_Export.ipynb"

The result looks as follows:

----
This is code.
----

Somehow any markdown area is completely omitted which is the case for base-notebook image and minimal-notebook one. Using datascience-notebook image, the markdown sections are correctly exported to the asciidoc file.

Why is that?

答案1

得分: 1

正如评论中由Wayne提到的,这个问题涉及到nbconvert的版本。似乎7.5.0以上的版本存在这个问题,所以我切换到了以下镜像:

jupyter/minimal-notebook:9e3ab9075a5e

这个镜像包含了版本7.4.0,并成功将笔记本导出为asciidoc格式。

英文:

As mentioned by Wayne in the comments, the problem refers to the version of nbconvert. It seems that versions above 7.5.0 have this problem, so I switched to the following image:

jupyter/minimal-notebook:9e3ab9075a5e

This one contains version 7.4.0 and exports the notebook to asciidoc format successfully.

答案2

得分: 0

只返回翻译好的部分:

要省略输入代码,只需执行以下操作。

jupyter nbconvert yourNotebook.ipynb --no-input
英文:

To omit the input code, simply do the following.

jupyter nbconvert yourNotebook.ipynb --no-input

What is the purpose of your docker container here? It seems irrelevant to the question.

huangapple
  • 本文由 发表于 2023年6月29日 19:34:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76580643.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定