-
Notifications
You must be signed in to change notification settings - Fork 326
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
Quarto images don't display in preview when using absolute path #7329
Comments
This is not a bug. |
Thanks! I'll update rstudio/rstudio/issues/12690 to reflect that this is by design. |
I see this is closed and merged as part of pull #13838, but I don't understand the logic behind applying this rule when the Quarto document is not part of a project. Using a leading slash has a long standing meaning: absolute path; and having to make symlinks or something in order to put figures at the same level as the Quarto document (even within a project, honestly) seems surprising to me. |
@cswingle Sorry I don't understand what you are referring to. It seems you are referencing things that are not in Quarto. One of the goals of Quarto is to have reproducible documents/projects. Paths outside the "project" is clearly a reproducibility breaker. FYI: A Quarto document is treated as a project since 1.5. |
@mcanouil Understood re Quarto docs being their own “project”. I was surprised by this new behavior when rendering a document with 1.5 that worked fine under 1.4, and the idea that an absolute path would be changed to be relative to the Quarto document seems to break with long standing Unix tradition. Thanks for your reply and clarification. |
Your comment seems to imply a few inaccurate things. Just to be clear, this is behavior that we've used since Quarto 1.0, as @mcanouil pointed out in the documentation. as far as "Unix tradition is concerned": note two things:
I promise you we're aware of Unix traditions. I would like to suggest that you might not be taking all the considerations we did into account, and to keep that in mind in the future. Thanks! |
@cscheid Using Quarto 1.4, a figure path that starts with a slash is treated as an absolute filesystem path and a single-file Quarto document renders successfully to PDF. In 1.5, a dot is prepended to the path to make the path relative to the location of the quarto document and TeX cannot find the file. I do understand the rationale for this, but it is a recent change and was a surprise to me. I expect it might be a surprise to others that are used to a leading slash (or drive letter in Windows) meaning "root" in a different sense than "root of the project or document". It sounds like this is a decided issue and the definition of paths and their meaning in the context of Quarto isn't going to change. Fair enough. I meant no disrespect, I was merely trying to explain why this behavior was a surprise to me. |
That's the 1.4 behavior for single-file renders. In projects that already wasn't the case, and that was not only for "book" projects. It was also the case for default and website projects.
Understood. We should have done a better job at documenting the change. We made the behavior more uniform; "default" and "website" projects already behaved in this way; now single-file renders also do.
That's correct; it's how Quarto "always" behaved and intended to behave, aside from this (admittedly popular) "corner" case. I'll also note that this isn't just a Quarto behavior: other typesetting systems work the same way. Consider typst. Quarto supports emitting Typst code, but here you can see the pure-Typst behavior: |
@cscheid I believe this is not the case anymore since 1.5. My understanding of what @cswingle is reporting is that for single file project render the behavior has changed. Quick example of this is ---
title: test
format: html
embed-resources: true
---
Some content
![](/tmp/elephant.png) I am using And with image from our website cd /tmp
curl -O https://quarto.org/docs/authoring/elephant.png
cd Single doc not in a project. Calling
I believe this behavior is due to the fact Single file render has now since 1.5 some concept of single file project. And so it inherits this behavior from project. I thought this was expected change, but reading you I am unsure, so I preferred to share in case we should open an issue about that. |
I meant in 1.4; edited now to clarify. |
All good then ! Thanks for the clarification - I was also in doubt 😅 |
Bug description
Quarto images don't display in preview when using absolute path. The absolute path is being treat as relative to the local directory.
Steps to reproduce
This can all be done in RStudio, but I'm leaving it out because the behavior is with Quarto. Discovered while working on RStudio issue rstudio/rstudio/issues/12690.
quarto create project
as a default and with the namequarto_image
cd quarto_image
mkdir images
somepath.png
in theimages
directory.Quarto_image.qmd
to contain the followingbut change the second image reference to the image file's absolute page.
quarto preview Quarto_image.qmd
Expected behavior
Both images get displayed.
Actual behavior
When the web page is opened:
- The image with the relative path is displayed.
- The image with the broken path is broken.
Looking at the generated page's source, the absolute path is getting set as relative to the local directory.
In the terminal in which Quarto is running:
Your environment
Quarto 1.4.429
R 4.3.1
MacOS 14.1
RStudio Desktop Pro 2023.12.0-daily+221.pro12 (but reproduced outside of RStudio)
Quarto check output
The text was updated successfully, but these errors were encountered: