mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-12 11:48:29 +01:00
Answer prose round 1: 0 🔴, 2 🟡 (0 misread); say what insideRun's callers rely on, delete sharedRuns's comment, clear the termination comment
This commit is contained in:
@@ -44,7 +44,7 @@ export function isEmphasis(mark: AdfMark): boolean {
|
||||
return markSpelling(mark.type)?.kind === 'emphasis'
|
||||
}
|
||||
|
||||
// spec/flavour.md, Marks. The writers and the portable reducer group runs alike only while both ask this.
|
||||
// spec/flavour.md, Marks. The portable reducer must ask this too, or it trims edge whitespace by runs the writers do not spell.
|
||||
export function insideRun({ node, outer }: RunNode, mark: AdfMark): RunNode | undefined {
|
||||
const held = nodeMarks(node)[outer]
|
||||
return held !== undefined && identicalMark(held, mark) ? { node, outer: outer + 1 } : undefined
|
||||
|
||||
@@ -162,7 +162,7 @@ function withMarks(leaf: AdfNode, marks: readonly AdfMark[]): AdfNode {
|
||||
}
|
||||
|
||||
export function trimmedEdges(leaves: readonly AdfNode[]): AdfNode[] {
|
||||
// Terminates: a pass that changes a leaf drops its edge whitespace or takes a mark off that whitespace, and merging adds neither.
|
||||
// Terminates: a pass that changes a leaf drops whitespace from the leaf's edge or takes a mark off that whitespace, and merging adds no whitespace or mark.
|
||||
for (let current = leaves; ; ) {
|
||||
const merged = withoutEdgeBreaks(mergeAdjacentText(current, joinsWhenEditorNormal))
|
||||
let changed = false
|
||||
@@ -218,7 +218,6 @@ function edgeDepth(marks: readonly AdfMark[], neighbour: AdfNode | undefined, wh
|
||||
return kept === 0 && lineEdge ? undefined : kept
|
||||
}
|
||||
|
||||
// How many of the runs around a leaf holding `marks`, outermost first, hold `neighbour` too.
|
||||
function sharedRuns(marks: readonly AdfMark[], neighbour: AdfNode): number {
|
||||
let inside: RunNode | undefined = { node: neighbour, outer: 0 }
|
||||
for (const [depth, mark] of marks.entries()) {
|
||||
|
||||
Reference in New Issue
Block a user