Closed guansss closed 1 year ago
Thank you for your contribution! This is very appreciated.
It turns out that the annotations are half escaped, resulting in unexpected HTML tag that breaks Mermaid parser:
I looked into the source of fence_mermaid
formatter and the comment says it does not escape the Mermaid source, so I switched to the official formatter superfences.fence_div_format
(which does escape) and then everything worked without problem.
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_div_format
Looks like escaping the source is necessary? Then I'm wondering, what was the original purpose of not to escape? Does escaping have pitfalls?
That's a thought-provoking question 🤔. I will look into it.
The custom mermaid2.fence_mermaid
was developed specifically for the loose security mode, which allows tags in text and clicking (it's stated in the code of the fence.py
.
When using tags in text, you don't want to escape your HTML .
But if you are operating in the default strict mode (no tags in text and no clickable links), escaping might indeed be better.
🤔 Perhaps I should document this better?
Oh I missed that part. Thanks for the answer!
Perhaps I should document this better?
That'll be good. 👍 Maybe also suggest user to manually escape these symbols (e.g. <<abstract>>
) as a workaround in loose mode.
Source:
Expected:
Actual:
Here's the mkdocs.yml, if I disable SuperFences it works as expected.
mkdocs==1.3.1 mkdocs-mermaid2-plugin==0.6.0 pymdown-extensions==9.5