Skip to content

fix: #5714 restore Windows image paths in PDF export - #5716

Merged
Jocs merged 1 commit into
developfrom
fix/5714-export-windows-image-paths
Oct 12, 2026
Merged

Jocs merged 1 commit into
developfrom
fix/5714-export-windows-image-paths

Conversation

@Jocs

@Jocs Jocs commented Oct 12, 2026

Copy link
Copy Markdown
Member

Closes #5714

Summary

A local image such as ![](assets\image.png) 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.png to file:///docs/assets/90ddb94aced7dd9421a1dc67e76a83c9f0a77378.png.

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • New tests added: the issue's Markdown through the real export renderer; encoded Windows drive/UNC paths; preservation of encoded separators in remote URLs.
  • 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 %5C URL above.
  • pnpm run lint — passed with existing warnings (0 errors).
  • pnpm run typecheck — passed.
  • Manually tested on Windows: no Windows runtime was available for automated validation. The requester independently reproduced the failure using supplied local-image fixtures; their platform was not recorded.

Notes for reviewers

Source-history inspection traces the missing normalization to the desktop migration to @muyajs/core in #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.

@github-actions

Copy link
Copy Markdown
Contributor

Build artifacts for PR #5716:

Run: https://github.com/marktext/marktext/actions/runs/38217213702

Artifact Size Link
marktext-windows-arm64 288.6 MB Download
marktext-linux 661.1 MB Download
marktext-windows-x64 296.7 MB Download
marktext-macos-x64 311.1 MB Download
marktext-macos-arm64 297.8 MB Download

@Jocs
Jocs merged commit df87904 into develop Oct 12, 2026
12 checks passed
@Jocs
Jocs deleted the fix/5714-export-windows-image-paths branch October 12, 2026 08:00
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.
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.

[Bug] PDF导出图片问题,编辑器可显示,导出PDF没有图片

1 participant