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

Function renderList

cli/src/utils/markdown-renderer.tsx:548–590  ·  view source on GitHub ↗
(list: List, state: RenderState)

Source from the content-addressed store, hash-verified

546}
547
548const renderList = (list: List, state: RenderState): ReactNode[] => {
549 const { palette, nextKey } = state
550 const nodes: ReactNode[] = []
551 const start = list.start ?? 1
552
553 list.children.forEach((item, idx) => {
554 const listItem = item as ListItem
555 const marker =
556 listItem.checked === true
557 ? '[x] '
558 : listItem.checked === false
559 ? '[ ] '
560 : list.ordered
561 ? `${start + idx}. `
562 : '- '
563
564 nodes.push(
565 <span key={nextKey()} fg={palette.listBulletFg}>
566 {marker}
567 </span>,
568 )
569
570 const itemNodes = trimTrailingBreaks(
571 renderNodes(listItem.children as MarkdownNode[], state, listItem.type),
572 )
573 if (itemNodes.length === 0) {
574 nodes.push('\n')
575 } else {
576 nodes.push(
577 <KeyedFragment key={nextKey()}>
578 {wrapSegmentsInFragments(itemNodes, nextKey())}
579 </KeyedFragment>,
580 )
581 nodes.push('\n')
582 }
583 })
584
585 if (nodes.length > 0) {
586 nodes.push('\n')
587 }
588
589 return nodes
590}
591
592const renderHeading = (heading: Heading, state: RenderState): ReactNode[] => {
593 const { palette, nextKey } = state

Callers 1

renderNodeFunction · 0.85

Calls 3

trimTrailingBreaksFunction · 0.85
renderNodesFunction · 0.85
wrapSegmentsInFragmentsFunction · 0.85

Tested by

no test coverage detected