diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4000d5da..c05356e6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -70,7 +70,7 @@ jobs: strategy: fail-fast: false matrix: - docutils-version: ["0.16", "0.17", "0.18"] + docutils-version: ["0.17", "0.18", "0.19"] steps: - name: Checkout source diff --git a/myst_parser/mdit_to_docutils/base.py b/myst_parser/mdit_to_docutils/base.py index ab720484..1709f1bc 100644 --- a/myst_parser/mdit_to_docutils/base.py +++ b/myst_parser/mdit_to_docutils/base.py @@ -1391,11 +1391,16 @@ def html_meta_to_nodes( return [] try: + # if sphinx available from sphinx.addnodes import meta as meta_cls except ImportError: - from docutils.parsers.rst.directives.html import MetaBody + try: + # docutils >= 0.19 + meta_cls = nodes.meta # type: ignore + except AttributeError: + from docutils.parsers.rst.directives.html import MetaBody - meta_cls = MetaBody.meta # type: ignore + meta_cls = MetaBody.meta # type: ignore output = [] diff --git a/pyproject.toml b/pyproject.toml index a2e988ab..d375a604 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ keywords = [ ] requires-python = ">=3.7" dependencies = [ - "docutils>=0.15,<0.19", + "docutils>=0.15,<0.20", "jinja2", # required for substitutions, but let sphinx choose version "markdown-it-py>=1.0.0,<3.0.0", "mdit-py-plugins~=0.3.0", diff --git a/tests/test_renderers/fixtures/docutil_roles.md b/tests/test_renderers/fixtures/docutil_roles.md index 1aabac99..51fa48d1 100644 --- a/tests/test_renderers/fixtures/docutil_roles.md +++ b/tests/test_renderers/fixtures/docutil_roles.md @@ -93,7 +93,7 @@ . - + PEP 0 . @@ -104,7 +104,7 @@ . - + RFC 1 . diff --git a/tests/test_renderers/test_fixtures_docutils.py b/tests/test_renderers/test_fixtures_docutils.py index d80792f3..a1e16e52 100644 --- a/tests/test_renderers/test_fixtures_docutils.py +++ b/tests/test_renderers/test_fixtures_docutils.py @@ -50,7 +50,18 @@ def _apply_transforms(self): parser=Parser(), ) - file_params.assert_expected(doctree.pformat(), rstrip_lines=True) + ptree = doctree.pformat() + # docutils >=0.19 changes: + ptree = ptree.replace( + 'refuri="http://tools.ietf.org/html/rfc1.html"', + 'refuri="https://tools.ietf.org/html/rfc1.html"', + ) + ptree = ptree.replace( + 'refuri="http://www.python.org/dev/peps/pep-0000"', + 'refuri="https://peps.python.org/pep-0000"', + ) + + file_params.assert_expected(ptree, rstrip_lines=True) @pytest.mark.param_file(FIXTURE_PATH / "docutil_directives.md") diff --git a/tests/test_sphinx/test_sphinx_builds.py b/tests/test_sphinx/test_sphinx_builds.py index c30850f8..beba4845 100644 --- a/tests/test_sphinx/test_sphinx_builds.py +++ b/tests/test_sphinx/test_sphinx_builds.py @@ -299,6 +299,10 @@ def test_include_from_rst( ) +@pytest.mark.skipif( + __version_info__ < VersionInfo(0, 19, 0, "final", 0, True), + reason="Footnote HTML changed in docutils 0.19", +) @pytest.mark.sphinx( buildername="html", srcdir=os.path.join(SOURCE_DIR, "footnotes"), freshenv=True ) diff --git a/tests/test_sphinx/test_sphinx_builds/test_footnotes.sphinx5.html b/tests/test_sphinx/test_sphinx_builds/test_footnotes.sphinx5.html index 9129e236..546739c3 100644 --- a/tests/test_sphinx/test_sphinx_builds/test_footnotes.sphinx5.html +++ b/tests/test_sphinx/test_sphinx_builds/test_footnotes.sphinx5.html @@ -97,113 +97,115 @@


- - - -