feat(opencode): enhanced markdown renderer with tables, themes, and syntax highlighting #8077
+1,472
−15
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.



Related Issues
Tables & Formatting:
Summary
Comprehensive markdown rendering overhaul for both CLI and TUI with proper table support, theme integration, syntax highlighting, and unified rendering architecture.
Key Features
📊 Table Rendering
🎨 Theme Support
💻 Syntax Highlighting
🎯 Advanced Formatting
strikethrough🏗️ Architecture
🔧 Smart Behavior
Technical Details
Files Changed
Key Functions
Rendering Flow
CLI:
```
User config → loadTheme() → MarkdownTheme
Markdown → renderMarkdownThemedStyled() → TextChunks
TextChunks → textChunksToAnsi() → ANSI string → stdout
```
TUI:
```
User config → Theme context → MarkdownTheme
Markdown → parseMarkdownSegments() → [text, code, text, code]
Text segments → renderMarkdownThemedStyled() → StyledText →
Code segments → tree-sitter →
```
Examples
Before/After: Tables
Before:
```
| Header | Value |
| A | B |
```
After:
```
┌────────┬───────┐
│ Header │ Value │
├────────┼───────┤
│ A │ B │
└────────┴───────┘
```
Theme Colors
All colors match user's selected theme:
Testing
✅ CLI output verified with multiple themes
✅ TUI rendering stable during streaming
✅ Tables with complex content (inline code, word wrap, unicode)
✅ Escaped pipes (\|) for union types
✅ Double-width characters (emoji, CJK)
✅ TTY detection (piped vs interactive)
✅ All 12+ built-in themes load correctly
Breaking Changes
None - backward compatible. Existing markdown rendering continues to work.
Performance
Migration Notes
No migration needed. The feature is automatically available in both CLI and TUI.
Commits
22 commits with iterative improvements: