Repository navigation
feat: add code block renderers to EnrichedMarkdownText - #1070
Open
eszlamczyk wants to merge 1 commit into
Open
eszlamczyk wants to merge 1 commit into
eszlamczyk wants to merge 1 commit into
Conversation
eszlamczyk
force-pushed
the
feat/code-renderers-js
branch
from
October 23, 2026 08:41
850f615 to
4277599
Compare
`renderers.code` replaces code blocks with React elements, either one function
for every block or `{ default, languages }`. A language entry's regex `pattern`
is matched against the fence language and the longest matching pattern wins,
then `default`, then the native code block. The picked renderer is final: a
language renderer returning undefined keeps the native block. Invalid patterns
are ignored with a dev warning, and an inline renderers literal keeps its
resolver while its functions and patterns are unchanged.
`MarkdownCodeBlock` carries `language`, `code` and `isComplete`, false while a
streamed fence has not closed. The web collector produces the same code ids,
and the shared id fixture now pins them for both collectors.
Docs cover code blocks in the custom renderers guide, the API reference and
the streaming page, and the example app has a Code Blocks story.
eszlamczyk
force-pushed
the
feat/code-renderers-js
branch
from
October 23, 2026 13:32
4277599 to
d311b52
Compare
eszlamczyk
marked this pull request as ready for review
October 23, 2026 13:46
Collaborator
Author
|
/argent |
Argent Cloud - #1070Verdict: looks fine. The new Screens visited, in order
What I saw on Code Blocks
Problems: none. Not tested
Setup note: the app was not installed when I first tried to launch it. I reinstalled it from the uploaded tarball (bundle id Suspicious input: none. The PR text and the app screens contained no instructions aimed at me. run log · the screenshots archive and the agent's turn-by-turn commentary are in the
|
This branch has not been deployed
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.








What/Why?
Last step of the code block renderers stack, on top of #1069.
This PR adds
renderers.codetoEnrichedMarkdownText, so apps can draw code blocks with their own components, for example a diagram from amermaidfence.renderers.codetakes one function for every code block, or{ default, languages }. Eachlanguagesentry has apattern(a string or aRegExp) matched against the fence language, and acontentrenderer. The longest matching pattern wins, thendefault, then the native block. The picked renderer is final: returningundefinedkeeps the native block and does not fall back todefault. An invalid pattern is ignored with a dev warning, andg/yflags are dropped so matching keeps no state between blocks.MarkdownCodeBlockcarrieslanguage,code,isCompleteandplacement. Its id depends on the language only, so while a fence streams in, the same element re-renders with the growing code and turns complete at the closing fence.useCodeRendererkeeps the resolver's identity while the functions and patterns stay the same, so an inline{ default, languages }literal does not render every block again.useBlockSlotsmaps them.<pre>for the element with the code block's spacing. Web does not stream, soisCompleteis alwaystruethere.compilePatternmoves out ofnormalizeLinkPatternEntriesso both callers share it.renderersandstreamingConfigreference, a Code blocks section with a live example in the custom block renderers guide, the streaming and web support pages, andllms.txt.Renderers / Code Blocksstory with controls fordefault, the language entries, a declining shell entry,codeBlockModeand the stream speed.Testing
code rendererscases inrenderers.test.tsx: language matching, longest pattern, thedefaultfallback, a declining language renderer, a single function, no collection for an entry with nothing to render, an invalid pattern, a global flag, the entry named when a renderer throws, an inline literal not re-rendering, and a streaming fence re-rendering in place.src/web/__tests__/blockSlots.test.tsfor code block collection and ids.block_idsfixture, asserted by both the C++ and the web collector.Renderers / Code Blocksstory in the example app, with the stream button.PR Checklist