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

Strange behaviour while accessing images on local file system #8260

Closed
dreamos82 opened this issue Aug 30, 2022 · 4 comments
Closed

Strange behaviour while accessing images on local file system #8260

dreamos82 opened this issue Aug 30, 2022 · 4 comments
Labels

Comments

@dreamos82
Copy link

I have the following scenario:

  • ProjectFolder/
    • /Images/
      • img.png
      • img2.png
    • Folder2
      • File.md

Now in Folder2\File.md i have:

text
[My shiny image](/Images/img.png)
other text
[My shiny image 2](/Images/img2.png)

It has to be absolute because the files are stored on a github repository and there the path is relative to the current directory.
They are rendered as expected on github, but i'm aware that using pandoc the working dir is the main directory, not the file directory (and i'm compiling many markdown files when generating the single pdf)

But it fails to open them when i use pandoc (because with pandoc the path should be relative to the ProjectFolder). I read about the --resource-path option of pandoc and it looked the solution to my issue:

List of paths to search for images and other resources.

So i tried to use it with the following command:

pandoc --toc --top-level-division=chapter -f markdown -t pdf README.md  ...othermarkdownfile....  pandoc.yaml -o notes.pdf --pdf-engine=pdflatex -N --resource-path=./

And i got the following error:

pandoc: /Images/taskssequence.png: openBinaryFile: does not exist (No such file or directory)

Note that the images are 2, and i got the error only for one. But the most interesting thing is that both images are present in the final pdf. So i'm confused they should or shouldn't be present?.

I think that using an absolute path in the markdown it is actually searching in the Root folder of my hard disk. But i wonder if there is a way to express an absolute path, forcing pandoc to consider the project directory as its root.

Pandoc version?
2.9.2.1

@dreamos82 dreamos82 added the bug label Aug 30, 2022
@jgm
Copy link
Owner

jgm commented Aug 30, 2022

I think that using an absolute path in the markdown it is actually searching in the Root folder of my hard disk

Correct.

But i wonder if there is a way to express an absolute path, forcing pandoc to consider the project directory as its root.

Not that I can think of. But perhaps you could use relative paths after all? If your content is below the images directory, could you use something like ../../images/picture.jpg? And then when you use pandoc, use -f markdown+rebase_relative_paths so that the paths will be computed from the file's directory and not the working directory?

@dreamos82
Copy link
Author

Using Unknown extension: rebase_relative_paths i get the following error:

Unknown extension: rebase_relative_paths

@jgm
Copy link
Owner

jgm commented Aug 30, 2022

Your pandoc version may be too old.

@tarleb
Copy link
Collaborator

tarleb commented Sep 4, 2022

Closing in favor of #8272, which is essentially the same issue.

@tarleb tarleb closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants