3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-21 15:42:58 +01:00

Answer stability round 2: 1 🔴, 0 🟡 (0 misread); a line gives up every highlight run whose own delimiters cannot flank in one pass, as shipped, so a line of them re-emits once, and the reader records no highlight pairs

This commit is contained in:
2026-10-28 18:10:03 +01:00
committed by Lillem4n
parent 5107c9506b
commit 2f9a1b3540
5 changed files with 44 additions and 30 deletions
+4 -4
View File
@@ -41,7 +41,7 @@ type LineAttempt = { fallback: NodeRange | 'opening-link'; line?: undefined } |
type LineFallbacks = { carried: Set<number>; flavour: WrittenFlavour; openingLinkAsDirective: boolean }
export type PortableLineFallback = { kind: 'opening-link' } | { kind: 'unspellable-run'; run: MarkRun }
export type PortableLineFallback = { kind: 'opening-link' } | { kind: 'unspellable-run'; runs: [MarkRun, ...MarkRun[]] }
export function emitInlineLine(nodes: readonly AdfNode[], container: LineContainer, path: ConvertErrorPath, flavour: WrittenFlavour): Result<string> {
const emitted = emitLine(nodes, container, path, flavour)
@@ -136,7 +136,7 @@ function lineSegments(nodes: readonly AdfNode[], container: LineContainer, path:
function attemptLine(segments: readonly InlineSegment[], container: LineContainer, flavour: WrittenFlavour): LineAttempt {
const verdict = lineVerdict(segments, container, flavour)
if (verdict.kind === 'opening-link') return { fallback: 'opening-link' }
if (verdict.kind === 'unspellable-run') return { fallback: verdict.run }
if (verdict.kind === 'unspellable-run') return { fallback: verdict.runs[0] }
return { line: verdict.text }
}
@@ -144,8 +144,8 @@ function attemptLine(segments: readonly InlineSegment[], container: LineContaine
function lineVerdict(segments: readonly InlineSegment[], container: LineContainer, flavour: WrittenFlavour): PortableLineFallback | { kind: 'line'; text: string } {
const assembled = assembleInlineLine(segments, container, flavour)
if (assembled.openingLinkAsDirective) return { kind: 'opening-link' }
const run = assembled.unspellableRun
return run === undefined ? { kind: 'line', text: assembled.line } : { kind: 'unspellable-run', run }
const [run, ...others] = assembled.unspellableRuns
return run === undefined ? { kind: 'line', text: assembled.line } : { kind: 'unspellable-run', runs: [run, ...others] }
}
// A space or tab CommonMark strips at a line edge rides !adf:text{text="…"}.