You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently only substitution works for direct expansion of variables. It would be nice to have support for {% for %} directives and so on.
Describe the solution you'd like
No response
Describe alternatives you've considered
I've tried simply parsing the files as jinja templates, but it fails at directives like :::{include} because of curly brackets. How does myst get arround this?
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).
Ok, it seems that the error I encountered was not on that side, and indeed I am able to hack in the jinja rendered with:
defjinja_render(app: Sphinx, docname: str, source: list[str]) ->None:
""" Render pages as jinja templates :param app: Sphinx app :param docname: Name of the doc file :param source: Single element list with the source as first element """ifapp.builder.format!='html':
# Only parsing html for nowreturnfile=Path(app.env.doc2path(docname, base=False))
if".j2"notinfile.suffixes:
# If the file is not explicitly a jinja template do not parse itreturnsrc=source[0]
rendered=app.builder.templates.render_string(src, app.config.html_context)
source[0] =rendereddefsetup(app: Sphinx):
app.connect("source-read", jinja_render)
Only issue there is I can't extract the filename so that id doesn't try to render non-jinja file. If you have a clue, that would be wonderful
I did check that one out, and it uses directives. I want this one to be for the whole file. I've used this one for inspiration. Do you know how to extract the filename in general from app object?
Activity
welcome commentedon Jun 29, 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! 🎉
chrisjsewell commentedon Jun 30, 2023
Heya, to note, myst-parser does not use jinja to actually parse the file, but only for expression evaluation.
Parsing is done with a plugin to the Markdown parser, e.g.
gives
expressions are then evaluated in a post-processing step
LecrisUT commentedon Jun 30, 2023
Ok, it seems that the error I encountered was not on that side, and indeed I am able to hack in the jinja rendered with:
Only issue there is I can't extract the filename so that id doesn't try to render non-jinja file. If you have a clue, that would be wonderful
chrisjsewell commentedon Jun 30, 2023
You might want to have a look at https://pypi.org/project/sphinx-jinja/
LecrisUT commentedon Jun 30, 2023
I did check that one out, and it uses directives. I want this one to be for the whole file. I've used this one for inspiration. Do you know how to extract the filename in general from
appobject?chrisjsewell commentedon Jun 30, 2023
app.env.doc2pathLecrisUT commentedon Jun 30, 2023
Thanks a bunch! I'll update the comment above with a short implementation. Not sure how to share it more generally though