Skip to content

feat: add an opt-in HTTP(S) autolink extension - #20

Draft
silouanwright wants to merge 3 commits into
TanStack:mainfrom
silouanwright:codex/markdown-autolinks
Draft

feat: add an opt-in HTTP(S) autolink extension#20
silouanwright wants to merge 3 commits into
TanStack:mainfrom
silouanwright:codex/markdown-autolinks

Conversation

@silouanwright

@silouanwright silouanwright commented Sep 12, 2026

Copy link
Copy Markdown

Problem

TanStack Markdown does not currently autolink bare HTTP(S) URLs. For example, See https://example.com/docs displays the URL as plain text. Authors must use explicit Markdown link syntax to make it clickable.

Applications rendering comments, messages, and documents often need pasted URLs to become links automatically. This PR makes that behavior available as an opt-in extension, since automatic URL linking is outside the current core profile.

URL recognition also needs to preserve the characters in the address. For https://example.com/~alice~/notes, the current parser turns alice into strikethrough. The extension should instead produce one clickable URL with both tildes intact. This is why it uses the source-level hook from #19: a transform over finished inline nodes runs after that formatting has already happened.

Proposed solution

Add autolinksExtension() through @tanstack/markdown/extensions/autolinks, using the inline parser API proposed in #19.

The extension recognizes bare http:// and https:// URLs, plus angle-bracket notation such as <https://example.com>. It preserves URL spelling, leaves sentence punctuation outside bare links, and handles balanced parentheses, brackets, and braces. It respects escapes, code, and explicit link labels, applies the existing application URL policy, and produces ordinary link nodes for HTML, React, and Octane.

Core rendering and the docs preset keep their existing defaults. The initial scope covers HTTP(S); www. addresses, email detection, other schemes, entity decoding, and full CommonMark/GFM autolink conformance are excluded. Malformed HTTP(S) candidates are consumed as literal text to avoid repeatedly scanning their suffixes. Recognition stays within the enclosing inline container.

Dependency, size, and validation

This draft depends on #19 and currently includes its prerequisite commit. The extension is isolated in commit 90796de: review the extension-only diff.

The separate extension entry is 632 bytes gzip (994 minified; 568 Brotli). All 22 existing measured import shapes retain their sizes relative to #19. It adds no further core parser or renderer code and no runtime dependency. The revision-comparison script now reports newly introduced package entries separately.

pnpm run verify passes with 309 tests, including 45 autolink cases, plus typecheck, build, documentation and shipped-skill checks, conformance, size/benchmark reports, and package dry run. Tests cover renderer parity, URL policies, serialized ASTs, and malformed input. All 403 established CommonMark matches remain unchanged with the extension disabled. Reproducible Node benchmarks are in reports/autolinks.md; browser performance is unmeasured. Includes a minor changeset.

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@silouanwright
silouanwright force-pushed the codex/markdown-autolinks branch from 09fa135 to 90796de Compare September 12, 2026 17:13
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