From 744476658ca100d264c2923c5d0aea9dab658e8f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 12:48:28 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20prose=20round=202:=200=20=F0=9F=94=B4,?= =?UTF-8?q?=202=20=F0=9F=9F=A1=20(0=20misread);=20the=20memo=20comments=20?= =?UTF-8?q?say=20what=20they=20hold,=20the=20PR=20body=20names=20destinati?= =?UTF-8?q?onEnds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/markdown/commonmark/link-syntax.ts | 4 ++-- src/markdown/parse/inline-content.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/markdown/commonmark/link-syntax.ts b/src/markdown/commonmark/link-syntax.ts index 8ac7bed..f899364 100644 --- a/src/markdown/commonmark/link-syntax.ts +++ b/src/markdown/commonmark/link-syntax.ts @@ -10,7 +10,7 @@ export type LinkPart = { length: number; value: string } // Every destination ending at one index shares what follows it: the title and the closing `)`. type Tail = { end: number; title: string | undefined } -// What the targets read in `text` share; `destinationEnds` is walked at the first one. +// One memo serves every target in `text`, those in a directive's content included. export type TargetMemo = { destinationEnds: Int32Array | undefined; tails: Map; text: string } // The lossless flavour escapes a quote alone, writing a title holding a backslash or an entity reference as a directive (spec/flavour.md, Marks); the portable flavour writes no directive, so it escapes those too, and a table cell's `|` (README, Portable markdown). @@ -72,7 +72,7 @@ export function targetMemo(text: string): TargetMemo { return { destinationEnds: undefined, tails: new Map(), text } } -// Where an unbracketed destination starting at each index stops, in one pass, for every start a target can have: the index just after a `(`, a space or a control character. Index 0 is a start too, for `readDestination`, which reads from its text's first character. +// `ends[start]` is where an unbracketed destination from `start` stops, filled in one pass for every start a target can have: just after a `(`, a space or a control character, and 0, where `readDestination`'s run begins. function destinationEnds(text: string): Int32Array { const ends = new Int32Array(text.length + 1) const open = [0] diff --git a/src/markdown/parse/inline-content.ts b/src/markdown/parse/inline-content.ts index 6c3fae5..77160a3 100644 --- a/src/markdown/parse/inline-content.ts +++ b/src/markdown/parse/inline-content.ts @@ -433,7 +433,7 @@ function resolveTarget(scan: Scan, start: number, index: number): InlineTarget | const after = index + 1 if (scan.source.charAt(after) === '(') { const inline = readInlineTarget(scan.targets, scan.offset + after) - // A target read in the outermost content holds in a directive's content exactly when it ends inside it. + // The memo reads the outermost content; a target it reads holds here exactly when the target ends inside `source`. if (inline !== undefined && after + inline.length <= scan.source.length) return inline } const label = scan.source.charAt(after) === '[' ? readLabel(scan.source, after) : undefined