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

Allow at least one kind of substitution inside directive #680

Open
senges opened this issue Jan 11, 2023 · 2 comments
Open

Allow at least one kind of substitution inside directive #680

senges opened this issue Jan 11, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@senges
Copy link

senges commented Jan 11, 2023

Context

This issue is closely related to #172, especially #172 (comment).

As @nickcrider was explaining, there is an edge case where users needs to use {eval-rst} but are unable to use any kind of substitution as Jinja's {{ }} won't be evaluated and reST substitution .. |any| replace:: does not work either (throwing Undefined substitution referenced: "any" error).

To be a bit more precise, in my case, I'm using {eval-rst} to handle more complex tables offered by reST (to merge cells essentially). And it's quite a known fact that tables are hard to maintain when the content gets a bit large.

Until now, with basic markdown tables I was able to use Jinja substitution :

---
myst:
  substitutions:
    large_text: A very long long text here that would make table super ugly...
---

| Key   | Content          |
| :---- | :--------------- |
| Story | {{ large_text }} |

But with reST tables, I cannot manage to make it work :

---
myst:
  substitutions:
    large_text: A very long long text here that would make table super ugly...
---

```{eval-rst}
+------------------------+------------+----------+----------+
| Header row, column 1   | Header 2   | Header 3 | Header 4 |
| (header rows optional) |            |          |          |
+========================+============+==========+==========+
| body row 1, column 1   | column 2   | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2             | {{ large_text }}                 |
+------------------------+------------+----------+----------+
```
```{eval-rst}
.. |large| replace:: A very long long text...

+------------------------+------------+----------+----------+
| Header row, column 1   | Header 2   | Header 3 | Header 4 |
| (header rows optional) |            |          |          |
+========================+============+==========+==========+
| body row 1, column 1   | column 2   | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2             | |large|                          |
+------------------------+------------+----------+----------+
```

Proposal

I understand that this is not that simple, but that would be really great to have some kind of support for reST substitution inside {eval-rst} blocks.

Or any other way of doing text substitution.

I am aware that sphinx-substitution-extention supports rst_prolog but I cannot set these text variables inside the conf.py file. Each text is very page related and that would be very confusing to move it in the config file.

Maybe I'm missing something here ?
Thank you very much 🙏

Tasks and updates

No response

@senges senges added the enhancement New feature or request label Jan 11, 2023
@welcome
Copy link

welcome bot commented Jan 11, 2023

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@dbitouze
Copy link

Related to #637.

chancez added a commit to chancez/MyST-Parser that referenced this issue 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: executablebooks#680

Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
chancez added a commit to chancez/MyST-Parser that referenced this issue 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: executablebooks#680

Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
chancez added a commit to chancez/MyST-Parser that referenced this issue 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: executablebooks#680

Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants