asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
435 stars 106 forks source link

Support SVG/HTML integration #342

Open rmannibucau opened 3 years ago

rmannibucau commented 3 years ago

Hi,

It is possible to do svg image using plantUML (or some others) but it is integrated as an + base64 encoding. This makes the usage of SVG pretty impossible to add JS event handler on the SVG (which is one of the key facet of using SVG with vector one). Would be great to support to inject the SVG in the dom instead of relying on the encoding hack.

pepijnve commented 3 years ago

This is controlled by the svg-type attribute (or diagram-svg-type at the document level). If not specified you'll get whatever default value Asciidoctor decides to apply. Note that the base64 encoding is not a hack, but a means to make the generated HTML self contained. See https://docs.asciidoctor.org/asciidoc/latest/macros/image-svg/ for more details.

rmannibucau commented 3 years ago

@pepijnve hmm, embedding the svg is self contained too so still sounds like the default for svg should change, no?

Edit: confirming it works with [plantuml, generated/xxx.svg, svg, role="myclass",opts=inline]

pepijnve commented 3 years ago

That's something Asciidoctor core does, not the diagram extension. The extension generates a file on disk and passes the path to that file on to Asciidoctor core.

rmannibucau commented 3 years ago

@pepijnve I know but it is something I'd like to not be (ie when embedded the image is not even dumped physically)

pepijnve commented 3 years ago

BTW you should be able to get the behaviour you want by adding :diagram-svg-type: inline to the attribute section of your file.

pepijnve commented 3 years ago

I know but it is something I'd like to not be (ie when embedded the image is not even dumped physically)

That's simply not possible today I'm afraid and I'm not inclined to add support for that. The extension uses those files on disk to avoid needlessly rerendering unchanged images for instance.

rmannibucau commented 3 years ago

Ok I see, let's hope it is possible someday since temp images are very bothering in most editors and it is not alway easy to control them with imagesdir or equivalent. Thanks for the inline tip btw!