feat: support custom scheme autolinks via autolinkSchemes#214
Closed
maccman wants to merge 1 commit into
Closed
Conversation
GFM's autolink only recognizes `www.` / `http(s)://` / email / `mailto:` / `xmpp:` forms, so custom app schemes like `reflect://today` stay plain text. Add a creation-time `autolinkSchemes: string[]` editor option (and matching `@meowdown/react` prop) that registers a `SchemeAutolink` lezer inline parser for each configured scheme, with the same boundary and trailing-punctuation rules as the bare-domain autolink. It emits the shared `URL` node, so the existing mark walk renders and click-handles it like any other autolink, and the markdown source round-trips unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@maccman is attempting to deploy a commit to the ocavue's projects Team on Vercel. A member of the Team first needs to authorize it. |
commit: |
Collaborator
Author
|
We decided to scrap this one |
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
Typing a bare custom-scheme URL like
reflect://todaystays plain text: lezer's GFM autolink only matcheswww./http(s):/// emails /mailto:/xmpp:, so app schemes never linkify the wayhttps://…does.Changes
schemeAutolinklezer inline parser (packages/core/src/lezer/scheme-autolink.ts), modeled on the existingbareAutolink: matches<scheme>://<rest>for each configured scheme (case-insensitive), applies the same before-boundary rule and the trailing-punctuation trimming ported from @lezer/markdown, and emits the sharedURLnode so the existing mark walk renders it like any other autolink (getAutolinkHrefalready returns scheme URLs as-is). Scheme names are validated against the RFC 3986 grammar at configuration time.autolinkSchemes: string[](default: none), threadeddefineEditorExtension→defineInlineMarkPlugin→inlineTextToMarkChunks→parseInline, which now picks a per-scheme-list configured parser (cached, one per distinct list; only inline parsing is extended, soLEZER_NODE_IDSstays valid).FileLinkOptions→InlineParseOptions: the threaded options interface now carries bothresolveFileLinkandautolinkSchemes, matching its existing "host options that influence inline parsing" doc. (FileLinkResolveris unchanged.)autolinkSchemesprop on@meowdown/react'sMeowdownEditor/ProseKitEditor, read once on mount likeresolveFileLink.Tests
lezer/scheme-autolink.test.ts: detection (start/whitespace/paren boundaries, path+query+fragment, uppercase scheme, multiple schemes), rejection (unconfigured scheme, default parse, empty rest, mid-word, prefix scheme), trailing-punctuation trimming, coexistence with GFM/bare-domain autolinks and inline code/link labels, and config-time scheme validation.extensions/autolink.test.ts: browser-mode rendering —reflect://todayrenders as a link with the righthrefwhen configured, stays plain text by default.converters/roundtrip.test.ts: a custom-scheme URL round-trips byte-identical (it's plain text in the source).Full suite (1218 tests),
tsc -b, eslint, oxfmt, and knip all pass.Notes
Downstream, Reflect will pass
autolinkSchemes={['reflect']}once this ships in a release.🤖 Generated with Claude Code