Skip to content

Commit 4718514

Browse files
fix(mobile): copy a wrapped quoted definition without its quote markers
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c07da4b commit 4718514

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,11 @@ function referenceDefinition(source: string): MarkdownReferenceDefinition | null
354354
let end = 1;
355355
while (end < source.length && source[end] !== "]") end += source[end] === "\\" ? 2 : 1;
356356
if (source[0] !== "[" || end >= source.length) return null;
357-
return { label: source.slice(1, end).replace(/\s+/g, " ").toLowerCase(), source };
357+
return {
358+
label: source.slice(1, end).replace(/\s+/g, " ").toLowerCase(),
359+
// A definition may sit on one line, so drop the quote markers and indent of its continuations.
360+
source: source.replace(/\n[ \t>]*/g, " "),
361+
};
358362
}
359363

360364
/** Each fragment renders as its own document, so it carries the definitions it mentions. */

‎apps/mobile/src/lib/markdownHtml.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ describe("details folds in chat Markdown", () => {
229229
]);
230230
});
231231

232+
it("carries a quoted definition that wraps onto a continuation line", () => {
233+
const { segments, definitions } = splitMarkdownDetails(
234+
'See [d].\n\n<details><summary>A</summary>a</details>\n\n> [d]:\n> https://example.com\n> "Title"',
235+
);
236+
const before = segments[0];
237+
expect(
238+
before?.kind === "markdown" && withReferenceDefinitions(before.markdown, definitions),
239+
).toBe('[d]: https://example.com "Title"\n\nSee [d].\n\n');
240+
});
241+
232242
it("finds definitions inside a compact HTML block and labels that wrap", () => {
233243
const markdown =
234244
"See [the\n doc].\n\n<details><summary>A</summary>a</details>\n[The Doc]: https://example.com";

0 commit comments

Comments
 (0)