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:
@@ -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
|
||||
|
||||
@@ -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[] = []
|
||||
|
||||
Reference in New Issue
Block a user