Skip to content

fix: emit autolink content verbatim without escapes#77

Open
SAY-5 wants to merge 4 commits into
syntax-tree:mainfrom
SAY-5:fix-autolink-backslash-doubling
Open

fix: emit autolink content verbatim without escapes#77
SAY-5 wants to merge 4 commits into
syntax-tree:mainfrom
SAY-5:fix-autolink-backslash-doubling

Conversation

@SAY-5

@SAY-5 SAY-5 commented May 12, 2026

Copy link
Copy Markdown

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything or linked relevant results below
  • I made sure the docs are up to date
  • I included tests (or that’s not needed)

Description of changes

Autolink content is interpreted literally per CommonMark, so the serializer no longer routes it through phrasing escaping, which was doubling backslashes (and escaping other characters) in the URL on round-trip. Closes #73.

@github-actions github-actions Bot added the 👋 phase/new Post is being triaged automatically label May 12, 2026
@github-actions

This comment has been minimized.

@SAY-5

SAY-5 commented May 12, 2026

Copy link
Copy Markdown
Author

The CI failure looks unrelated to this change: c8 (via yargs) throws ReferenceError: require is not defined on Node 26, and the Node 18 job reports # fail 0 before the matrix is cancelled. Tests pass locally with npm run test-api.

@github-actions github-actions Bot added 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels May 12, 2026
SAY-5 added 3 commits May 26, 2026 20:21
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@wooorm

wooorm commented Jun 9, 2026

Copy link
Copy Markdown
Member

Hi! Did you see the code around it? e.g.:

  if (formatLinkAsAutolink(node, state)) {
    // Hide the fact that we’re in phrasing, because escapes don’t work.
    const stack = state.stack
    state.stack = []

Can you explain what you ran into?

@wooorm wooorm added the 🙉 open/needs-info This needs some more info label Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Hi! Thanks for taking the time to contribute! This has been marked by a maintainer as needing more info. It’s not clear yet whether this is an issue. Here are a couple tips:

  • Spend time framing the pull request! The more time you put into it, the more we will
  • Often, maintainers respond with why for several back and forths; rubber duck debugging might help avoid that
  • Folks posting issues sometimes fall for xy problems: asking for a certain solution instead of raising the root problem

Thanks,
— bb

@SAY-5

SAY-5 commented Jun 9, 2026

Copy link
Copy Markdown
Author

Yes, the stack clearing handles the unsafe patterns, since those are filtered through patternInScope. What it doesn't cover is escapeBackslashes() at the bottom of lib/util/safe.js, which runs unconditionally and doubles a backslash that sits before ASCII punctuation (here the closing > passed as config.after). So on main, fromMarkdown('aa:\\') gives a link whose text is 'aa:\', and toMarkdown emits 'aa:\\\\'; that round-trip is what the added test covers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🙉 open/needs-info This needs some more info 🤞 phase/open Post is being triaged manually

Development

Successfully merging this pull request may close these issues.

Autolink URL backslashes are doubled on stringify

2 participants