fix: preserve Unicode whitespace in inline link destinations #4249
@hakarrr is attempting to deploy a commit to the MarkedJS Team on Vercel.
A member of the Team first needs to authorize it.
[vc]: #qBDfuIlWFMn6gi7SDUZepzo3+ZrKX5yUUlN7SjJWwUY=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJtYXJrZWQtd2Vic2l0ZSIsInByb2plY3RJZCI6InByal9RbnhOam0wSDI0YlVHQWI1MWIxUnVaa25ReXlZIiwidjAiOmZhbHNlLCJyb290RGlyZWN0b3J5IjpudWxsLCJpbnNwZWN0b3JVcmwiOiJodHRwczovL3ZlcmNlbC5jb20vbWFya2VkanMvbWFya2VkLXdlYnNpdGUvOHN3a1BGSGtKbndNRnRDbjVpNmFLRHpQaUM4ZyIsInByZXZpZXdVcmwiOiJtYXJrZWQtd2Vic2l0ZS1naXQtZm9yay1oYWthcnJyLWZpeC1pbmxpbmUtbGluay1mMjVhM2MtbWFya2VkanMudmVyY2VsLmFwcCIsIm5leHRDb21taXRTdGF0dXMiOiJERVBMT1lFRCIsImxpdmVGZWVkYmFjayI6eyJyZXNvbHZlZCI6MCwidW5yZXNvbHZlZCI6MCwidG90YWwiOjAsImxpbmsiOiJtYXJrZWQtd2Vic2l0ZS1naXQtZm9yay1oYWthcnJyLWZpeC1pbmxpbmUtbGluay1mMjVhM2MtbWFya2VkanMudmVyY2VsLmFwcCJ9fV0sInJlcXVlc3RSZXZpZXdVcmwiOiJodHRwczovL3ZlcmNlbC5jb20vdmVyY2VsLWFnZW50L3JlcXVlc3QtcmV2aWV3P293bmVyPW1hcmtlZGpzJnJlcG89bWFya2VkJnByPTQyNDkifQ==
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Actions | Updated |
| :--- | :----- | :------ | :------ |
| <a href="https://vercel.com/markedjs/marked-website"><sup><img src="https://vercel.com/api/www/avatar?projectId=prj_QnxNjm0H24bUGAb51b1RuZknQyyY&teamId=team_RpARALaqy6bNW7b6MI363ieY&s=32" width="16" height="16" align="middle" alt="" /></sup></a> marked-website | !Ready Ready | Preview | <relative-time datetime="2026-11-25T15:53:06.342Z">Nov 25, 2026 3:53pm UTC</relative-time> |
<a href="https://vercel.com/vercel-agent/request-review?owner=markedjs&repo=marked&pr=4249" rel="noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://agents-vade-review.vercel.sh/request-review-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://agents-vade-review.vercel.sh/request-review-light.svg"><img src="https://agents-vade-review.vercel.sh/request-review-light.svg" alt="Request Review"></picture></a>
Use .md & .html files for tests in test/specs/new and remove unit tests
One of the tests is different than commonmark. We should fix it or remove it from the tests.
[x]( /url )
This PR&options=%7B%0A%20%22async%22%3A%20false%2C%0A%20%22breaks%22%3A%20false%2C%0A%20%22extensions%22%3A%20null%2C%0A%20%22gfm%22%3A%20true%2C%0A%20%22hooks%22%3A%20null%2C%0A%20%22pedantic%22%3A%20false%2C%0A%20%22silent%22%3A%20false%2C%0A%20%22tokenizer%22%3A%20null%2C%0A%20%22walkTokens%22%3A%20null%0A%7D&version=master)
CommonMark&options=%7B%0A%20%22async%22%3A%20false%2C%0A%20%22breaks%22%3A%20false%2C%0A%20%22extensions%22%3A%20null%2C%0A%20%22gfm%22%3A%20true%2C%0A%20%22hooks%22%3A%20null%2C%0A%20%22pedantic%22%3A%20false%2C%0A%20%22silent%22%3A%20false%2C%0A%20%22tokenizer%22%3A%20null%2C%0A%20%22walkTokens%22%3A%20null%0A%7D&version=commonmark)
Removed the ASCII-tab case you identified and its expected output in 3941e8c and 52eefe9. The Unicode destination cases are unchanged, and there are no production changes in this revision. The separate ASCII-tab parser mismatch is not fixed by this PR.
The published fixture files match the locally tested revision: npm test passed with 2,039 specs and 256 unit tests, followed by npm run build:reset. These are local results, not a claim that hosted CI is green.
Thanks! 💯
Approved these changes.
UziTech
hakarrr
Marked version: master (c6b22e89)
Markdown flavor: CommonMark / GFM
Description
Non-ASCII whitespace at either end of an unbracketed inline link destination is removed. For example, when the spaces below are U+00A0,
[x]( /url )currently links to/urlrather than%C2%A0/url%C2%A0. Images lose those destination characters too. The same characters already survive inside angle-bracket destinations.Marked master demo / CommonMark demo
The modern link regex already separates ASCII space, tab and newline gaps from the captured destination. The final
href.trim()then removes characters that belong to that destination. This change keeps that trim in pedantic mode only. It leaves the regex, angle validation, title handling and parenthesis consumption unchanged. The destination definition in CommonMark 0.31.2 excludes ASCII controls and space, not all Unicode whitespace.This follows the destination/gap distinction in merged #4106. Open #4237 changes raw-token length calculation when a destination has extra closing parentheses; this PR does not change that calculation or resolve its cases.
Committed default-GFM fixtures assert exact rendered output for eight non-ASCII whitespace characters at the leading edge, trailing edge and both edges, for links and images. ASCII gaps, angle destinations and titles remain rendering controls, with a separate pedantic fixture checking unchanged trimming. CommonMark and GFM behavior was separately validated locally; identical mode copies are not committed. The lexer href/raw identity tests were removed at review, not replaced with equivalent API coverage.
Validation
npm test: passed, including 2,039 spec entries, 256 unit tests, UMD, CJS, types and lint.npm run build:reset: passed afterward.Those local comparisons decode entities and collapse whitespace, so they are not full conformance checks. The exact fixtures protect the encoded destination bytes in rendered links and images. At the maintainer's request, paired Markdown/HTML fixtures replace generated cases and unit tests; raw token identity assertions were removed. ASCII-gap, title, angle-destination and pedantic controls remain as fixtures. Existing malformed-angle, entity and parenthesis-consumption gaps remain outside this change.
Contributor
Committer
Revision validation: no production source changes in the fixture migration. Hosted CI for the revision is not yet verified. AI assistance was used; the change and local results were independently reviewed before publication.
The committed fixtures avoid duplicate mode copies where these cases use shared grammar. Both modern modes were also checked locally before deduplication.