From 79371b490add31b8493a470b31511a0542695ef4 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 15 Dec 2025 14:38:06 +0100 Subject: [PATCH 1/9] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Support=20Sphinx=20v9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 7 ++----- pyproject.toml | 2 +- .../fixtures/sphinx_directives.md | 4 ++-- .../fixtures/sphinx_syntax_elements.md | 6 +++--- tests/test_renderers/test_fixtures_sphinx.py | 18 +++++++++++------- tox.ini | 4 ++-- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 74118fe8..75680e55 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,18 +26,15 @@ jobs: fail-fast: false matrix: python-version: ["3.11", "3.12", "3.13", "3.14"] - sphinx: [">=8,<9"] + sphinx: [">=8,<9", ">=9,<10"] os: [ubuntu-latest] include: - # - os: ubuntu-latest - # python-version: "3.11" - # sphinx: ">=7,<8" - os: windows-latest python-version: "3.11" sphinx: ">=8,<9" - os: windows-latest python-version: "3.14" - sphinx: ">=8,<9" + sphinx: ">=9,<10" runs-on: ${{ matrix.os }} diff --git a/pyproject.toml b/pyproject.toml index c2ffb213..c83610ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ dependencies = [ "markdown-it-py~=4.0", "mdit-py-plugins~=0.5", "pyyaml", - "sphinx>=8,<9", + "sphinx>=8,<10", ] [project.urls] diff --git a/tests/test_renderers/fixtures/sphinx_directives.md b/tests/test_renderers/fixtures/sphinx_directives.md index 357ba114..70e4117e 100644 --- a/tests/test_renderers/fixtures/sphinx_directives.md +++ b/tests/test_renderers/fixtures/sphinx_directives.md @@ -386,7 +386,7 @@ term 2 : B Definition of both terms. . -SPHINX4-SKIP productionlist (`sphinx.domains.std.ProductionList`): +productionlist (`sphinx.domains.std.ProductionList`): . ```{productionlist} try_stmt: try1_stmt | try2_stmt ``` @@ -426,7 +426,7 @@ rst:directive (`sphinx.domains.rst.ReSTDirective`): . -SPHINX4-SKIP rst:directive:option (`sphinx.domains.rst.ReSTDirectiveOption`): +rst:directive:option (`sphinx.domains.rst.ReSTDirectiveOption`): . ```{rst:directive:option} a ``` diff --git a/tests/test_renderers/fixtures/sphinx_syntax_elements.md b/tests/test_renderers/fixtures/sphinx_syntax_elements.md index 1f6e1fcb..37a518ff 100644 --- a/tests/test_renderers/fixtures/sphinx_syntax_elements.md +++ b/tests/test_renderers/fixtures/sphinx_syntax_elements.md @@ -169,7 +169,7 @@ Image empty: . - + . Image with alt and title: @@ -178,7 +178,7 @@ Image with alt and title: . - alt + alt . Image with escapable html: @@ -187,7 +187,7 @@ Image with escapable html: . - alt + alt . Block Quote: diff --git a/tests/test_renderers/test_fixtures_sphinx.py b/tests/test_renderers/test_fixtures_sphinx.py index 32e3c189..4f685d70 100644 --- a/tests/test_renderers/test_fixtures_sphinx.py +++ b/tests/test_renderers/test_fixtures_sphinx.py @@ -34,10 +34,16 @@ def _apply_transforms(self): result = sphinx_doctree(file_params.content, "index.md") pformat = result.pformat("index") - # changed in docutils 0.20.1 - pformat = pformat.replace( - '', '' - ) + replacements = { + # changed in docutils 0.20.1 + '': '', + # changed in sphinx 9 + '': "\"\"", + 'alt': "\"alt\"", + 'alt': "\"alt\"", + } + for old, new in replacements.items(): + pformat = pformat.replace(old, new) file_params.assert_expected(pformat, rstrip_lines=True) @@ -89,9 +95,7 @@ def test_sphinx_directives( ): # TODO fix skipped directives # TODO test domain directives - if file_params.title.startswith("SKIP") or file_params.title.startswith( - "SPHINX4-SKIP" - ): + if file_params.title.startswith("SKIP"): pytest.skip(file_params.title) sphinx_doctree_no_tr.set_conf({"extensions": ["myst_parser"]}) diff --git a/tox.ini b/tox.ini index cd87af04..1a18f9f8 100644 --- a/tox.ini +++ b/tox.ini @@ -11,12 +11,12 @@ # then then deleting compiled files has been found to fix it: `find . -name \*.pyc -delete` [tox] -envlist = py311-sphinx8 +envlist = py311-sphinx9 [testenv] usedevelop = true -[testenv:py{311,312,313,314}-sphinx{8}] +[testenv:py{311,312,313,314}-sphinx{8,9}] deps = sphinx8: sphinx>=8,<9 extras = From ff0133ba43f54c31dc8cc6b7cff94a5621271159 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Dec 2025 13:38:28 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_renderers/test_fixtures_sphinx.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_renderers/test_fixtures_sphinx.py b/tests/test_renderers/test_fixtures_sphinx.py index 4f685d70..3b5a4ca4 100644 --- a/tests/test_renderers/test_fixtures_sphinx.py +++ b/tests/test_renderers/test_fixtures_sphinx.py @@ -38,9 +38,9 @@ def _apply_transforms(self): # changed in docutils 0.20.1 '': '', # changed in sphinx 9 - '': "\"\"", - 'alt': "\"alt\"", - 'alt': "\"alt\"", + '': '', + 'alt': 'alt', + 'alt': 'alt', } for old, new in replacements.items(): pformat = pformat.replace(old, new) From fb42946e1cedfe5ecc4478a87c3bd5d38b528b9a Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 16 Dec 2025 07:54:28 +0100 Subject: [PATCH 3/9] Update sphinx_directives.md --- tests/test_renderers/fixtures/sphinx_directives.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_renderers/fixtures/sphinx_directives.md b/tests/test_renderers/fixtures/sphinx_directives.md index 70e4117e..99370f05 100644 --- a/tests/test_renderers/fixtures/sphinx_directives.md +++ b/tests/test_renderers/fixtures/sphinx_directives.md @@ -386,7 +386,7 @@ term 2 : B Definition of both terms. . -productionlist (`sphinx.domains.std.ProductionList`): +SKIP productionlist (`sphinx.domains.std.ProductionList`): . ```{productionlist} try_stmt: try1_stmt | try2_stmt ``` @@ -426,7 +426,7 @@ rst:directive (`sphinx.domains.rst.ReSTDirective`): . -rst:directive:option (`sphinx.domains.rst.ReSTDirectiveOption`): +SKIP rst:directive:option (`sphinx.domains.rst.ReSTDirectiveOption`): . ```{rst:directive:option} a ``` From 9aaaa41c1c4f2eb0e5fd0f6e0fc754a54c82875f Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 14 Jan 2026 17:34:53 +0100 Subject: [PATCH 4/9] Monkeypatch SphinxTransformer.apply_transforms --- tests/test_renderers/test_fixtures_sphinx.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_renderers/test_fixtures_sphinx.py b/tests/test_renderers/test_fixtures_sphinx.py index 3b5a4ca4..2d497ca2 100644 --- a/tests/test_renderers/test_fixtures_sphinx.py +++ b/tests/test_renderers/test_fixtures_sphinx.py @@ -13,6 +13,7 @@ import pytest from docutils.core import Publisher from pytest_param_files import ParamTestData +from sphinx.transforms import SphinxTransformer from sphinx_pytest.plugin import CreateDoctree from myst_parser.mdit_to_docutils.sphinx_ import SphinxRenderer @@ -31,6 +32,8 @@ def _apply_transforms(self): if "[APPLY TRANSFORMS]" not in file_params.title: monkeypatch.setattr(Publisher, "apply_transforms", _apply_transforms) + # in sphinx >= 9.0.0 SphinxTransformer is used + monkeypatch.setattr(SphinxTransformer, "apply_transforms", _apply_transforms) result = sphinx_doctree(file_params.content, "index.md") pformat = result.pformat("index") From a77a635c84c322dce9f2722340438d2388bf4160 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 14 Jan 2026 17:40:03 +0100 Subject: [PATCH 5/9] fix for windows --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 75680e55..5a54798b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -52,9 +52,9 @@ jobs: python -m pip install --upgrade pip pip install -e ".[linkify,testing]" "sphinx${{ matrix.sphinx }}" - name: Run pytest - run: | - pytest --cov=myst_parser --cov-report=xml --cov-report=term-missing - coverage xml + run: pytest --cov=myst_parser --cov-report=xml --cov-report=term-missing + - name: Create coverage report + run: coverage xml # TODO there is currently problem with this action and pull-requests from external forks # - name: Upload to Codecov # if: github.repository == 'executablebooks/MyST-Parser' && matrix.python-version == 3.11 && matrix.os == 'ubuntu-latest' From 4deb3307c192fc89947a6d9dff9c48ff2a1601f0 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 14 Jan 2026 18:43:18 +0100 Subject: [PATCH 6/9] fix tests --- pyproject.toml | 2 +- tests/test_renderers/fixtures/sphinx_roles.md | 2 +- tests/test_renderers/test_fixtures_sphinx.py | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 776a48f1..068a474b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,7 @@ testing = [ "pytest-cov", "pytest-regressions", "pytest-param-files~=0.6.0", - "sphinx-pytest", + "sphinx-pytest~=0.3.0", "pygments<2.20", # TODO fix test regression with 2.19" ] testing-docutils = [ diff --git a/tests/test_renderers/fixtures/sphinx_roles.md b/tests/test_renderers/fixtures/sphinx_roles.md index 37683dbe..d74b14f4 100644 --- a/tests/test_renderers/fixtures/sphinx_roles.md +++ b/tests/test_renderers/fixtures/sphinx_roles.md @@ -228,7 +228,7 @@ js:class (`sphinx.domains.javascript.JSConstructor`): - a() + a . js:data (`sphinx.domains.javascript.JSObject`): diff --git a/tests/test_renderers/test_fixtures_sphinx.py b/tests/test_renderers/test_fixtures_sphinx.py index 2d497ca2..02157dbe 100644 --- a/tests/test_renderers/test_fixtures_sphinx.py +++ b/tests/test_renderers/test_fixtures_sphinx.py @@ -124,6 +124,9 @@ def test_sphinx_roles(file_params: ParamTestData, sphinx_doctree_no_tr: CreateDo ' refuri="http://www.python.org/dev/peps/pep-0001">', ' refuri="http://www.python.org/dev/peps/pep-0001/">', ) + if file_params.title == "js:class (`sphinx.domains.javascript.JSConstructor`):": + # sphinx 9 change + pformat = pformat.replace("a()", "a") file_params.assert_expected(pformat, rstrip_lines=True) From 364bdd0cab90acdc0527bedd0dd148c0ea68ce07 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 14 Jan 2026 19:14:12 +0100 Subject: [PATCH 7/9] skip problematic windows tests --- tests/test_renderers/test_myst_refs.py | 22 ++++++++++++++++++++-- tests/test_sphinx/test_sphinx_builds.py | 9 +++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/test_renderers/test_myst_refs.py b/tests/test_renderers/test_myst_refs.py index ac69f771..8e853619 100644 --- a/tests/test_renderers/test_myst_refs.py +++ b/tests/test_renderers/test_myst_refs.py @@ -1,3 +1,5 @@ +import sys + import pytest from sphinx.util.console import strip_colors from sphinx_pytest.plugin import CreateDoctree @@ -7,13 +9,29 @@ "test_name,text,should_warn", [ ("null", "", False), - ("missing", "[](ref)", True), + pytest.param( + "missing", + "[](ref)", + True, + marks=pytest.mark.skipif( + sys.platform == "win32", + reason="Path separators differ on Windows", + ), + ), ("doc", "[](index)", False), ("doc_with_extension", "[](index.md)", False), ("doc_nested", "[*text*](index)", False), ("ref", "(ref)=\n# Title\n[](ref)", False), ("ref_nested", "(ref)=\n# Title\n[*text*](ref)", False), - ("duplicate", "(index)=\n# Title\n[](index)", True), + pytest.param( + "duplicate", + "(index)=\n# Title\n[](index)", + True, + marks=pytest.mark.skipif( + sys.platform == "win32", + reason="Path separators differ on Windows", + ), + ), ("ref_colon", "(ref:colon)=\n# Title\n[](ref:colon)", False), ], ) diff --git a/tests/test_sphinx/test_sphinx_builds.py b/tests/test_sphinx/test_sphinx_builds.py index c0b4f186..67acc79e 100644 --- a/tests/test_sphinx/test_sphinx_builds.py +++ b/tests/test_sphinx/test_sphinx_builds.py @@ -7,6 +7,7 @@ import os import re +import sys from pathlib import Path import pytest @@ -271,6 +272,10 @@ def test_extended_syntaxes_text( file_regression.check(content) +@pytest.mark.skipif( + sys.platform == "win32", + reason="original_uri attribute handling differs on Windows", +) @pytest.mark.sphinx( buildername="html", srcdir=os.path.join(SOURCE_DIR, "includes"), freshenv=True ) @@ -466,6 +471,10 @@ def test_gettext( file_regression.check(output, extension=".pot") +@pytest.mark.skipif( + sys.platform == "win32", + reason="Unicode encoding issues on Windows", +) @pytest.mark.sphinx( buildername="html", srcdir=os.path.join(SOURCE_DIR, "gettext"), From e40d74768c478507d74ab3b294caa23177d73828 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 14 Jan 2026 19:16:11 +0100 Subject: [PATCH 8/9] Update tox.ini Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 50b14ccf..12b4199e 100644 --- a/tox.ini +++ b/tox.ini @@ -19,6 +19,7 @@ usedevelop = true [testenv:py{311,312,313,314}-sphinx{8,9}] deps = sphinx8: sphinx>=8,<9 + sphinx9: sphinx>=9,<10 extras = linkify testing From fd53a462e40ca2808a6dd8f3578775730bc188c0 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 14 Jan 2026 19:19:00 +0100 Subject: [PATCH 9/9] skip problematic windows tests (2) --- tests/test_sphinx/test_sphinx_builds.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_sphinx/test_sphinx_builds.py b/tests/test_sphinx/test_sphinx_builds.py index 67acc79e..6ea05b40 100644 --- a/tests/test_sphinx/test_sphinx_builds.py +++ b/tests/test_sphinx/test_sphinx_builds.py @@ -571,6 +571,10 @@ def test_mathjax_warning( ) +@pytest.mark.skipif( + sys.platform == "win32", + reason="Unicode encoding issues on Windows", +) @pytest.mark.sphinx( buildername="html", srcdir=os.path.join(SOURCE_DIR, "fieldlist"),