Repository: jupyter/nbconvert (python)

Issue:
nbconvert export omits markdown cells
I have noticed that newer _base_ and _minimal_ docker images on dockerhub do not export markdown cells to asciidoc format. It seems that this problem has been introduced at some point of version 7.5.0.

For further details, please have a look at this [stackoverflow question](https://stackoverflow.com/questions/76580643/jupyter-notebook-export-omits-markdown).

Pull request description:
Fix markdown2asciidoc function for pandoc >= 3.0 (closes #2017)
Pass different arguments to `pandoc` depending on whether the version is >= 3.0, to fix #2017.

Patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 42d04df9..7a37851e 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -4,7 +4,7 @@ ci:
 
 repos:
   - repo: https://github.com/pre-commit/pre-commit-hooks
-    rev: v4.5.0
+    rev: v4.6.0
     hooks:
       - id: check-case-conflict
       - id: check-ast
@@ -21,7 +21,7 @@ repos:
       - id: trailing-whitespace
 
   - repo: https://github.com/python-jsonschema/check-jsonschema
-    rev: 0.28.1
+    rev: 0.28.4
     hooks:
       - id: check-github-workflows
 
@@ -45,13 +45,13 @@ repos:
         additional_dependencies: [black==23.7.0]
 
   - repo: https://github.com/codespell-project/codespell
-    rev: "v2.2.6"
+    rev: "v2.3.0"
     hooks:
       - id: codespell
-        args: ["-L", "sur,nd"]
+        args: ["-L", "sur,nd,assertin"]
 
   - repo: https://github.com/pre-commit/mirrors-mypy
-    rev: "v1.9.0"
+    rev: "v1.10.0"
     hooks:
       - id: mypy
         files: "^nbconvert"
@@ -81,7 +81,7 @@ repos:
       - id: rst-inline-touching-normal
 
   - repo: https://github.com/astral-sh/ruff-pre-commit
-    rev: v0.3.5
+    rev: v0.4.8
     hooks:
       - id: ruff
         types_or: [python, jupyter]
@@ -90,7 +90,7 @@ repos:
         types_or: [python, jupyter]
 
   - repo: https://github.com/scientific-python/cookie
-    rev: "2024.03.10"
+    rev: "2024.04.23"
     hooks:
       - id: sp-repo-review
         additional_dependencies: ["repo-review[cli]"]
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6109e572..c42f0a1f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1586,6 +1586,7 @@ raw template
 {%- endblock in_prompt -%}
     """
 
+
 exporter_attr = AttrExporter()
 output_attr, _ = exporter_attr.from_notebook_node(nb)
 assert "raw template" in output_attr
diff --git a/nbconvert/filters/markdown.py b/nbconvert/filters/markdown.py
index 7e4bee9f..fe0cb10e 100644
--- a/nbconvert/filters/markdown.py
+++ b/nbconvert/filters/markdown.py
@@ -8,6 +8,10 @@ markdown within Jinja templates.
 
 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:
diff --git a/pyproject.toml b/pyproject.toml
index 0f5539e2..9d876813 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -27,7 +27,7 @@ urls = {Homepage = "https://jupyter.org"}
 requires-python = ">=3.8"
 dependencies = [
     "beautifulsoup4",
-    "bleach!=5.0.0",
+    "bleach[css]!=5.0.0",
     "defusedxml",
     "importlib_metadata>=3.6;python_version<\"3.10\"",
     "jinja2>=3.0",
@@ -40,7 +40,6 @@ dependencies = [
     "packaging",
     "pandocfilters>=1.4.1",
     "pygments>=2.4.1",
-    "tinycss2",
     "traitlets>=5.1",
 ]
 dynamic = ["version"]
@@ -224,6 +223,8 @@ ignore = [
   "SIM105", # Use `contextlib.suppress(...)`
   "T201",   # `print` found
   "RUF012", # Mutable class attributes should be annotated
+  "UP031",  # Use format specifiers instead of percent format
+
 ]
 unfixable = [
   "T201",   # Don't touch print statements


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index a0c8d3ec..0b652494 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -122,6 +122,8 @@ jobs:
 
       - name: Run tests
         run: |
+          # Attempt to work around https://github.com/pypa/pip/issues/12781
+          PIP_CONSTRAINT= hatch env run -e test -- pip install 'pip>=24.2'
           xvfb-run --auto-servernum hatch run test:nowarn || xvfb-run --auto-servernum hatch run test:nowarn --lf
 
   test_prereleases:
diff --git a/tests/exporters/test_asciidoc.py b/tests/exporters/test_asciidoc.py
index e2a2ae35..0298bf90 100644
--- a/tests/exporters/test_asciidoc.py
+++ b/tests/exporters/test_asciidoc.py
@@ -50,6 +50,10 @@ class TestASCIIDocExporter(ExportersTestsBase):
         assert re.findall(in_regex, output)
         assert re.findall(out_regex, output)
 
+        # Assert that the Markdown header from our test notebook made it into the output.
+        # This can fail when nbconvert invokes pandoc incorrectly, as in issue #2017.
+        assert "== NumPy and Matplotlib examples" in output
+
     @onlyif_cmds_exist("pandoc")
     def test_export_no_prompt(self):
         """