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

Function renderMarkdown

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

Source from the content-addressed store, hash-verified

1007}
1008
1009export function renderMarkdown(
1010 markdown: string,
1011 options: MarkdownRenderOptions = {},
1012): ReactNode {
1013 try {
1014 const palette = resolvePalette(options.palette)
1015 const codeBlockWidth = options.codeBlockWidth ?? 80
1016 const state = createRenderState(palette, codeBlockWidth)
1017 const ast = processor.parse(markdown) as Root
1018 applyInlineFallbackFormatting(ast)
1019 const nodes = renderNode(ast, state, ast.type, undefined)
1020 return normalizeOutput(nodes)
1021 } catch (error) {
1022 logger.error(error, 'Failed to parse markdown')
1023 return markdown
1024 }
1025}
1026
1027export function hasMarkdown(content: string): boolean {
1028 return /[*_`#>\-\+]|\[.*\]\(.*\)|```/.test(content)

Callers 5

plan-box.tsxFile · 0.90
renderStreamingMarkdownFunction · 0.85

Calls 6

resolvePaletteFunction · 0.85
createRenderStateFunction · 0.85
renderNodeFunction · 0.85
normalizeOutputFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected