mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 13:06:00 +03:00
[PR #568] [MERGED] feat(core): Add highlighting callback for custom inline highlighting #1402
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#1402
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/568
Author: @jettptacek
Created: 1/21/2026
Status: ✅ Merged
Merged: 1/24/2026
Merged by: @kommander
Base:
main← Head:main📝 Commits (4)
330f744feat(core): Add highlighting callback for custom inline highlightinged41889Merge branch 'main' into main118f36etest(core) add CodeRenderable OnHighlight tests80e8b9bMerge branch 'main' into main📊 Changes
2 files changed (+269 additions, -3 deletions)
View changed files
📝
packages/core/src/renderables/Code.test.ts(+221 -0)📝
packages/core/src/renderables/Code.ts(+48 -3)📄 Description
Adds an
onHighlightcallback toCodeRenderablethat allows post-processing of syntax highlights before they're rendered. This enables custom inline highlightingChanges
onHighlightoption toCodeRenderablethat receives tree-sitter highlights and can modify themHighlightContextinterface providing access to content, filetype, and syntaxStyleUsage
Solves
I have an open pr in opencode https://github.com/anomalyco/opencode/pull/9016 to close https://github.com/anomalyco/opencode/issues/2586 but my pr monkey patches
treeSitterClient.highlightOnceto get that feature working and this onHighlight callback change would allow a cleaner implementation of https://github.com/anomalyco/opencode/issues/2586 and/or other custom highlight featuresExamples
I made 2 examples using this feature that I can add to the pull request as well. If it's wanted.
https://github.com/user-attachments/assets/6f41d59c-a5ea-4e9b-b398-43bc4b9914e8
https://github.com/user-attachments/assets/f0aeb59a-5b19-4fd2-948e-e1a2e80d7b1f
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.