(node: any, pattern: RegExp, buildNode: NodeBuilder)
| 33 | |
| 34 | // biome-ignore lint/suspicious/noExplicitAny: remark tree types are not available |
| 35 | function walkChildren(node: any, pattern: RegExp, buildNode: NodeBuilder) { |
| 36 | if ( |
| 37 | !node?.children || |
| 38 | !Array.isArray(node.children) || |
| 39 | shouldSkipNode(node) |
| 40 | ) { |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | for (let i = node.children.length - 1; i >= 0; i--) { |
| 45 | const child = node.children[i]; |
| 46 | |
| 47 | if (child.type === "text") { |
| 48 | const parts = splitByPattern(child.value, pattern, buildNode); |
| 49 | if ( |
| 50 | parts.length > 1 || |
| 51 | (parts.length === 1 && parts[0].type !== "text") |
| 52 | ) { |
| 53 | node.children.splice(i, 1, ...parts); |
| 54 | } |
| 55 | } else { |
| 56 | walkChildren(child, pattern, buildNode); |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | // biome-ignore lint/suspicious/noExplicitAny: remark tree types are not available |
| 62 | function shouldSkipNode(node: any): boolean { |
no test coverage detected