How to structure image paths in ascidoctor? - asciidoc

I have a book with the following directory structure
book.adoc
chapters/chapter1.adoc
chapters/chapter2.adoc
chapters/chapter3.adoc
images/img1.jpg
images/img2.jpg
in book.adoc I include the chapters. The problem is that in each chapter I include images from the images directory. If I use a path relative to book.adoc then the images render when I generate the PDF of the entire book, but not when I generate a PDF of an individual chapter.
This is particularly annoying when working on a chapter and the HTML preview does not show the images.
Is there a way to specify the paths so it works in both cases? Is the only way to move the chapters up a directory?

Yes. Your documents can specify the imagesdir attribute. See the documentation.
If you specify imagesdir as a relative path, such as ./images, then you can have chapter-specific image folders that should allow your full and chapter-specific builds to work, as well as make the HTML preview work.

Related

Prevent MyST from changing .md image paths

I'm generating sphinx documentation with.md files that reference images via relative paths:
![](../_static/figures/image.png)
I use MyST to parse the .md files into html, but it removes the ../' making all paths:
_static/figures/image.png.
The relative paths work fine before documentation generation and has to kept the same.
In the conf.py for sphinx I copy over the images as html_static_path files, and if the path is kept the same in the html, the images would show.
The MyST docs state that it copies .md images but give no configuration options for copying. The paragraphs below only reference how to parse HTML files with images. I did find another option that should treat all links as hyperlinks, but this made no change.
How do I force MyST to not change the image paths?
I think it is more of a convention question.
It is recommended to put _static in all folder levels and separate assets like images inside each of them, so that links like _static/figures/image.png resolve to just that folder level.
If you want to use a single top level _static folder for all folder levels, then your links should be written as /_static/figures/image.png, where they are resolved to the top level.

Relative and absolute paths issue using the include directive

I have the following sphinx directory structure for my project.
/applications
/app1
Content.rst
/app2
Content.rst
/components
/component1
Content.rst
/figures
Figure1.png
/component2
Content.rst
/figures
Figure1.png
For each reuseable UI software component I have a separate directory including some screenshots of the UI in figures. Every component has some figures, which makes directories easily moveable and re-namable, by using image directives using relative paths.
Furthermore, I have applications for our end user clients. But not every component is used in every application.
Now a problem with relative and absolute paths occurred. Assume that applications/app1/Content.rst contains somewhere:
.. include:: components/component1/Content.rst
Furthermore assume that components/component1/Content.rst contains somewhere:
.. image:: figures/Figure1.png
Now the file rst file of component1 is found an included in my documents, but the images of component1 are not included in the document.
Python Sphinx prints:
WARNING: image file not readable: figures/Figure1.png
Seemingly there is an issue with relative paths here, that I couldn't solve after trying for hours. I even still wonder what is the present working directory while processing components/component1/Content.rst.
I also want to avoid absolute paths in the Content.rst of the components if possible.
Any help for my problem is highly appreciated.
Review
If I change the image line to:
.. image:: components/component1/figures/Figure1.png
The image is displayed, but now I have a serious problem if I need to move or to rename my component.
But now I have another problem: In case someone wanted to include components/component1/Content.rst in the index.rst via the toctree:: command. Then the images are looked at components/component1/components/component1/figures/Figure1.png, which is wrong again.

Link to relative files in Asciidoc

I'm writing a document using asciidoc and asciidoctor. So, I'm having a intro.adoc file and then bunch of section files. So, what I want to do is list them on to intro.adoc and add hyperlinks to them so that it will be easy to navigate.
For this I can think of two approaches:
First, I can use headers and associate a relative link to .adoc files in the same directory. So, that they will redirect to them. But I don't know how to achieve it. link: == section1.adoc[Section 1] is not working.
Second, using include::section1.adoc[]. Its working but its not a hyperlink.
What is wrong with it? or is there a easy way to do it.
Edit
If its not clear, I'm trying to achieve this # [Section1](section.md)(Markdown version) in asciidoc.
What about:
<<section1.adoc#Section1,your link>>
See:
https://docs.asciidoctor.org/asciidoc/latest/macros/inter-document-xref/

How to go up one directory using Markdown

Within the markdown document, what is the proper syntax to go up one directory and then choose the file? It will be rendered online, so would html ../ be appropriate to put in the markdown syntax?
such as [some_description]andthen(../file_name.md)
I had to add the "and then" to get it to show up on stack....
Links work the same way in Markdown as they do in HTML. A relative path would work the same way.
[I'm a relative reference to a repository file](../blob/master/LICENSE)
which is from here: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links

Magmi is cannot find multiple images

I've Googled, and Stackoverflowed this to death (and checked the Wiki), but I can't find a solution to my problem :(
Problem:
With Magento Magmi: all products and single images are importing fine, the only catch is that Magmi throws the following error when I try to import multiple images (e.g. /BJ977L.png,/BJ977R.png):
Image attributes processor v1.0.25 - /BJ977L.png,/BJ977R.png cannot be found in images path
Obviously I checked and the files are there... Also, if I change it to only reference one image, then it works. I find this very confusing.
The images are located in: media/import and the Magmi Image Plugin configuration reflects this. Also, if I move the images to another folder, say var/import/images; then it makes no difference...
Your help is hugely appreciated!
Thanks in advance!
As the Images Attribute Processor documentation states, you should be using a semi-colon ; to separate multiple images.
/extraimg1.jpg;/extraimg2.jpg
Also ensure that the column names you are using are correct. media_gallery is the correct column header name for the media gallery images.
Have you tried using semi colon?
/BJ977L.png;/BJ977R.png
Have you tried using the complete file path to the images? Also, did you specify the file path root for the images in the plugin settings?
If you have formatted the .csv file the right way then you should check the Image Renaming setting for the Image attributes processor. If you specify a bad rule to rename your newly imported images you could end up with the same name for every picture. So basically the first image will be imported, then the second will overwrite it because it was given the same name. If you only see the last picture you specified for the media_gallery attribute then this is probably the cause.
Hope this helps.

Resources