feat(opencode): enhanced markdown renderer with tables, themes, and syntax highlighting#1
Open
feat(opencode): enhanced markdown renderer with tables, themes, and syntax highlighting#1
Conversation
580b630 to
9cfe157
Compare
9cfe157 to
969dc48
Compare
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
927acf8 to
f419b65
Compare
…yntax highlighting Custom markdown renderer that works alongside upstream's experimental markdown flag: - When OPENCODE_EXPERIMENTAL_MARKDOWN is ON: uses upstream's <markdown> element - When OFF (default): uses custom hybrid renderer with Prose/CodeBlock components Features: - Box-drawing table rendering with cell word wrap and unicode-aware widths - Tree-sitter syntax highlighting for code blocks via native <code> element - Task list checkbox rendering - Strikethrough support - Header background panels for h1/h2 - Diff code block coloring (+/- lines) - CLI markdown rendering via UI.markdown() with theme support - Theme loader supporting all 33 upstream themes
Adds control panel option to render markdown in user messages: - Default: agent messages only (existing behavior) - Toggle: Ctrl+P -> Render markdown: all messages - Persisted via KV store (markdown_all_messages) - Respects OPENCODE_EXPERIMENTAL_MARKDOWN flag
…bles Inline markdown (backticks, links, strikethrough) nested inside bold or italic markers was rendered as raw text. For example, table cells like **HTTP `/tools/list`** would show literal backticks instead of styled code spans. Replace hardcoded single-nesting checks (bold-inside-italic, italic-inside-bold) with recursive renderInlineThemedWithDefault calls that process all inline markdown within bold/italic/bold-italic content. Recursive calls inherit parent attrs via bitwise OR to preserve combined styling (e.g. italic inside bold retains bold+italic). Also update table header rendering to use renderCell with inline markdown processing instead of dumping raw text as a single bold chunk. Additional fixes identified via code review: - Add truncation in renderCell when rendered content exceeds column width, preventing table border misalignment on narrow terminals - Propagate defaultAttrs to inline code, links, and strikethrough so they inherit outer bold/italic styling when nested
The 'Render markdown: all messages' toggle was under the Session category in the command palette. Move it to the System category alongside other app-wide toggles (animations, diff wrapping) since markdown rendering preference is a global setting, not session-specific.
4521827 to
2813c6d
Compare
4 tasks
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.
Summary
Custom markdown renderer that works alongside upstream's experimental markdown flag. When
OPENCODE_EXPERIMENTAL_MARKDOWNis set, upstream's<markdown>element is used unchanged. When unset (default), a hybrid renderer provides enhanced markdown formatting with proper table rendering, tree-sitter syntax highlighting, and theme support.Single commit, additive only - no upstream code removed or modified beyond minimal integration points.
Features
<code>element- [x]/- [ ])~~text~~)UI.markdown()with theme supportFiles Changed
cli/markdown-renderer.tscli/theme-loader.tscli/cmd/tui/routes/session/index.tsxTextPart,Prose,CodeBlock,MarkdownDiffcomponentscli/cmd/run.tscli/ui.tsUI.markdown()now calls custom renderer with theme supportTotal: 5 files, 1552 additions, 15 deletions
Architecture
The renderer integrates with upstream's existing
OPENCODE_EXPERIMENTAL_MARKDOWNflag:CLI mode (
opencode run):Table Rendering
Related Issues