pelican-plugins icon indicating copy to clipboard operation
pelican-plugins copied to clipboard

[AsciiDoc] How can I add a picture with a relative path to the created webpage?

Open Carniv0re opened this issue 7 years ago • 6 comments

I've checked the documentation and it tells me to use a path like this: {filename}/images/example.jpg So with AsciiDoc, I tried referencing the image like this: image::{filename}/images/schoolkids.jpg[] but all it does is print out the line of code as text. What am I doing wrong?

Best Regards, Diego

Carniv0re avatar Jul 17 '18 10:07 Carniv0re

I was having the same problem and fixed it by removing one of the colons to make it "inline", i.e. image:{filename}/images/schoolkids.jpg[]. Maybe it's a parsing issue with the asciidoc_reader plugin.

mdko avatar Aug 20 '18 10:08 mdko

With Pelican 4.5.4 using {attach} like image::{attach}relative/path/to/image.webp[] works for me. Note that there is no slash between the closing curly bracket and the beginning of the path.

You can also achieve the same result by specifying an imagesdir. Then you only have to set the filename later on:

:imagesdir: {attach}relative/path/to/image/folder

image::image.webp[]

devidw avatar Jan 30 '21 16:01 devidw

Would it be possible that the {attach} or {filename} are processed by AsciiDoctor instead of Pelican? I could not get it working and tried the methods mentioned in the previous comments.

patrickdung avatar May 28 '21 14:05 patrickdung

I could not get it working and tried the methods mentioned in the previous comments.

@patrickdung When you have the following file structure

└── image.png
└── test.adoc

and contents inside test.adoc

= Test

:date: 2021-05-30

image::{attach}image.png[]

you should get a working output

image


Tested with Pelican Version 4.5.4 and asciidoc_reader plugin from #1337

devidw avatar May 30 '21 17:05 devidw

I am using the latest version of asciidoc_reader and head of Pelican (as of yesterday) After using DEBUG=1 for the make command, it is found that it is using asciidoc instead of asciidoctor. I had specified ASCIIDOC_CMD = '/usr/bin/asciidoctor' in pelicanconf.py but it still choose asciidoc.

It is found that if asciidoc is used, it can get the pygments working but {attach} would not work. If asciidoctor is used, {attach} works but pygments is not working (Fedora does not provide pygments.rb rpm).

asciidoc was installed because the rpm package vim-syntastic-asciidoc.noarch depends on it.

Edit: OK, I found that I should be using ASCIIDOC_CMD = 'asciidoctor' instead of using the path to the binary for it, so now {attach} works. Thanks.

patrickdung avatar May 30 '21 18:05 patrickdung

Since asciidoc v10.0.1 you can use backslash to attach files:

image::\{attach}image.png[]

It's work for links too.

For more info see https://github.com/asciidoc-py/asciidoc-py/issues/200.

podsvirov avatar Nov 03 '21 16:11 podsvirov