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

Span a run inside inlineRuns, so runs group in one place

This commit is contained in:
2026-10-31 04:32:55 +01:00
committed by Lillem4n
parent 433d9442d2
commit e473fa92d0
3 changed files with 68 additions and 86 deletions
+3 -4
View File
@@ -9,8 +9,7 @@ import { insideRun, isEmphasis, type RunNode } from '../mark-spellings.ts'
import { joinsWhenEditorNormal } from './editor-normal.ts'
import { largestNesting } from '../../nesting.ts'
import { partsShownText, referenceName, shownImage, shownLink, shownText, shownUrl } from '../../adf/shown-text.ts'
import { portableLineFallback, readBackPasses, type PortableLineFallback } from '../emit/inline-line.ts'
import { spanSkippedNodes } from '../emit/skipped-nodes.ts'
import { portableLineFallback, readBackPasses, spannedNodes, type PortableLineFallback } from '../emit/inline-line.ts'
import { spellDestination } from '../commonmark/link-syntax.ts'
const highlight = 'backgroundColor'
@@ -166,8 +165,8 @@ 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 inside a run keeps the run's mark, since the writer spans the run across the code.
const spanned = spanSkippedNodes(merged, () => false)
// Judged beside the spanned line's nodes, so whitespace beside a code span inside a run keeps the run's mark.
const spanned = spannedNodes(merged, new Set()) ?? merged
let changed = false
const trimmed: AdfNode[] = []
for (const [index, leaf] of merged.entries()) {