Skip to content

White text in fenced code blocks: missing parser aliases (sh, yml, py, jsonc) cause fallback to hardcoded #ffffff #17323

Description

@gpid007

Bug

Fenced code blocks using common language aliases like ```sh, ```yml, ```py, ```jsonc render as pure white text (#ffffff), making them illegible.

Root Cause

Two issues combine to produce this:

1. Missing language alias mappings in parsers-config.ts

The bash parser is registered as "bash", but when markdown content uses ```sh, the system looks for a parser named "sh" — which doesn't exist. Same for yml (registered as yaml), py (registered as python), and jsonc (registered as json).

The built-in infoStringMap in @opentui/core only maps js→javascript, ts→typescript, md→markdown. There are no aliases for sh→bash, yml→yaml, py→python, etc.

2. Hardcoded white fallback in @opentui/core

When the parser lookup fails, CodeRenderable falls back to plain text rendering using _defaultFg = RGBA(1, 1, 1, 1) (pure white #ffffff). The MarkdownRenderable.createCodeRenderable method does not pass a fg prop, so the theme's text color is never used as a fallback.

This only affects the <markdown> rendering path (experimental markdown / OPENCODE_EXPERIMENTAL_MARKDOWN). The <code filetype="markdown"> path is not affected because it uses tree-sitter's markup.raw.block scope.

Suggested Fix

Quick fix (opencode side): Add parser aliases in parsers-config.ts

Register duplicate entries pointing to the same wasm/queries:

Alias Points to Rationale
sh bash Most common shell alias
shell bash Common alias
zsh bash Close enough for highlighting
py python Common shorthand
jsonc json Used in many config files
yml yaml Very common alias

Proper fix (opentui side): Two changes

  1. Pass theme foreground to child code renderables — In MarkdownRenderable.createCodeRenderable, pass the default syntax style foreground as the fg option so the fallback is theme.text instead of hardcoded white.

  2. Expand infoStringMap — Add common language aliases so the parser lookup succeeds for standard markdown code fence tags.

Reproduction

  1. Use any theme (solarized, opencode, gruvbox, etc.)
  2. Have the assistant respond with a ```sh fenced code block
  3. The code block content renders as white text

Environment

  • OpenCode v1.2.10
  • WSL2 (Ubuntu) with Windows Terminal
  • Any theme — the white fallback bypasses all theme colors

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions