Skip to content

feat(tui): highlight hex codes with the color#9016

Closed
jettptacek wants to merge 1 commit intoanomalyco:devfrom
jettptacek:dev
Closed

feat(tui): highlight hex codes with the color#9016
jettptacek wants to merge 1 commit intoanomalyco:devfrom
jettptacek:dev

Conversation

@jettptacek
Copy link

@jettptacek jettptacek commented Jan 17, 2026

What does this PR do?

Highlights hex color codes in markdown content with their actual color as the background. The foreground text automatically switches between black and white based on luminance for readability.
Supports:

  • 3-char (#rgb)
  • 4-char (#rgba)
  • 6-char (#rrggbb)
  • 8-char with alpha (#rrggbbaa)
    Colors with alpha are blended against the theme background, and update correctly when switching themes.

Closes #2586

How did you verify your code works?

Manual verification in Wezterm and Powershell on Windows

opencode_colorcode.mp4

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@jettptacek
Copy link
Author

jettptacek commented Jan 18, 2026

This feature probably benefits from being configurable. I don't know if that is what people want though. I could see this being part of a set of non-theme colorization options that users could set what they want

Also, I'm monkey patching treeSitterClient.highlightOnce to even get this to work. I think an improvement to OpenTUI might be required for a cleaner approach

@jettptacek
Copy link
Author

jettptacek commented Jan 21, 2026

I created a pull request for opentui anomalyco/opentui#568 so I can change this implementation to use a callback feature instead of monkey patching treeSitterClient.highlightOnce

Here's my little opentui example

ColorCodeExample.mp4

@jettptacek jettptacek closed this Jan 24, 2026
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.

feat: highlight hex codes with the color

1 participant