From 9dfa14a095222c5b8fd4d4d435e2940720483feb Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 9 Nov 2026 06:53:53 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1=20(0=20misread);=20drop=20the?= =?UTF-8?q?=20repeating=20comment,=20name=20characterPast,=20settle=20two?= =?UTF-8?q?=20places=20in=20the=20PR=20summary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/markdown/emit/unspellable-runs.test.ts | 2 +- src/markdown/emit/unspellable-runs.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/markdown/emit/unspellable-runs.test.ts b/src/markdown/emit/unspellable-runs.test.ts index 4a2fadc..493a758 100644 --- a/src/markdown/emit/unspellable-runs.test.ts +++ b/src/markdown/emit/unspellable-runs.test.ts @@ -78,7 +78,7 @@ const lines: { carry?: string[]; drop?: string[]; name: string; nodes: AdfNode[] { carry: ['em@2-2'], drop: ['em@2-2'], - name: 'a digit, strong and strike over nodes 1 and 2, em on node 2, strong on a digit', + name: 'a digit, strong over nodes 1 to 3, strike over nodes 1 and 2, em on node 2', nodes: [plain('0'), marked(['strong', 'strike'], '_'), marked(['strong', 'em', 'strike'], '_'), marked(['strong'], '0')], }, ] diff --git a/src/markdown/emit/unspellable-runs.ts b/src/markdown/emit/unspellable-runs.ts index 79b615c..049b3a7 100644 --- a/src/markdown/emit/unspellable-runs.ts +++ b/src/markdown/emit/unspellable-runs.ts @@ -166,7 +166,6 @@ function mayFlank(sweep: PairSweep, judged: number, character: string, end: 'clo function runEdge(sweep: PairSweep, judged: number, from: number, step: -1 | 1, character: string): string[] | undefined { const found: string[] = [] const { delimiters } = touching(sweep, from, step) - // Each pair beside adds the characters it may be written with; one that stands ends the run unless it may be written with `character`. for (const at of delimiters) { const other = sweep.pairAt[at] ?? -1 const standing = pairStanding(sweep, judged, other) @@ -176,12 +175,16 @@ function runEdge(sweep: PairSweep, judged: number, from: number, step: -1 | 1, c for (const spelling of spellings) if (spelling !== character) found.push(spelling) if (standing === 'stands' && !spellings.includes(character)) return found } - // Past the run stands the character after its last delimiter: a backslash where the text beside is escaped, which the next segment's start skips. - const edge = delimiterEdge(sweep.placed, delimiters.at(-1) ?? from, step) - found.push(sweep.output.charAt(step === 1 ? edge : edge - 1)) + found.push(characterPast(sweep, delimiters.at(-1) ?? from, step)) return found } +// Past the run stands the character after its last delimiter: a backslash where the text beside is escaped, which the next segment's start skips. +function characterPast({ output, placed }: PairSweep, lastDelimiter: number, step: -1 | 1): string { + const edge = delimiterEdge(placed, lastDelimiter, step) + return output.charAt(step === 1 ? edge : edge - 1) +} + // Whether a word character may stand beside the delimiter at `from` as resolveEmphasis reads the line, for each way the unsettled pairs fall. function wordBeside(sweep: PairSweep, judged: number, from: number, step: -1 | 1): boolean[] | undefined { const found: boolean[] = []