open-agreements
Version:
Open-source legal template filling CLI and library
47 lines • 2.23 kB
TypeScript
import type { Element } from '@xmldom/xmldom';
import type { CleanConfig, GuidanceOutput } from '../metadata.js';
/**
* Default size threshold for removeHeaderFooterDrawings, in bytes.
*
* Empirically calibrated against the bundled corpus (2026-08): the largest
* benign header/footer media across all 187 bundled DOCX files is a 146-byte
* spacer PNG (40 occurrences across 21 Common Paper templates), while the
* known-bad artifact class — full-page "how to use this template" screenshots
* from Google-Docs exports (legal-explainer#1800) — starts around 125 KB.
* 50 KB sits comfortably between the two and matches legal-explainer's
* source-side vendored-docx audit threshold.
*/
export declare const DEFAULT_HEADER_FOOTER_DRAWING_MIN_BYTES: number;
export interface CleanResult {
outputPath: string;
guidance?: GuidanceOutput;
}
export interface CleanOptions {
extractGuidance?: boolean;
/** Pre-computed hashes for guidance staleness detection */
sourceHash?: string;
configHash?: string;
}
/**
* Clean a DOCX document by removing footnotes, pattern-matched paragraphs,
* and clearing specified parts.
* Operates at the OOXML level to preserve formatting of retained content.
*
* Processes all general OOXML text parts (document, headers, footers, endnotes).
* Footnotes.xml is handled separately with its separator/continuationSeparator logic.
*
* When options.extractGuidance is true, captures the text content of all
* removed elements before deletion and returns them as structured guidance data.
*
* Note: Helpers use xmldom's own `Document`/`Element`/`Node` types to avoid
* incompatibilities with the global DOM lib declarations.
*/
export declare function cleanDocument(inputPath: string, outputPath: string, config: CleanConfig, options?: CleanOptions): Promise<CleanResult>;
/**
* Whether a paragraph carries no visible content: no non-whitespace text and no
* drawing/picture/embedded-object. A paragraph holding only formatting, a
* section break (<w:sectPr>), or a page break counts as empty; a logo or other
* image-bearing paragraph does not.
*/
export declare function isParagraphContentEmpty(para: Element): boolean;
//# sourceMappingURL=cleaner.d.ts.map