First question (quick fix): how can i actually insert image by absolute path on windows? Doesn't work:
image::c:/image1.png[]
image::C:/image1.png[]
image::c:\image1.png[]
image::C:\image1.png[]
Second question (real problem): I'm trying to set my project folder, something like this:
C:\
asciidoctor-project\
images\
windows\
123123.png
122112.png
...
img1.png
img2.png
...
content\
preface.adoc
section1\
1.adoc
2.adoc
...
subsection1.1\
1.1.adoc
...
section2\
3.adoc
...
main.adoc
settings.adoc
In
settings.adoc i set all needed options, and then just include it on top of
main.adoc. Then i include all other files from
content\ folder(s). Imagesdir is also set in
settings.adoc, and everything is actually working great, output files are generated with images etc.
The problem is this: what i need is be able to generate valid output from any
.adoc in
content\folder, not only from
main.adoc. Plus, i'm using VSCode with asciidoctor extension which allows to preview document, and images preview will work only if image path is correct in previewed file.
I add include of
settings.adoc in all files in
content\folder. This resolves the problem for everything, except images. When converter sees directive
:imagesdir: ./images
in
preface.adoc it looks for
C:\asciidoctor-project\content\images, not for a correct path
C:\asciidoctor-project\images.
Now, i was able to produce partial decision: in
settings.adoc i added lines:
// images folder
ifndef::main-file[]
:imagesdir: ../images
endif::main-file[]
ifdef::main-file[]
:imagesdir: ./images
endif::main-file[]
And on first line of
main.adoc i added:
:main-file: true
Now it does work, but only for
preface.adoc. Because for
section1\1.adoc images directory have to be set to "
../../images", for
section1\subsection1.1\1.1.adoc it have to be "
../../../images" etc.
Maybe somebody can propose some way to do that?
I'm trying to do something with absolute path to images directory, but for some reason can't even include single image by it's absolute path...