Handle encoded image paths in markdown #11310
Merged
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.
Changes
fix #11291
The markdown vfile
data.imagePaths
now contains decoded paths instead of possibly-encoded paths. I'm not sure if this is ideal/intentional for the option itself, but this top-level change helps align all downstream usage:astro/packages/astro/src/vite-plugin-markdown/images.ts
Lines 6 to 8 in 93d068a
rehypeImageToComponent
currently compares with decoded paths, the generated imports are also decoded:astro/packages/integrations/mdx/src/rehype-images-to-component.ts
Lines 84 to 86 in 93d068a
rehype-images
is also comparing with decoded paths:astro/packages/markdown/remark/src/rehype-images.ts
Lines 14 to 16 in 93d068a
astro/packages/astro/src/vite-plugin-markdown/images.ts
Lines 12 to 20 in 93d068a
So with the above discoveries, I made this PR change instead of keeping
imagePaths
encoded only.Testing
Added new tests
Docs
n/a. bug fix.