Replies: 5 comments 5 replies
-
I m not exactly sure if I understand your question. Isn't it something that jinja2 provides out of the box? Both Markdown and jinja2 are largely agnostic: you can import non Markdown files. It will be gracefully ignored (unless it conflicts with Markdown syntax); and it if is HTML, it will keep it as-is. Hence, you could, in principle, import whatever file of whatever format you want. |
Beta Was this translation helpful? Give feedback.
-
I was asking if is it possible via MkDocs or your plugin to process jinja2 template in files other than markdown, in a SVG in this case. For the rest I tried to explain what I was going to do with that code; basically using some "includes" to process data to generate the final SVG code. |
Beta Was this translation helpful? Give feedback.
-
II understand: if you want to import an SVG, with a little more than the standard Markdown facilities, a macro would be a good fit. I asked ChatGPT how to do that... and here it is its answer:
Which is a little naive, because you want HTML, I guess. But you have the gist. |
Beta Was this translation helpful? Give feedback.
-
I want to process jinja2 code inside a svg to produce the svg in the same way markdown with jinja2 code inside produce the final html. |
Beta Was this translation helpful? Give feedback.
-
The discussion in MKDocs was solved, so closing this, thank you again for the tips! |
Beta Was this translation helpful? Give feedback.
-
Hello! This has already been discussed in mkdocs/mkdocs#3251, but looking at the template files I'm using, it would be much more simply solved if it could be possible to process macros' jinja templates in non markdown files:
docs/assets/img/badge.svg
:includes/status_progress.j2
has the svg data plus some jinja template variables to generate it with the needed label (name
parameter, e.g. "ARIA"), and progress bar value (progress
, e.g. a variable with a value of 57).includes/status_badge.j2
has some macros that calculate the values based on a YAML file data. This template file is already used for a table in another page, so I reuse the code for these badge images.Result (despite a font size issue):
Beta Was this translation helpful? Give feedback.
All reactions