Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions myst_parser/mdit_to_docutils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_sphinx/sourcedirs/substitutions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
6 changes: 6 additions & 0 deletions tests/test_sphinx/test_sphinx_builds/test_substitutions.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
</pre>
</div>
</div>
<p>
Test substitutions are processed within eval-rst
</p>
<p>
a - text b
</p>
<p>
Using env and filters:
</p>
Expand Down
6 changes: 6 additions & 0 deletions tests/test_sphinx/test_sphinx_builds/test_substitutions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
This will not process the substitution
<literal_block language="python" xml:space="preserve">
{{ text_with_nest }}
<paragraph>
Test substitutions are processed within eval-rst
<paragraph>
a
- text
b
<paragraph>
Using env and filters:
<paragraph>
Expand Down