diff --git a/myst_parser/mdit_to_docutils/base.py b/myst_parser/mdit_to_docutils/base.py index bdd15156..e7cd70ff 100644 --- a/myst_parser/mdit_to_docutils/base.py +++ b/myst_parser/mdit_to_docutils/base.py @@ -280,6 +280,17 @@ def _render_finalise(self) -> None: substitution_node, f"wordcount-{key}" ) + for key, value in self.md_config.substitutions.items(): + if value is None: + continue + + substitution_node = nodes.substitution_definition( + str(value), nodes.Text(str(value)) + ) + substitution_node.source = self.document["source"] + substitution_node["names"].append(key) + self.document.note_substitution_def(substitution_node, key) + def nested_render_text( self, text: str, diff --git a/tests/test_sphinx/sourcedirs/substitutions/index.md b/tests/test_sphinx/sourcedirs/substitutions/index.md index 9773a951..a475aeb4 100644 --- a/tests/test_sphinx/sourcedirs/substitutions/index.md +++ b/tests/test_sphinx/sourcedirs/substitutions/index.md @@ -52,6 +52,12 @@ This will not process the substitution {{ text_with_nest }} ``` +Test substitutions are processed within eval-rst + +```{eval-rst} +a |text| b +``` + Using env and filters: {{ env.docname | upper }} diff --git a/tests/test_sphinx/test_sphinx_builds/test_substitutions.html b/tests/test_sphinx/test_sphinx_builds/test_substitutions.html index 38ff9bae..2bf4b38d 100644 --- a/tests/test_sphinx/test_sphinx_builds/test_substitutions.html +++ b/tests/test_sphinx/test_sphinx_builds/test_substitutions.html @@ -62,6 +62,12 @@ +
+ Test substitutions are processed within eval-rst +
++ a - text b +
Using env and filters:
diff --git a/tests/test_sphinx/test_sphinx_builds/test_substitutions.xml b/tests/test_sphinx/test_sphinx_builds/test_substitutions.xml index 37bd766a..a9fe9b11 100644 --- a/tests/test_sphinx/test_sphinx_builds/test_substitutions.xml +++ b/tests/test_sphinx/test_sphinx_builds/test_substitutions.xml @@ -47,6 +47,12 @@ This will not process the substitution