Skip to main content

Function: mergeSpans()

mergeSpans(spans): VerseSpan[]

Defined in: Data/Text/normalizeVerseText.ts:579

Canonicalize the span list: merge overlapping or touching spans that share a type (and ref), then sort by start, end, type.

Merging matters because the legacy HTML frequently splits one logical run across several tags — <i>the L</i><i>ord</i>, or a red-letter quotation broken at every <br />. Merging also makes the output independent of whether the caller supplied formatting_data, since the two sources produce the same ranges.

Parameters

spans

readonly VerseSpan[]

Returns

VerseSpan[]