Re: Chrome Asciidoctor.js plugin environment variables

Posted by mojavelinux on
URL: https://discuss.asciidoctor.org/include-and-imagesdir-in-different-folders-tp8154p8159.html

> Am I missing something, do you have a solution for that?

Including a file does not change the current directory. You have to think of includes as all the files being combined together and then the result being converted. So they are flat. (Only the include targets themselves are relative to the parent document).

So you would either need to

a) modify the imagesdir in different places in the document, or
b) use a shared image folder with topic folders that mirror the folders you are using for the documents.

I prefer (b). You structure might look like this:

index.adoc
topic-a/
  doc.adoc
topic-b/
  doc.adoc
images/
  topic-a/
    image-for-topic-a-doc.png
  topic-b/
    image-for-topic-b-doc.png

Then, in topic-a/doc.adoc, the image reference would be:

image::topic-a/image-for-topic-a-doc.png[]

At the top of the file, you could define an attribute like:

:topic: topic-a

then reference the image as:

image::{topic}/image-for-topic-a-doc.png[]

or change imagesdir like:

:imagesdir: images/topic-a

then reference the image as:

image::image-for-topic-a-doc.png[]

There are lots of possible solutions. But they all come down to storing the images under a separate hierarchy.

Best Regards,

-Dan

On Sun, Aug 9, 2020 at 4:01 AM yo [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Yes, I would prefer to keep it portable, however, as I said, I use some include. And the asciidoctor.js processes can not resolve them when they are not in the same folder.

Example of file system:
file1.ad
test/file2.ad


file1.ad
Bla bla
include test/file2.ad

test/file2.ad
:imagesdir: ../../src/img/

Bla bla bla
image::test.png[Test]

Then, the image will render for test/file2.ad but it won't for file1.ad as, I guess, it stays in the same path and the :imagesdir: ../../src/img/ then doesn't work.

Am I missing something, do you have a solution for that?


If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Chrome-Asciidoctor-js-plugin-environment-variables-tp8154p8158.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux