Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include-files sub file can not use URL image? #194

Open
ajeep8 opened this issue Nov 1, 2021 · 3 comments
Open

include-files sub file can not use URL image? #194

ajeep8 opened this issue Nov 1, 2021 · 3 comments

Comments

@ajeep8
Copy link

ajeep8 commented Nov 1, 2021

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
Copy link
Author

ajeep8 commented Nov 1, 2021

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

@ajeep8
Copy link
Author

ajeep8 commented Nov 1, 2021

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,

@alerque
Copy link
Collaborator

alerque commented Jan 6, 2022

Did you ever figure this out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants