Description
Exporting to styled HTML or PDF drops relative images () when the document's folder name contains #, ? or %, for example C# notes/note.md. The editor shows the image (fixed in #5302), but the exported file does not.
resolveLocalImageSrc (packages/desktop/src/renderer/src/util/resolveImageSrc.ts) joins the raw window.DIRNAME into a file:// URL. Chromium reads everything after # as a fragment and everything after ? as a query, and decodes a literal %xx in the folder name, so the exported <img> points at a file that doesn't exist. The PDF path goes through the same function (the exporter rewrites the src first, and printService leaves an existing file:// src alone).
#5320 fixed the same problem for exported links (resolveLinkHref.ts); it left images out because #4789 was touching resolveImageSrc.ts.
Measured on develop @ b267efb8 (macOS, built app, File › Export) with note.md containing  next to a 1×1 assets/cat.png:
| Document folder |
Styled HTML <img src> |
Image in Chrome |
Image in PDF |
plain-dir/ |
file://…/plain-dir/assets/cat.png |
loads |
the 1×1 image |
C# 100%25 what?/ |
file://…/C# 100%25 what?/assets/cat.png |
broken |
Chromium's broken-image icon |
Steps to Reproduce
- Create a folder named
C# notes with an assets subfolder, and save any PNG in it as assets/cat.png.
- In
C# notes, create note.md containing .
- Open
note.md in MarkText and use File › Export › HTML (or PDF).
- Open the exported file.
Expected Behavior
The image shows in the exported document, as it does when the folder is named notes.
Actual Behavior
The exported HTML shows a broken image, and the PDF contains the broken-image icon.
Operating System
macOS
MarkText Version
develop @ b267efb8
OS Version
macOS 27.0
Reproducibility
Description
Exporting to styled HTML or PDF drops relative images (
) when the document's folder name contains#,?or%, for exampleC# notes/note.md. The editor shows the image (fixed in #5302), but the exported file does not.resolveLocalImageSrc(packages/desktop/src/renderer/src/util/resolveImageSrc.ts) joins the rawwindow.DIRNAMEinto afile://URL. Chromium reads everything after#as a fragment and everything after?as a query, and decodes a literal%xxin the folder name, so the exported<img>points at a file that doesn't exist. The PDF path goes through the same function (the exporter rewrites the src first, andprintServiceleaves an existingfile://src alone).#5320 fixed the same problem for exported links (
resolveLinkHref.ts); it left images out because #4789 was touchingresolveImageSrc.ts.Measured on
develop@b267efb8(macOS, built app, File › Export) withnote.mdcontainingnext to a 1×1assets/cat.png:<img src>plain-dir/file://…/plain-dir/assets/cat.pngC# 100%25 what?/file://…/C# 100%25 what?/assets/cat.pngSteps to Reproduce
C# noteswith anassetssubfolder, and save any PNG in it asassets/cat.png.C# notes, createnote.mdcontaining.note.mdin MarkText and use File › Export › HTML (or PDF).Expected Behavior
The image shows in the exported document, as it does when the folder is named
notes.Actual Behavior
The exported HTML shows a broken image, and the PDF contains the broken-image icon.
Operating System
macOS
MarkText Version
develop@b267efb8OS Version
macOS 27.0
Reproducibility