Converter cannot locate fetched diagram if image output directory does not match imagesdir
mojavelinux opened this issue · comments
If the image output directory does not match the value of imagesdir
, such as when imagesoutdir
is specified, the converter cannot locate the fetched diagram. This particularly affects Asciidoctor PDF, which must read the image in order to embed it.
The current workaround for this situation in Asciidoctor Diagram is to use an absolute path as the image target if the data-uri
attribute is set on the document. See:
- https://github.com/asciidoctor/asciidoctor-pdf/blob/main/lib/asciidoctor/pdf/converter.rb#L139-L140
- https://github.com/asciidoctor/asciidoctor-diagram/blob/master/lib/asciidoctor-diagram/diagram_processor.rb#L238
Since setting the data-uri
has other implications, we may decide to settle on a different attribute name.
Since we plan to add support for the imagesdir
on the image node in core (see asciidoctor/asciidoctor#3660), one approach is to rely on that enhancement and set the imagesdir
attribute on the generated node if it differs from the normal location. That way, the converter doesn't have to do any extra work.
Related tests in Asciidoctor PDF: https://github.com/asciidoctor/asciidoctor-pdf/blob/main/spec/diagram_spec.rb#L38-L76
@mojavelinux should we anticipate this change and set the imagesdir
attribute on the generated node today?
Since we plan to add support for the imagesdir on the image node in core (see asciidoctor/asciidoctor#3660), one approach is to rely on that enhancement and set the imagesdir attribute on the generated node if it differs from the normal location. That way, the converter doesn't have to do any extra work.
So, if imagesoutdir
is specified we should set the imagesdir
attribute on the generated node? Maybe we should always set the imagesdir
on the generated node?
Yes, I'm confident that we can add the check for imagesdir on the node in 2.1. I'll revive asciidoctor/asciidoctor#3661
Maybe we should always set the imagesdir on the generated node?
Can't hurt, esp since this is essentially an internal negotiation with the converter.