top | item 30336812

(no title)

martinwoodward | 4 years ago

The idea of the bang syntax came up. https://talk.commonmark.org/t/mermaid-generation-of-diagrams...

But in the end went with simple. There will be a very limited subset that will render this way - executing raw code without the users permission in the browser just opens up too much attack surface area that we’d need a very compelling use case to do the security work necessary to make it protected (even if that was possible)

discuss

order

mintplant|4 years ago

Alright, but how do I embed highlighted Mermaid source code in Markdown now?

qbasic_forever|4 years ago

embed the HTML:

<pre><code> your mermaid code <span class="foo">with highlighted</span> sections </code></pre>

Use a tool like pygments to generate the highlighted HTML (assuming there even is highlighting for mermaid syntax).

What you're asking for is an uncommon edgecase that's not what people want in 99% of circumstances (instead they want the rendered chart). Markdown still gives you the HTML escape hatch so use it. Sure it's not pretty but it's no worse than if github didn't support highlighting mermaid source anyways.

If you don't want highlighting just put a fenced code block without the mermaid info string. It will render as unhighlighted code. IMHO that's what you'd want as a workaround to demo source like in a mermaid readme.

e12e|4 years ago

I don't think github should (generally) render stuff in the browser (although I see that both "benign"[1] graphs and source code highlights, not to mention the somewhat simple translation from Markdown to html - probably could be done in the browser as js/wasm.

But for "markdown the language" having a standard syntax for embed/evaluate along with prettify/highlight would've been nice - effectively a standard markup for multi-language "notebooks"/literate programs (maybe we need a triplet: format, render/embed, transclude/literate programming).

Github could then opt-in to highlighting the N languages they do, and initially only try to render mermaid graphs. Then perhaps also graphviz graphs. Etc.

[1] I'm sure one could do some minor DOS at least with a 500 mb graph..