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

Option to do not replace source with image #363

Open Bruno-366 opened 3 years ago

Bruno-366 commented 3 years ago

I was wondering if there was/could-be an option to preserve the source and place the outputted image below, rather than replace the source code with the image?

Oftentimes I was to generate an graphviz diagram, but I also want to show the dot code that produced the diagram. Right now the only solution I can think of is duplicating the source code, having two copies means I have to make sure that they're in sync.

pepijnve commented 3 years ago

I'm not sure how feasible that is, because I think a block macro can only generate single block. I'll have a look.

In the meantime, a simple solution that avoids the duplication is to put your dot code in a separate file (e.g., diagram.dot) and then use macros to produce the two blocks you want:

graphviz::diagram.dot[]

[source,dot]
----
include::diagram.dot[]
----
pepijnve commented 3 years ago

Just a note to self, it is possible to do this by creating a compound block.