Search code examples
imagemarkupasciidoc

images in various locations in included Asciidoc files


I have an AsciiDoc structure like this:

  • Documentation.adoc
    • DeveloperDocumentation/DeveloperDocumentation.adoc
    • DeveloperDocumentation/DeveloperDocumentationPart1.adoc
    • UserDocumentation/UserDocumentation.adoc

And this content:

in Documentation.adoc:

include::DeveloperDocumentation/DeveloperDocumentation.adoc
include::UserDocumentation/UserDocumentation.adoc

in DeveloperDocumentation/DeveloperDocumentation.adoc:

include::DeveloperDocumentationPart1.adoc

in DeveloperDocumentation/DeveloperDocumentationPart1.adoc (also in 'DeveloperDocumentation' directory):

image::devScreenshot.png[]

My problem: the image is displayed in the rendered DeveloperDocumentationPart1.adoc and DeveloperDocumentation.adoc, but not in the Documentation.adoc.

I am aware that the Documentation.doc cannot find the image as the image path is not correct in relation to the Documentation.doc.
So I tried to solve it with the :imagesdir: attribute but I cannot get it to work. And I cannot set one fixed image directory path, anyways, because not all images will be in one directory.

I read the docs but I could not find a working solution for imagesdir:

AsciiDoc: Set the Images Directory
AsciiDoc: Image Paths and Formats

Help would be appreciated :-)


Solution

  • I was able to solve by changing the imagesdir attribute before the respective include:

    in Documentation.adoc:

    :imagesdir: DeveloperDocumentation
    
    include::DeveloperDocumentation/DeveloperDocumentation.adoc
    
    :imagesdir: UserDocumentation
    
    include::UserDocumentation/UserDocumentation.adoc
    

    The docs don't mention this anywhere, but it works...