getpelican / pelican-plugins

Collection of plugins for the Pelican static site generator
Other
1.38k stars 849 forks source link

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

Open Carniv0re opened 6 years ago

Carniv0re commented 6 years ago

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

mdko commented 6 years ago

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.

devidw commented 3 years ago

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[]
patrickdung commented 3 years ago

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.

devidw commented 3 years ago

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

patrickdung commented 3 years ago

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.

podsvirov commented 2 years ago

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.