Skip to content

Fix escaped character in links - #19849

Merged
fisker merged 9 commits into
prettier:mainfrom
Kjubikstronk:fix-markdown-character-reference-escaping
Aug 18, 2026
Merged

fisker merged 9 commits into
prettier:mainfrom
Kjubikstronk:fix-markdown-character-reference-escaping

Conversation

@Kjubikstronk

@Kjubikstronk Kjubikstronk commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #19588.

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.
  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

@netlify

netlify Bot commented Aug 14, 2026

Copy link
Copy Markdown

✅ Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 59e9fec
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/6a7f0db2df6b6c00081ecd0a
😎 Deploy Preview https://deploy-preview-19849--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for prettier ready!

Name Link
🔨 Latest commit 7e3f0f1
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/6a84de2bb954cd000955669f
😎 Deploy Preview https://deploy-preview-19849--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@fisker

fisker commented Aug 18, 2026

Copy link
Copy Markdown
Member

The changes looks good, can you fix the conflicts?

Kjubikstronk and others added 4 commits August 18, 2026 12:43
The parser resolves character references in destinations and titles, so
printing the resolved value lets it resolve a second time: `&quot\;` in a
link URL became `"` on the first pass and `"` on the second. That
changes the document on the first format, not only on reformat.

Escaping the `&` keeps the text literal. Destinations like `?a=1&b=2` are
left alone, since they cannot resolve.
@Kjubikstronk
Kjubikstronk force-pushed the fix-markdown-character-reference-escaping branch from 4bcc3f6 to 52740bd Compare August 18, 2026 10:44
@Kjubikstronk

Copy link
Copy Markdown
Contributor Author

Rebased. #19482 rewrote printUrl and printTitle in the meantime, so the escape now runs after the backslash handling in both — if it runs before, the backslash it adds gets doubled and the reference resolves anyway. Your two commits are on top, unchanged.

Markdown suite is green (1487 tests, 1476 snapshots). The full suite shows the same 15 failing suites on my machine with or without this branch, so nothing here is from the rebase.

@pkg-pr-new

pkg-pr-new Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

yarn add https://pkg.pr.new/@prettier/[email protected]
yarn add https://pkg.pr.new/@prettier/[email protected]
yarn add https://pkg.pr.new/@prettier/[email protected]
yarn add https://pkg.pr.new/[email protected]

commit: 7e3f0f1

Comment thread tests/format/markdown/link/entity.md Resolved
@fisker fisker changed the title Print character references in link destinations as literal text Fix escaped character in links Aug 18, 2026
@fisker
fisker merged commit 518eb6a into prettier:main Aug 18, 2026
35 checks passed
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.

Idempotency bug in escaped semicolon in Markdown link

2 participants