Skip to content

fix: decode URI-encoded local link paths - #29

Open
andyhrc wants to merge 1 commit into
Neilooo:mainfrom
andyhrc:fix/unicode-local-links
Open

fix: decode URI-encoded local link paths#29
andyhrc wants to merge 1 commit into
Neilooo:mainfrom
andyhrc:fix/unicode-local-links

Conversation

@andyhrc

@andyhrc andyhrc commented Sep 3, 2026

Copy link
Copy Markdown

Summary

  • Decode URI-encoded local paths before resolving them against the current Markdown file
  • Apply the same path handling to internal document links and local images
  • Preserve malformed URI escapes from raw HTML instead of aborting link rewriting

Problem

MarkdownIt percent-encodes non-ASCII link destinations. For example, ./目录/中文文件.md#中文标题 is rendered with %E7... path segments. The existing code joined those encoded segments directly into the filesystem path, so readTextFile looked for a literal percent-encoded filename and navigation failed.

The fragment is split before decoding, so encoded heading IDs keep their existing behavior.

Validation

  • pnpm lint
  • pnpm build
  • Manually verified encoded Chinese directories and filenames resolve to their Unicode filesystem paths
  • Manually verified escaped spaces/filename characters and malformed % sequences

Decode MarkdownIt's URI escaping before resolving local links and images, while preserving malformed raw HTML URLs.
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