| 226 | |
| 227 | // Extract text content from React children if __raw__ is not available |
| 228 | const getTextContent = (node: ReactNode): string => { |
| 229 | if (typeof node === "string") { |
| 230 | return node; |
| 231 | } |
| 232 | if (typeof node === "number") { |
| 233 | return String(node); |
| 234 | } |
| 235 | if (Array.isArray(node)) { |
| 236 | return node.map(getTextContent).join(""); |
| 237 | } |
| 238 | if (isValidElement(node)) { |
| 239 | const nodeProps = node.props as { children?: ReactNode }; |
| 240 | if (nodeProps.children) { |
| 241 | return getTextContent(nodeProps.children); |
| 242 | } |
| 243 | } |
| 244 | return ""; |
| 245 | }; |
| 246 | |
| 247 | const codeContent = __raw__ || getTextContent(children); |
| 248 | |