forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nbconvert: fix asciidoc markdown export (jupyter/nbconvert#2017)
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
pkgs/development/python-modules/nbconvert/fix-asciidoc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
From 7f4e3bbb4a523df2d1866310a09697c601277678 Mon Sep 17 00:00:00 2001 | ||
From: thomasjm <tom@codedown.io> | ||
Date: Thu, 30 May 2024 02:54:34 -0700 | ||
Subject: [PATCH] Fix markdown2asciidoc function for pandoc >= 3.0 (closes | ||
#2017) | ||
|
||
--- | ||
nbconvert/filters/markdown.py | 15 ++++++++++++++- | ||
1 file changed, 14 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/nbconvert/filters/markdown.py b/nbconvert/filters/markdown.py | ||
index 7e4bee9fd..fe0cb10e2 100644 | ||
--- a/nbconvert/filters/markdown.py | ||
+++ b/nbconvert/filters/markdown.py | ||
@@ -8,6 +8,10 @@ | ||
|
||
import re | ||
|
||
+from packaging.version import Version | ||
+ | ||
+from nbconvert.utils.pandoc import get_pandoc_version | ||
+ | ||
try: | ||
from .markdown_mistune import markdown2html_mistune | ||
|
||
@@ -66,7 +70,16 @@ def markdown2html_pandoc(source, extra_args=None): | ||
|
||
def markdown2asciidoc(source, extra_args=None): | ||
"""Convert a markdown string to asciidoc via pandoc""" | ||
- extra_args = extra_args or ["--atx-headers"] | ||
+ | ||
+ # 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_args | ||
asciidoc = convert_pandoc(source, "markdown", "asciidoc", extra_args=extra_args) | ||
# workaround for https://github.com/jgm/pandoc/issues/3068 | ||
if "__" in asciidoc: |