MCPcopy Create free account
hub / github.com/deta/surf / handleIncompleteComponent

Function handleIncompleteComponent

packages/utils/src/formatting/markdown-plugins.ts:64–79  ·  view source on GitHub ↗
(node: any)

Source from the content-addressed store, hash-verified

62}
63
64function handleIncompleteComponent(node: any): boolean {
65 if (node.children.length !== 1 || node.children[0].type !== 'text') {
66 return false
67 }
68
69 const textNode = node.children[0]
70 // Match incomplete components like :::componentName{ or :::componentName{incomplete
71 const incompleteMatch = textNode.value.match(/^\s*:::(\w+)(\{[^}]*)?\s*$/)
72
73 if (incompleteMatch) {
74 node.children = [{ type: 'text', value: '' }]
75 return true
76 }
77
78 return false
79}
80
81function cleanTextContent(text: string): string {
82 return text.replace(/\s*:::(\w+)(\{[^}]*)?\s*$/, '').replace(/\}\s*$/g, '')

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected