-
Notifications
You must be signed in to change notification settings - Fork 262
feat(core): add MarkdownRenderable with automatic table alignment #433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…kdown types to react and solid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a new MarkdownRenderable component that extends the rendering capabilities of OpenTUI with markdown-specific features. The implementation uses the marked library to parse markdown and renders tables with automatic column sizing through a BoxRenderable-based layout system.
Key changes:
- Introduces
MarkdownRenderableclass with support for tables, code blocks, headings, lists, blockquotes, and inline formatting - Implements a conceal mode that hides markdown formatting markers (e.g.,
**,*,`) while preserving styled text - Adds comprehensive test coverage with 32 test cases covering various markdown features
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/renderables/Markdown.ts | New MarkdownRenderable implementation with table rendering, inline formatting, and concealment logic |
| packages/core/src/renderables/tests/Markdown.test.ts | Comprehensive test suite covering tables, formatting, code blocks, and conceal modes |
| packages/core/src/renderables/index.ts | Exports the new Markdown renderable |
| packages/core/src/examples/markdown-demo.ts | Interactive demo showcasing markdown features with theme switching |
| packages/react/src/types/components.ts | TypeScript types for React MarkdownRenderable component |
| packages/solid/src/types/elements.ts | TypeScript types for Solid MarkdownRenderable component |
| packages/core/package.json | Adds marked@^17.0.1 dependency |
| bun.lock | Lock file updates for marked dependency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Uhh looks good! I need to work through that. |
|
It currently does not support streaming markdown properly. I can look into that. It needs an |
Show only complete rows (N-1) during streaming to avoid partial row flicker. Rebuild tables only when complete row count changes, not on every cell update.
|
I updated table rendering to show a row at a time during streaming, this should improve performance (because right now tables rerender fully each time) and looks less janky |
|
Cool, that works better. It does not support updating itself when |
|
with full table border joins you mean not overlapping border right? should be an easy fix with custom borders |
|
That works. Switching the theme in the demo blocks the main thread for ~1s. Is that |
|
Tried rerendering instead of recreating the renderable and got a bit worse. But I cannot reproduce the 1 second freeze. For me it freezes only 300ms or less |
Instead of immediately rebuilding all blocks when syntaxStyle or conceal changes, mark dirty and defer work to renderSelf(). This follows the same pattern as CodeRenderable and avoids redundant work. Key improvements measured via CPU profiling: - textBufferSetStyledText: 113ms → 67ms (↓41%) - updateLayout: 99ms → 17ms (↓83%) - render: 160ms → 63ms (↓61%) - Total profile time: 3091ms → 2886ms (↓7%)
|
Added a performance fix for theme/conceal switching. Problem: When Fix: Now we defer the work to CPU profiling results (theme switch in the demo):
Estimated theme switch latency: ~100-150ms (down from ~300ms) |
|
I can only check that tomorrow, not allowed to touch the keyboard today. Happy holidays! |
|
Merry Christmas! |
|
I made it update the tables in-place instead of recreating all elements, which is somewhat better. I found that when streaming a lot of markdown (endless mode in the demo), it becomes slower and slower. Seems like something is resetting the I wonder if there is a better way to render tables, without relying on yoga layout, as for large tables it would be quite a lot of nested nodes. |
|
Thank you for fixing the reset. I think using Yoga is completely fine. I noticed no lags rendering a lot of tables in opencode with the markdown renderable. |
Screen.Recording.2025-12-29.at.11.32.01.movCheck the "Overall" render time in the stats, it should be low and stable, but it increases the more content is being streamed. In the markdown demo when I set stream speed to fastest and shift+E for endless stream (which can be stopped with shift+X again). |
|
Adding a cache for |



MarkdownRenderablethat extendsCodeRenderablewith markdown-specific featuresmarkedto parse markdown and automatically align table columns based on content widthTables are rendered via flexbox boxes: