Skip to content

Allow at least one kind of substitution inside directive #680

Description

@senges

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

Activity

  1. welcome commented on Jan 11, 2023

    @welcome

    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! 🎉

  2. dbitouze commented on Jan 11, 2023

    @dbitouze

    Related to #637.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions