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

Function applyInlineFallbackFormatting

cli/src/utils/markdown-renderer.tsx:311–352  ·  view source on GitHub ↗
(node: MarkdownNode)

Source from the content-addressed store, hash-verified

309}
310
311const applyInlineFallbackFormatting = (node: MarkdownNode): void => {
312 if (!node || typeof node !== 'object') {
313 return
314 }
315
316 const mutable = node as { children?: MarkdownNode[] }
317 if (!Array.isArray(mutable.children)) {
318 return
319 }
320
321 const nextChildren: MarkdownNode[] = []
322
323 mutable.children.forEach((child) => {
324 if (child.type === 'text') {
325 const replacements = parseInlineFallback(child.value)
326 const hasChanges =
327 replacements.length !== 1 ||
328 replacements[0].type !== 'text' ||
329 replacements[0].value !== child.value
330
331 if (hasChanges) {
332 replacements.forEach((replacement) => {
333 if (replacement.type === 'text') {
334 nextChildren.push(replacement)
335 } else {
336 applyInlineFallbackFormatting(
337 replacement as unknown as MarkdownNode,
338 )
339 nextChildren.push(replacement as unknown as MarkdownNode)
340 }
341 })
342 return
343 }
344 } else {
345 applyInlineFallbackFormatting(child as MarkdownNode)
346 }
347
348 nextChildren.push(child as MarkdownNode)
349 })
350
351 mutable.children = nextChildren
352}
353
354const getChildrenText = (children: MarkdownNode[]): string => {
355 return children.map(nodeToPlainText).join('')

Callers 1

renderMarkdownFunction · 0.85

Calls 1

parseInlineFallbackFunction · 0.85

Tested by

no test coverage detected