Replies: 6 comments 4 replies
-
Can we safely assume that the problem is localized in code blocks and inline code, and never happens outside of them? |
Beta Was this translation helpful? Give feedback.
-
In general there would be two broad categories of solutions:
Here are some ideas: Category 1: Escaping
Category 2: Detect inapplicable cases
ThoughtsIt seems to be that category 2 is more complicated to implement, and would (by nature) not solve all cases. I like the idea of the metadata field I also understand the ignore list, which could also have advantages. Any comments, or other ideas? |
Beta Was this translation helpful? Give feedback.
-
This has been implemented in commit 1f2c730. The follow up is in issue #78 |
Beta Was this translation helpful? Give feedback.
-
The new doctrine, when migrating an existing project under mkdocs-macros would be:
See the new documentation. |
Beta Was this translation helpful? Give feedback.
-
@HuangFuSL Your example has been included as a test case, for the new exclusion mechanism (
|
Beta Was this translation helpful? Give feedback.
-
@HuangFuSL Was this discussion "answered" for you? |
Beta Was this translation helpful? Give feedback.
-
In LaTeX, curly braces are frequently used. But when two pairs of braces are stacked together, this plug-in will try to interpret the statement, which might cause unwanted behavior or failure. In other circumstances, one may also encounter the same problem: #78 .
The following command is used to draw a table. With the plug-in enabled, the page fails to build because
{{?}}
can't be understood.The documentation suggested three solutions:
{{ 2 + 2 }}
is converted to{{ "{{ 2 + 2 }}" }}
;{% raw %}
and{% endraw %}
to prevent the snippet from being interpreted;mkdocs.yml
.In most cases, these solutions help.
However, what I want is to make the projects using mkdocs-macros and not using mkdocs-macros compatible. That is, the plug-in should be able to detect the pseudo-jinja statements and simply ignore them. The result is that if a project is originally not using mkdocs-macros, switching to mkdocs-macros will not affect the content of the pages. On the contrary, if a project is based on mkdocs-macros, the content should also stay the same except for those "real" jinja2 statements if someone removes mkdocs-macros from the project. Or, to say the least, the interpretation can be controlled outside the document.
Apparently solution 1 and solution 2 cannot satisfy the requirements. Although solution 3 does work, it does not solve the problem but hide it.
Here is some thoughts based on previous discussion. For more discussion on this problem, please refer to Issue #78.
We can intuitively assume jinja-like statements in code blocks are all pseudo-jinja statements. As a result, detecting code blocks automatically requires parsing the markdown file in the plug-in. And that means additional, possibly unworthy work.
I've came up with one possible solution (You can find it here), by adding an ignore file. But it's not sufficient for documents both including jinja statements and so-called pseudo-jinja statements. Is there a better way to resolve this problem?
Beta Was this translation helpful? Give feedback.
All reactions