Skip to content

Commit 3cd5901

Browse files
dibas-npclaude
andcommitted
perf(mobile): parse for image splits only when images are line-separated
The guard before the extra Markdown parse matched any image at the start of a line, including images already separated by blank lines, so most messages with a screenshot paid for a parse on every streaming tick. Match only an image end followed by a line break and another image. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 2e63366 commit 3cd5901

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎apps/mobile/src/lib/markdownDocument.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ const isSpace = (node: MarkdownNode) =>
437437

438438
// Native Markdown sizes an image as a block only when it is its paragraph's only child.
439439
function markdownWithImageParagraphs(markdown: string): string {
440-
// Skips the extra parse unless an image starts a line.
441-
if (!/[\r\n][ \t]*!\[/.test(markdown)) return markdown;
440+
// Skips the extra parse unless a line ending sits between two images.
441+
if (!/[\])][ \t]*\\?(?:\r\n?|\n)[ \t]*!\[/.test(markdown)) return markdown;
442442
const edits: MarkdownEdit[] = [];
443443
for (const block of parser.parse(markdown).children) {
444444
if (

0 commit comments

Comments
 (0)