adrianvlupu / C4-Builder

This is a documentation builder. You feed it .md and .puml and it exports a site, pdf, or a markdown with navigation.
https://adrianvlupu.github.io/C4-Builder/
MIT License
563 stars 93 forks source link

evol: embed svg diagram #26

Closed sju66 closed 3 years ago

sju66 commented 3 years ago

Hello,

Please consider this pull request.

The purpose of the feature is to include the svg directly in the body of the markdown thus allowing the use of hyperlink in diagrams (diag level 1 -> diag leve2 ...).

To use it, just add the option embedSvgDiagram = true in the .c4builder

jikuja commented 3 years ago

How widely supported is rendering embedded SVG when embedding SVG into markdown itself?

I had multiple problems with my data URI experimentations and markdown renderers and even browser(s) just refused to render SVG data URIs and decided to add png support for stable rendering.

sju66 commented 3 years ago

How widely supported is rendering embedded SVG when embedding SVG into markdown itself?

I use the mardown inline HTML capabilities in order to insert the svg HTML code to which I delete the "comment" part which contains "\n\n" generating a bad interpretation (new block in the markdown sense).

adrianvlupu commented 3 years ago

Hi! Thanks for the pull request. I took it but I made some changes to the way it embeds diagrams. Instead of adding the <div> with the actual svg, I added it as binary data:image/png;base64,QHN0YX....

This way it works with png and other formats as well.