Skip to content

fix(docs): normalize image paths for markdown-it-image-size on Windows - #23047

Open
dogledogle wants to merge 1 commit into
vitejs:mainfrom
dogledogle:fix-markdown-it-image-size-windows-path
Open

fix(docs): normalize image paths for markdown-it-image-size on Windows#23047
dogledogle wants to merge 1 commit into
vitejs:mainfrom
dogledogle:fix-markdown-it-image-size-windows-path

Conversation

@dogledogle

Copy link
Copy Markdown
Contributor

What is this PR solving?

On Windows, starting the Vite documentation site produces markdown-it-image-size warnings for relative images such as
../images/v3-docs.webp.

image

VitePress provides env.path with Windows path separators (\), while markdown-it-image-size expects / when determining the Markdown file's directory. The plugin therefore resolves relative images from the wrong directory and fails to add their width and height attributes.

This PR normalizes env.path before passing it to the image renderer. The normalization is scoped to markdown-it-image-size and does not mutate the shared Markdown environment.

Related issues

None.

Alternatives considered

Fixing markdown-it-image-size upstream. 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.

@dogledogle

Copy link
Copy Markdown
Contributor Author

Latest update: The PR submitted to the upstream repository has been merged and is now awaiting release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant