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

markdown: Fix bullet list parsing #2177

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions nbconvert/filters/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def markdown2html_mistune(source: str) -> str:
]


def markdown2latex(source, markup="markdown", extra_args=None):
_MARKDOWN_FMT = "markdown+lists_without_preceding_blankline"


def markdown2latex(source, markup=_MARKDOWN_FMT, extra_args=None):
"""
Convert a markdown string to LaTeX via pandoc.

Expand Down Expand Up @@ -65,7 +68,7 @@ def markdown2html_pandoc(source, extra_args=None):
Convert a markdown string to HTML via pandoc.
"""
extra_args = extra_args or ["--mathjax"]
return convert_pandoc(source, "markdown", "html", extra_args=extra_args)
return convert_pandoc(source, _MARKDOWN_FMT, "html", extra_args=extra_args)


def markdown2asciidoc(source, extra_args=None):
Expand All @@ -80,7 +83,7 @@ def markdown2asciidoc(source, extra_args=None):
atx_args = ["--markdown-headings=atx"]

extra_args = extra_args or atx_args
asciidoc = convert_pandoc(source, "markdown", "asciidoc", extra_args=extra_args)
asciidoc = convert_pandoc(source, _MARKDOWN_FMT, "asciidoc", extra_args=extra_args)
# workaround for https://github.com/jgm/pandoc/issues/3068
if "__" in asciidoc:
asciidoc = re.sub(r"\b__([\w \n-]+)__([:,.\n\)])", r"_\1_\2", asciidoc)
Expand Down Expand Up @@ -111,4 +114,4 @@ def markdown2rst(source, extra_args=None):
out : string
Output as returned by pandoc.
"""
return convert_pandoc(source, "markdown", "rst", extra_args=extra_args)
return convert_pandoc(source, _MARKDOWN_FMT, "rst", extra_args=extra_args)
Loading