Expose myst_substitions to RST#966
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #966 +/- ##
==========================================
- Coverage 90.30% 90.29% -0.01%
==========================================
Files 24 24
Lines 3507 3514 +7
==========================================
+ Hits 3167 3173 +6
- Misses 340 341 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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: executablebooks#680 Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
30e52eb to
21e1b43
Compare
|
Do what I expected it would do. In my case, I have lots of "reusable" documents where I use 'substitutions' to eventually generate the right output when product names etc... get eventually defined. However I also intensively use "conditional compiling" (in RST) to get parts of docs included/excluded from the final output. Thanks a lot for the time spend and the solution. |
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.