fix(docs): normalize image paths for markdown-it-image-size on Windows - #23047
Open
dogledogle wants to merge 1 commit into
Open
fix(docs): normalize image paths for markdown-it-image-size on Windows#23047dogledogle wants to merge 1 commit into
dogledogle wants to merge 1 commit into
Conversation
Contributor
Author
|
Latest update: The PR submitted to the upstream repository has been merged and is now awaiting release. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What is this PR solving?
On Windows, starting the Vite documentation site produces
markdown-it-image-sizewarnings for relative images such as../images/v3-docs.webp.VitePress provides
env.pathwith Windows path separators (\), whilemarkdown-it-image-sizeexpects/when determining the Markdown file's directory. The plugin therefore resolves relative images from the wrong directory and fails to add theirwidthandheightattributes.This PR normalizes
env.pathbefore passing it to the image renderer. The normalization is scoped tomarkdown-it-image-sizeand does not mutate the shared Markdown environment.Related issues
None.
Alternatives considered
Fixing
markdown-it-image-sizeupstream. I plan to submit an upstream PR to address the underlying issue. Until an upstream fix is released, this PR provides a scoped workaround for Vite contributors using Windows. I will continue tracking the upstream issue and submit a follow-up PR to remove this workaround once the fix is available.