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

Answer prose round 1: 0 🔴, 6 🟡 (0 misread); reword the spanning comments, spec and changelog entry

This commit is contained in:
2026-10-31 03:56:44 +01:00
parent ad86a9a989
commit 4492cd6ff4
4 changed files with 17 additions and 13 deletions
+2 -2
View File
@@ -6,13 +6,13 @@ import { takesMark } from '../../adf/inline-nodes.ts'
type Carries = (node: AdfNode, index: number) => boolean
// The nodes, each that an emphasis or link run skips between two nodes it marks holding the run's mark at the run's depth, or `nodes` itself where no run skips one.
// Lends each emphasis or link run's mark to the nodes inside the run that cannot hold it; returns `nodes` itself where no run skips a node.
export function spanSkippedNodes(nodes: readonly AdfNode[], carries: Carries): readonly AdfNode[] {
const spanned = [...nodes]
return spanRuns(spanned, 0, spanned.length, 0, carries) ? spanned : nodes
}
// Groups the runs as `inlineRuns` does, then lends each run's mark to the nodes it skips; returns whether it lent any.
// Groups the runs as `inlineRuns` does.
function spanRuns(spanned: AdfNode[], first: number, end: number, depth: number, carries: Carries): boolean {
if (depth > largestNesting) return false
let lent = false
+1 -1
View File
@@ -166,7 +166,7 @@ export function trimmedEdges(leaves: readonly AdfNode[]): AdfNode[] {
// 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))
// Whitespace beside a code span a run spans keeps the run's mark, where the line written spanned reads it.
// Whitespace beside a code span inside a run keeps the run's mark, since the writer spans the run across the code.
const spanned = spanSkippedNodes(merged, () => false)
let changed = false
const trimmed: AdfNode[] = []