| \n\nhttps://drop.example.com/table.png\n\n | \n\nhttps://drop.example.com/demo.mp4\n\n |
\n```\n\nUse `
` here.\n\n
\n\n\n\n
';
expect(markdownImageSources(markdown)).toEqual(["one.png", "two.png"]);
+ expect(markdownImages(markdown)).toEqual([
+ { url: "one.png", alt: null },
+ { url: "two.png", alt: "Two" },
+ ]);
+ expect(markdownImages('\n\n')).toEqual([
+ { url: "same.png", alt: "Captured" },
+ ]);
+ expect(
+ markdownImages(
+ '![Before][shot-1]\n\n![][shot-2]\n\n[shot-1]: https://example.com/1.png\n[shot-2]: https://example.com/2.png "After"',
+ ),
+ ).toEqual([
+ { url: "https://example.com/1.png", alt: "Before" },
+ { url: "https://example.com/2.png", alt: "After" },
+ ]);
const result = markdownWithHtml(markdown);
expect(result).toContain('```html\n
\n```');
expect(result).toContain('`
`');
diff --git a/apps/mobile/src/lib/markdownImageSources.ts b/apps/mobile/src/lib/markdownImageSources.ts
index d3ccaa8de793d..1529ee5cadc00 100644
--- a/apps/mobile/src/lib/markdownImageSources.ts
+++ b/apps/mobile/src/lib/markdownImageSources.ts
@@ -1,12 +1,53 @@
import { parseMarkdownDocument, type MarkdownNode } from "./markdownDocument";
-export function markdownImageSources(markdown: string): string[] {
- if (!markdown.includes("![") && !/