[PR #784] fix(markdown): harden code block fallback and info parsing #1558

Open
opened 2026-03-14 09:43:18 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/784
Author: @ryanfreckleton
Created: 3/6/2026
Status: 🔄 Open

Base: mainHead: fix-markdown-codeblock-style-clean


📝 Commits (3)

  • e84f8e5 fix(markdown): harden code block fallback and info parsing
  • b30915f Merge branch 'main' into fix-markdown-codeblock-style-clean
  • 076cc56 Merge branch 'main' into fix-markdown-codeblock-style-clean

📊 Changes

4 files changed (+373 additions, -7 deletions)

View changed files

📝 packages/core/src/renderables/Code.test.ts (+63 -0)
📝 packages/core/src/renderables/Code.ts (+57 -5)
📝 packages/core/src/renderables/Markdown.ts (+73 -2)
📝 packages/core/src/renderables/__tests__/Markdown.test.ts (+180 -0)

📄 Description

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

  • The readability invariant belongs in CodeRenderable, not MarkdownRenderable, so all call sites (markdown and standalone) inherit safe defaults.
  • This matches how Rich, Glamour, and syntect/bat treat default style ownership.

Scope

  • CodeRenderable now derives baseline fg/bg/attributes from syntaxStyle["default"] when those props are omitted (and reapplies on syntaxStyle change without overriding explicit caller values).
  • MarkdownRenderable now normalizes fence language info as first token + lowercase + extToFiletype alias mapping (for example, BASH title=... -> shell, ToMl -> toml).

Validation

  • Manual: verified in the linked OpenCode worktree (~/src/opencode-opentui-test) that unknown-language fences remain readable on light themes.
  • Automated: bun test packages/core/src/renderables/Code.test.ts packages/core/src/renderables/__tests__/Markdown.test.ts

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/784 **Author:** [@ryanfreckleton](https://github.com/ryanfreckleton) **Created:** 3/6/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-markdown-codeblock-style-clean` --- ### 📝 Commits (3) - [`e84f8e5`](https://github.com/anomalyco/opentui/commit/e84f8e5ee2bcaf9d39e5d9d5f41333e3706b4417) fix(markdown): harden code block fallback and info parsing - [`b30915f`](https://github.com/anomalyco/opentui/commit/b30915f536694da3a3d288834ca0ef0ff8122cce) Merge branch 'main' into fix-markdown-codeblock-style-clean - [`076cc56`](https://github.com/anomalyco/opentui/commit/076cc56cdaaf71d7af2b01da5cac5708e198eeaf) Merge branch 'main' into fix-markdown-codeblock-style-clean ### 📊 Changes **4 files changed** (+373 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/renderables/Code.test.ts` (+63 -0) 📝 `packages/core/src/renderables/Code.ts` (+57 -5) 📝 `packages/core/src/renderables/Markdown.ts` (+73 -2) 📝 `packages/core/src/renderables/__tests__/Markdown.test.ts` (+180 -0) </details> ### 📄 Description 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 - The readability invariant belongs in `CodeRenderable`, not `MarkdownRenderable`, so all call sites (markdown and standalone) inherit safe defaults. - This matches how Rich, Glamour, and syntect/bat treat default style ownership. ## Scope - `CodeRenderable` now derives baseline `fg`/`bg`/`attributes` from `syntaxStyle["default"]` when those props are omitted (and reapplies on `syntaxStyle` change without overriding explicit caller values). - `MarkdownRenderable` now normalizes fence language info as `first token + lowercase + extToFiletype alias mapping` (for example, `BASH title=...` -> `shell`, `ToMl` -> `toml`). ## Validation - Manual: verified in the linked OpenCode worktree (`~/src/opencode-opentui-test`) that unknown-language fences remain readable on light themes. - Automated: `bun test packages/core/src/renderables/Code.test.ts packages/core/src/renderables/__tests__/Markdown.test.ts` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#1558
No description provided.