atom-editorasciidocasciidoctor

How reference correctly images through many .adoc files located in different folders


I am working with Atom Editor + the two plugins/packages available about asciidoctor.

All work how it is expected. But I am with the following situation:

I have the following directory structure:

xml
  figures
     findOneXml.adoc
     findOneXml.png
  urls
     findOne.adoc

Where findOneXml.adoc (within figures folder) has

[[findOneXml]]
image::findOneXml.png[caption="Figure - " title="findOneXml"]

With the live preview I can see the image and its respective description

Now with findOne.adoc (within url folder) contains among many things the following line:

include::../figures/findOneXml.adoc[]

I think the path reference is ok. if I use other, the live preview shows an error message about an invalid or wrong path.

But through the live preview I see broken the image but I can see the description.

enter image description here

What is wrong or missing?

Even with include::./../figures/findOneXml.adoc[] fails

Note: in the sub/child document I need add other data how notes, tips (Admonition), that child document would be reused many times by other parents. So I only don't need refer to the image only.

Thanks


Solution

  • The image is resolved relative to an internal base path of the asciidoc rendering engine. In your case I assume the engine takes the path of the rendered (main, parent) document. So, images are resolved relative to that. Try:

    image::../figures/findOneXml.png[]
    

    This should work for both adoc documents, as the path moves up to the parent directory and then explicitly down into the figures directory.

    In case you want to have a common absolute base for images, you can also set the :imagesdir: attribute to the base url of your images directory. This should then also work with live previews: