👌 Improve generation of meta nodes #1080
Merged
+103
−74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates how HTML meta nodes are generated in MyST-Parser to ensure compatibility with Sphinx v9.
Changes Made
myst_parser/mdit_to_docutils/base.pyfrom docutils.transforms.components import Filterhtml_meta_to_nodes():list[nodes.pending | nodes.system_message]list[nodes.meta | nodes.system_message]nodes.pendingwith aFiltertransform, meta nodes are now directly returnedTest Fixtures Updated
tests/test_renderers/fixtures/docutil_syntax_elements.mdtests/test_renderers/fixtures/sphinx_syntax_elements.mdExpected output changed from
<pending>nodes with internal transform details to direct<meta>nodes.Assessment: ✅ Correct and Necessary
Why This Change is Needed
nodes.metabecame a standard node type that writers handle directlyFiltertransform with pending nodes is deprecated/removed in newer Sphinx versionsWhy It Works
nodes.metadirectly and render them as<meta>tags in the HTML<head>sectionnodes.metaapproachTest Coverage
tests/test_renderers/fixtures/docutil_syntax_elements.mdtests/test_renderers/fixtures/sphinx_syntax_elements.mdtests/test_renderers/fixtures/myst-config.txt--myst-html-metaoptiontests/test_sphinx/test_sphinx_builds.py::test_extended_syntaxestests/test_sphinx/test_sphinx_builds.py::test_extended_syntaxes_textNon-HTML Builder Coverage
The added
test_extended_syntaxes_texttest uses thetextbuilder with theextended_syntaxessource directory, which hasmyst_html_metaconfigured.This ensures that meta nodes don't cause issues for non-HTML builders—they simply don't render meta tags (as expected, since
<meta>is an HTML-specific concept).