Repository navigation
fix: #5714 restore Windows image paths in PDF export - #5716
Merged
Merged
Conversation
This was referenced Oct 13, 2026
Zane-0x5a
added a commit
to Zane-0x5a/marktext
that referenced
this pull request
Oct 15, 2026
Upstream reworked the old print path (marktext#5722 makes MarkdownPrint wait for the notation fonts; marktext#5716 resolves URL-encoded Windows image paths). The fork replaced that path with the paged preview, so printService and its two specs keep the fork's side. Both fixes still reach the preview: the image fix lives in resolveLocalImageSrc, which exportHtml uses, and the notation fonts arrive through the muya export styles, the export themes and getCssForOptions. Main already waits for fonts.ready under print media before printToPDF. marktext#5746 drops the Info tab and explains that a table of contents needs a [TOC] line. The HTML export dialog takes both changes. The print preview panel shows the same explanation under its contents settings. The preload keeps the fork's visual zoom limit next to upstream's platform path import, and the editor store keeps isSameList. marktext#5691 was merged earlier from its PR head; upstream's squash differs from it only by commits that came in alongside it. Verified on Windows 11: typecheck, desktop and muya lint, and the desktop unit suite pass. In the muya unit suite, only the tableChessboard entrypoint import timed out, and only on cold runs (it passes alone). The print, export, sidebar, theme and title bar e2e specs plus upstream's new 3510, 5394, 5683 and 5710 specs pass in background windows, except 5394's exact `toBe(400)` width check. At this machine's 1.75 device pixel ratio the restored width reads 400.0000305, with or without the camera transform; with `toBeCloseTo(400, 3)` all three scenarios pass.
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.
Closes #5714
Summary
A local image such as
renders in the editor but disappears from PDF export. The editor normalizes Windows separators before loading the image, while the export renderer URL-encodes the backslash as%5C. The local-image resolver then treats that encoding as part of the filename and generates an incorrect file URL.Normalize URL-encoded backslashes in recognized local image paths before resolving them. This repairs the shared PDF, print, and styled-HTML export path, including encoded drive and UNC paths. Remote URLs retain their existing encoding.
For the issue's sample, the generated URL changes from
file:///docs/assets%5C90ddb94aced7dd9421a1dc67e76a83c9f0a77378.pngtofile:///docs/assets/90ddb94aced7dd9421a1dc67e76a83c9f0a77378.png.Type of change
Test plan
pnpm -C packages/desktop exec vitest run test/unit/specs/exportHtml.spec.ts test/unit/specs/printService-image.spec.ts— 36 tests passed. The Markdown regression failed before the fix with the%5CURL above.pnpm run lint— passed with existing warnings (0 errors).pnpm run typecheck— passed.Notes for reviewers
Source-history inspection traces the missing normalization to the desktop migration to
@muyajs/corein #4406. The 0.19.1 legacy image renderer normalized backslashes before URL encoding; the new export pipeline does not. The migration is already included in the 0.20.0 tag. Historical release binaries were not tested.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.