feat: add an opt-in HTTP(S) autolink extension - #20
Draft
silouanwright wants to merge 3 commits into
Draft
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
silouanwright
force-pushed
the
codex/markdown-autolinks
branch
from
September 12, 2026 17:13
09fa135 to
90796de
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TanStack Markdown does not currently autolink bare HTTP(S) URLs. For example,
See https://example.com/docsdisplays 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 turnsaliceinto 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://andhttps://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 verifypasses 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 inreports/autolinks.md; browser performance is unmeasured. Includes a minor changeset.