3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-12 11:48:29 +01:00

Answer stability round 1: 0 🔴, 3 🟡 (0 misread); drop the repeating comment, name characterPast, settle two places in the PR summary

This commit is contained in:
2026-11-09 06:53:53 +01:00
committed by Lillem4n
parent aa3ca490dc
commit 9dfa14a095
2 changed files with 8 additions and 5 deletions
+1 -1
View File
@@ -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')],
},
]
+7 -4
View File
@@ -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[] = []