mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 04:55:58 +03:00
[PR #737] [CLOSED] feat(tree-sitter): detect URL scopes and set link property on text chunks #746
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#746
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/anomalyco/opentui/pull/737
Author: @mugnimaestra
Created: 2/24/2026
Status: ❌ Closed
Base:
main← Head:feat/tree-sitter-link-detection📝 Commits (1)
cc986aefeat(tree-sitter): detect URL scopes and set link property on text chunks📊 Changes
2 files changed (+150 additions, -0 deletions)
View changed files
📝
packages/core/src/lib/tree-sitter-styled-text.test.ts(+120 -0)📝
packages/core/src/lib/tree-sitter-styled-text.ts(+30 -0)📄 Description
Summary
When tree-sitter highlights markdown content via the
<code filetype="markdown">rendering path, URL-bearing text chunks never receive alinkproperty, so OSC 8 hyperlink sequences are never emitted. This causes terminals to fall back on visual URL auto-detection, which breaks when URLs wrap across lines.Changes
packages/core/src/lib/tree-sitter-styled-text.tsAdded URL detection to
treeSitterToTextChunks():Pre-scan phase (lines 51-68): Builds a
Map<number, string>mapping highlight indices to URLs. Scans formarkup.link.urlandstring.special.urlscopes, extracts the URL text, and also maps associatedmarkup.link.labelhighlights (found by walking backwards pastmarkup.linkbracket highlights) to the same URL.Chunk creation (lines 204-227): After merging styles, checks if any active highlight has a URL mapping. If so, sets
link: { url }on the chunk.This enables:
https://example.com) → clickable OSC 8 hyperlinkClick herein[Click here](url)) → also clickable, linking to the same URLstring.special.url→ also clickablepackages/core/src/lib/tree-sitter-styled-text.test.tsAdded 5 new tests in a
"Link detection"describe block:markup.link.urlchunks getlinkproperty ✅markup.link.labelchunks get associated URL ✅string.special.urlchunks getlinkproperty ✅link✅Test Results
All 49 tests pass (44 existing + 5 new).
Related
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.