open-agreements
Version:
Open-source legal template filling CLI and library
41 lines • 1.81 kB
TypeScript
/**
* merge_runs — merge adjacent format-identical runs within paragraphs.
*
* Safety barriers: never merge across fldChar/instrText, comment range,
* bookmark, or tracked-change wrapper boundaries.
*/
export type MergeRunsResult = {
runsMerged: number;
proofErrRemoved: number;
};
export type MergeRunsOptions = {
/**
* When true, adjacent runs that differ in any `w:rsid*` attribute are
* NOT merged, and existing rsid attributes on live runs are not stripped.
* Use this from edit pipelines (e.g. `replace_text`) so that mutations
* to one run do not silently rewrite rsid identity on neighbouring runs
* the caller never touched. The default (`false`) preserves the
* normalize-on-open behaviour: every run in the body is first stripped
* of its `w:rsid*` attributes, then format-identical adjacent runs are
* merged unconditionally.
*/
preserveRsidIdentity?: boolean;
};
/**
* Merge adjacent format-identical runs across all paragraphs in the
* document body. Removes `<w:proofErr>` elements.
*
* Pass `{ preserveRsidIdentity: true }` from edit pipelines that must not
* disturb rsid attributes on runs the caller did not touch (see #286).
* The default omits that guard and matches the historical normalize-on-open
* behaviour, which consolidates rsid-fragmented runs that Word produces
* across edit sessions.
*
* Safety barriers prevent merges across:
* - Field boundaries (fldChar, instrText)
* - Comment range boundaries (commentRangeStart, commentRangeEnd)
* - Bookmark boundaries (bookmarkStart, bookmarkEnd)
* - Tracked-change wrapper boundaries (ins, del, moveFrom, moveTo)
*/
export declare function mergeRuns(doc: Document, opts?: MergeRunsOptions): MergeRunsResult;
//# sourceMappingURL=merge_runs.d.ts.map