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
439 stars 107 forks source link

Images inside of diagrams not rendering #378

Closed Alwinator closed 2 years ago

Alwinator commented 2 years ago

I want to use a diagram that includes an image inside of my asciidoctor document. However, the image inside of the diagram does not render in the document. When I directly build the diagram using the blockdiag command it works.

It also does not work with graphviz diagrams. I have this problem both when creating HTML and PDF.

test.diag

blockdiag {
   A [label = "", background = "asciidoctor.png"];
   A -> B;
}

Output of the blockdiag test.diag command: test

test.adoc

== Test

[blockdiag, format=png]
----
include::test.diag[]
----

The image rendered from asciidoctor: diag-de9e625d4980107e4cde6f2a5b6252e0

pepijnve commented 2 years ago

Could you give this a try instead blockdiag::test.diag[format=png]? The difference between the two is that in your example the diagram processor uses the directory containing test.adoc as base directory while in my suggestion the base directory containing test.diag should get used.

Alwinator commented 2 years ago

@pepijnve Thank you for your comment. Unfortunately, I have the same problem with blockdiag::test.diag[format=png]. (All three files (.adoc, .diag, .png) are in the same directory.)

pepijnve commented 2 years ago

I tried to reproduce what you're seeing locally, but no success so far I'm afraid. blockdiag test.diag and running through asciidoctor result in the same image here.

pepijnve commented 2 years ago

I think this has to do with the current directory of the blockdiag subprocess not being set at all. As a consequence the resolution of the image path will start from the current directory of the shell from which asciidoctor is being run. Could that explain the difference we're seeing?

Alwinator commented 2 years ago

@pepijnve Sorry for the long delay. I was finally able to reproduce the bug in a new environment. I have used Docker to make sure that it also works on your machine. You can find the code here: https://github.com/Alwinator/asciidoctor-diagram-image-bug I also think that it is a directory problem, but I haven't found it yet.

Alwinator commented 2 years ago

@pepijnve Were you able to reproduce the bug on your computer using the Docker image?

pepijnve commented 2 years ago

I haven't had a chance to try yet. Paid work is keeping me occupied.

Alwinator commented 2 years ago

@pepijnve That's okay! Just tell me when you reviewed it.

Alwinator commented 2 years ago

It was a path issue, I've fixed it by setting the :outdir: parameter in addition to the :imagesdir:.