lua-filters icon indicating copy to clipboard operation
lua-filters copied to clipboard

include-files sub file can not use URL image?

Open ajeep8 opened this issue 3 years ago • 3 comments

main.md

This is main.md

```{.include}
sub.md
```

sub.md

This is sub.md

![remote image](https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg)

![local image](Markdown-mark.svg)

pandoc -L include-files.lua sub.md -o sub.pdf

It's OK.


pandoc -L include-files main.md -o main.pdf

[WARNING] Could not fetch resource https:/upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg: InvalidUrlException "https:/upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg" "URL must be absolute" Replacing image with description.

the local image is OK, but the remote image not.

ajeep8 avatar Nov 01 '21 06:11 ajeep8

https:/upload one '/' less, why?

ajeep8 avatar Nov 01 '21 07:11 ajeep8

I think it's because consider URL as relative path

    -- If image paths are relative then prepend include file path
    Image = function (image)
      if (string.sub(image.src,1,7) ~= "http://") and (string.sub(image.src,1,8) ~= "https://") then
        if path.is_relative(image.src) then
          image.src = path.normalize(path.join({include_path, image.src}))
        end
      end
      return image
    end,

ajeep8 avatar Nov 01 '21 08:11 ajeep8

Did you ever figure this out?

alerque avatar Jan 06 '22 10:01 alerque