(list: List, state: RenderState)
| 546 | } |
| 547 | |
| 548 | const 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 | |
| 592 | const renderHeading = (heading: Heading, state: RenderState): ReactNode[] => { |
| 593 | const { palette, nextKey } = state |
no test coverage detected