Mermaid-Chart / vscode-mermaid-preview

Previews Mermaid diagrams
MIT License
148 stars 16 forks source link

[request] Handles more tags around mermaid code, like HUGO shortcodes. #48

Closed SR-G closed 6 years ago

SR-G commented 6 years ago

Mermaid can be wired for examples with HUGO shortcodes (and inclusion of mermaid files in the HUGO's template). Sadly, the vscode-mermaid-preview does not work anymore in this situation, as the mermaid code is enclosed in a tag not known (yet) by the vscode extension.

For example, i'm using these tags :

{{<mermaid align="left">}} {{</mermaid>}}

The proposal would be to either take in account that kind of tags, either to allow to have customizable tags in a global vscode-mermaid-preview configuration.

vstirbu commented 6 years ago

I'm not that familiar with hugo, so let me know if I understood the issue at hand correctly: you want to extend the extension so that the start and end strings (or more general the regex) that wrap the mermaid diagram to be configurable?

This will allow the extension to render the mermaid enclosed by the strings in your example in addition to the plain html and markdown fences that are currently supported.

SR-G commented 6 years ago

Yes, basically that's it.

HUGO is a templating system (static generator) allowing to convert markdown to HTML. By default, HUGO does not know anything about mermaid, but can easily be extended with "shortcodes" - that are just a small template linked to a HTML entry name (like in the example above). The shortcode name is customizable.

Handling the token as in my example would fit my need, but maybe it's better to make something more generic that would allow to handle any other names, whatever the situation is (HUGO shortcodes, or anything else).

vstirbu commented 6 years ago

can you check if the following regex captures correctly the diagram https://regex101.com/r/iAmzA9/6?

SR-G commented 6 years ago

Yes, it seems fine like this, the output result has the expected layout.

vstirbu commented 6 years ago

do hugo templates (in common use) have other extensions than .html?