diff --git a/src/markdown/mark-spellings.ts b/src/markdown/mark-spellings.ts index ca42526..0bebc98 100644 --- a/src/markdown/mark-spellings.ts +++ b/src/markdown/mark-spellings.ts @@ -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 diff --git a/src/markdown/portable/inline-reduction.ts b/src/markdown/portable/inline-reduction.ts index d76db68..e279af5 100644 --- a/src/markdown/portable/inline-reduction.ts +++ b/src/markdown/portable/inline-reduction.ts @@ -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()) {