The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { parseMarkdownDocument, type MarkdownNode } from "./markdownDocument"; |
| 2 | |
| 3 | export function markdownImageSources(markdown: string): string[] { |
| 4 | if (!markdown.includes("![") && !/<img[\s>]/i.test(markdown)) return []; |
| 5 | const sources = new Set<string>(); |
| 6 | const visit = (node: MarkdownNode) => { |
| 7 | if (node.type === "image") sources.add(node.url); |
| 8 | if ("children" in node) node.children.forEach(visit); |
| 9 | }; |
| 10 | visit(parseMarkdownDocument(markdown)); |
| 11 | return [...sources]; |
| 12 | } |