Skip to content

Commit

Permalink
Fix markdown2asciidoc functino for pandoc >= 3.0 (closes jupyter#2017)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed May 30, 2024
1 parent d6dc8a5 commit 91f10fc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions nbconvert/filters/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

from packaging.version import Version
import re

from nbconvert.utils.pandoc import get_pandoc_version

try:
from .markdown_mistune import markdown2html_mistune

Expand Down Expand Up @@ -66,6 +69,15 @@ def markdown2html_pandoc(source, extra_args=None):

def markdown2asciidoc(source, extra_args=None):
"""Convert a markdown string to asciidoc via pandoc"""

# Prior to version 3.0, pandoc supported the --atx-headers flag.
# For later versions, we must instead pass --markdown-headings=atx.
# See https://pandoc.org/releases.html#pandoc-3.0-2023-01-18
atx_args = ["--atx-headers"]
pandoc_version = get_pandoc_version()
if pandoc_version and Version(pandoc_version) >= Version("3.0"):
atx_args = ["--markdown-headings=atx"]

extra_args = extra_args or ["--atx-headers"]
asciidoc = convert_pandoc(source, "markdown", "asciidoc", extra_args=extra_args)
# workaround for https://github.com/jgm/pandoc/issues/3068
Expand Down

0 comments on commit 91f10fc

Please sign in to comment.