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

Function renderCodeBlock

cli/src/utils/markdown-renderer.tsx:478–510  ·  view source on GitHub ↗
(code: Code, state: RenderState)

Source from the content-addressed store, hash-verified

476}
477
478const renderCodeBlock = (code: Code, state: RenderState): ReactNode[] => {
479 const { palette, nextKey } = state
480 const lines = code.value.split('\n')
481 const nodes: ReactNode[] = []
482
483 if (code.lang) {
484 nodes.push(
485 <span key={nextKey()} fg={palette.codeHeaderFg}>
486 {`// ${code.lang}`}
487 </span>,
488 '\n',
489 )
490 }
491
492 lines.forEach((line, index) => {
493 const displayLine = line === '' ? ' ' : line
494 nodes.push(
495 <span
496 key={nextKey()}
497 fg={palette.codeTextFg}
498 bg={palette.codeMonochrome ? undefined : palette.codeBackground}
499 >
500 {displayLine}
501 </span>,
502 )
503 if (index < lines.length - 1) {
504 nodes.push('\n')
505 }
506 })
507
508 nodes.push('\n\n')
509 return nodes
510}
511
512const renderBlockquote = (
513 blockquote: Blockquote,

Callers 1

renderNodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected