-
Notifications
You must be signed in to change notification settings - Fork 337
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
Retain forward slashes in HTML img src paths #2811
Merged
jayhesselberth
merged 4 commits into
r-lib:main
from
Andrew0Hill:fix_forward_slash_in_img_src
Nov 8, 2024
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
04a03da
Fixes issue where forward slashes are encoded in HTML img src paths
Andrew0Hill c019e26
Test that slashes in image src attributes are handled correctly
Andrew0Hill 8d2b45d
Added call to path_real to ensure input image path is not relative.
Andrew0Hill 20b22b6
Added a comment with summary of temporary pkgdown directory discussion.
Andrew0Hill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you've changed only
tweak_rmarkdown_html()
, it would be better if the test could more explicitly check just that function — i.e. you don't need to set up an entire placeholder site, you can just passhtml
totweak_rmarkdown_html()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing.
I originally tried something similar to what you suggest, but I found that the path conversion portion of
tweak_rmarkdown_html()
makes two calls tofs::path_real()
(lines 51 and 52), which will fail if the path referenced does not exist on the filesystem.This means that whatever path is provided in the test HTML also needs to physically exist on the filesystem for the path conversion portion of the call to
tweak_rmarkdown_html()
to work properly. For this reason, I added the placeholder site with image, so that the paths referenced in the test HTML will exist, and the calls tofs::path_real()
will succeed.In the other existing test for
tweak_rmarkdown_html()
(line 112 intest_tweak_page.R
) the test HTML doesn't contain any<img/>
tags, so the path resolution code never runs (and therefore that test does not run into the same issue with the calls tofs::path_real()
).The only other way I could think of avoiding the placeholder package would be to set the img src in the test HTML to an image path that we know exists in the repository (like
test_path("assets/kitten.jpg")
, and then having it resolve the path relative totest_path()
(untested idea below):I went with the method in my current commit though since the above version would fail if the
assets/kitten.jpg
file ever moved. (The version with the placeholder package still refers to this resource, but indirectly throughpkg_add_kitten()
)I'm happy to take another shot at this if you have any other suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed explanation! In that case it sounds like you have written the minimal test, and I'd just suggest briefly summarising this discussion as a comment.