Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change markdown standard to GFM #812

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 38 additions & 7 deletions doc/markdown-cells.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,47 @@
"* Green\n",
"* Blue\n",
"\n",
"Note: JupyterLab and JupyterNotebook uses a different Markdown parser than nbsphinx (which currently uses Pandoc). \n",
"In case that your Bulletpoints do render in the notebook and do not render with nbsphinx, please add one blank line before the bulletpoints.\n",
"***\n",
"JupyterLab and JupyterNotebook use a different Markdown parser than nbsphinx\n",
"(which currently uses Pandoc). When using Pandoc v2.0 or later, nbsphinx uses\n",
"GitHub-flavored markdown, this is the same standard of markdown used by\n",
"JupyterLab and JupyterNotebook.\n",
"\n",
"In particular, newer versions of nbsphinx (>v0.9.5) will now correctly convert\n",
"lists without a blank line:\n",
"\n",
"```markdown\n",
"No new line before this list:\n",
"1. One\n",
"2. Two\n",
"3. Three\n",
"```\n",
"No new line before this list:\n",
"1. One\n",
"1. Two\n",
"1. Three\n",
"2. Two\n",
"3. Three\n",
"\n",
"\n",
"Arbitrary Unicode characters should be supported, e.g. łßō. Note, however, that\n",
"this only works if your HTML browser and your LaTeX processor provide the\n",
"appropriate fonts."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Task Lists\n",
"\n",
"Arbitrary Unicode characters should be supported, e.g. łßō.\n",
"Note, however, that this only works if your HTML browser and your LaTeX processor provide the appropriate fonts."
"nbsphinx supports GitHub-style task lists:\n",
"\n",
"```\n",
"- [x] Task 1\n",
"- [ ] Task 2\n",
"- [ ] Task 3\n",
"```\n",
"- [x] Task 1\n",
"- [ ] Task 2\n",
"- [ ] Task 3"
]
},
{
Expand Down
19 changes: 14 additions & 5 deletions src/nbsphinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,13 +1039,22 @@ def filter_func(text):
json_data = json.loads(text, object_hook=object_hook)
return json.dumps(json_data)

input_format = 'markdown'
input_format += '-implicit_figures'
v = nbconvert.utils.pandoc.get_pandoc_version()
if nbconvert.utils.version.check_version(v, '1.13'):
input_format += '-native_divs+raw_html'
if nbconvert.utils.version.check_version(v, '2.0'):
input_format += '-smart' # Smart quotes etc. are handled by Sphinx
"""Accodring to https://nbformat.readthedocs.io/en/latest/format_description.html#markdown-cells
the kind of markdown used by jupyter is github flavored markdown (gfm).

The gfm extension was added in 2.0
(https://pandoc.org/releases.html#pandoc-2.0-2017-10-29).
"""
input_format = 'gfm-smart'
else:
input_format = 'markdown'
input_format += '-implicit_figures'
if nbconvert.utils.version.check_version(v, '1.13'):
input_format += '-native_divs+raw_html'
if nbconvert.utils.version.check_version(v, '2.0'):
input_format += '-smart' # Smart quotes etc. are handled by Sphinx

rststring = pandoc(text, input_format, 'rst', filter_func=filter_func)
rststring = re.sub(
Expand Down
Loading