Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose myst_substitions to RST #966

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chancez
Copy link

@chancez chancez commented Aug 22, 2024

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_def from reading where the Undefined substitution referenced: error message comes from and determining that it reads from two dictionaries that the document.note_substitution_def updates. I then kind of got lucky and found that MyST already 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 from self.md_config.substitutions which is where myst_substitutions values 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.

Copy link

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.29%. Comparing base (1038800) to head (30e52eb).

Files Patch % Lines
myst_parser/mdit_to_docutils/base.py 85.71% 1 Missing ⚠️
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     
Flag Coverage Δ
pytests 90.29% <85.71%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 <[email protected]>
@chancez chancez force-pushed the pr/chancez/expose_myst_substitutions_to_rst_substitutions branch from 30e52eb to 21e1b43 Compare August 22, 2024 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant