MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / renderStreamingMarkdown

Function renderStreamingMarkdown

cli/src/utils/markdown-renderer.tsx:1059–1090  ·  view source on GitHub ↗
(
  content: string,
  options: MarkdownRenderOptions = {},
)

Source from the content-addressed store, hash-verified

1057}
1058
1059export function renderStreamingMarkdown(
1060 content: string,
1061 options: MarkdownRenderOptions = {},
1062): ReactNode {
1063 if (!hasMarkdown(content)) {
1064 return content
1065 }
1066
1067 if (!hasIncompleteCodeFence(content)) {
1068 return renderMarkdown(content, options)
1069 }
1070
1071 const lastFenceIndex = content.lastIndexOf('```')
1072 if (lastFenceIndex === -1) {
1073 return renderMarkdown(content, options)
1074 }
1075
1076 const completeSection = content.slice(0, lastFenceIndex)
1077 const pendingSection = content.slice(lastFenceIndex)
1078
1079 const segments: ReactNode[] = []
1080
1081 if (completeSection.length > 0) {
1082 segments.push(renderMarkdown(completeSection, options))
1083 }
1084
1085 if (pendingSection.length > 0) {
1086 segments.push(pendingSection)
1087 }
1088
1089 return mergeStreamingSegments(segments)
1090}

Calls 4

hasMarkdownFunction · 0.85
hasIncompleteCodeFenceFunction · 0.85
renderMarkdownFunction · 0.85
mergeStreamingSegmentsFunction · 0.85

Tested by

no test coverage detected