fix(markdown): harden code block fallback and info parsing#784
Open
ryanfreckleton wants to merge 3 commits intoanomalyco:mainfrom
Open
fix(markdown): harden code block fallback and info parsing#784ryanfreckleton wants to merge 3 commits intoanomalyco:mainfrom
ryanfreckleton wants to merge 3 commits intoanomalyco:mainfrom
Conversation
CodeRenderable now owns its own fg/bg fallback: it reads the `default` style entry from its syntaxStyle theme and applies it as baseline colors and attributes at construction and whenever syntaxStyle changes. This means any code block automatically renders legibly on light themes (e.g. Solarized Light) without requiring the parent container to pass explicit fg/bg values. Also hardens startHighlight against a temporarily-undefined syntaxStyle during streaming, and normalises fenced code info strings in MarkdownRenderable (first token, lowercase, alias map) so that ```BASH, ```TypeScript, etc. resolve to correct tree-sitter grammars. Tests cover: unknown-language fallback colors, missing-syntaxStyle robustness, case-insensitive alias/info-string normalisation.
@opentui/core
@opentui/react
@opentui/solid
@opentui/core-darwin-arm64
@opentui/core-darwin-x64
@opentui/core-linux-arm64
@opentui/core-linux-x64
@opentui/core-win32-arm64
@opentui/core-win32-x64
commit: |
|
+1 for the alias fix (ts -> typescript) |
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.
Downstream: OpenCode
In OpenCode, fenced code blocks with unknown/unsupported languages are illegible on light terminal themes (for example, Solarized Light) because fallback plain-text rendering had no guaranteed base fg/bg.
Why here
CodeRenderable, notMarkdownRenderable, so all call sites (markdown and standalone) inherit safe defaults.Scope
CodeRenderablenow derives baselinefg/bg/attributesfromsyntaxStyle["default"]when those props are omitted (and reapplies onsyntaxStylechange without overriding explicit caller values).MarkdownRenderablenow normalizes fence language info asfirst token + lowercase + extToFiletype alias mapping(for example,BASH title=...->shell,ToMl->toml).Validation
~/src/opencode-opentui-test) that unknown-language fences remain readable on light themes.bun test packages/core/src/renderables/Code.test.ts packages/core/src/renderables/__tests__/Markdown.test.ts