Expose myst_substitions to RST #966
Open
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.
While this doesn't fix the fact that
.. replace::does not work within eval-rst, it does make it possible to perform substitutions within eval-rst using the same substitutions available to Jinja substitutions.Related: #680
Honestly I have very little experience with docutils, or even MyST but I basically figured out substitutions need to be registered by calling
self.document.note_substitution_deffrom reading where theUndefined substitution referenced:error message comes from and determining that it reads from two dictionaries that thedocument.note_substitution_defupdates. I then kind of got lucky and found thatMySTalready called the necessary function for the wordcount extension, which gave me a basic example of what I needed to do. I literally just copy and pasted the code used for the word count extension but using the values fromself.md_config.substitutionswhich is wheremyst_substitutionsvalues are stored, and it "just worked".Let me know what you think, like I said, it was really just a stab at trying to make something substitution related work for
eval-rst. I'd still love to get.. replace::working but this will solve my needs pretty well I think.