open-agreements
Version:
Open-source legal template filling CLI and library
52 lines • 2.36 kB
TypeScript
import AdmZip from 'adm-zip';
import type { Element } from '@xmldom/xmldom';
/** Set xml:space without duplicating a parsed namespaced attribute. */
export declare function preserveXmlSpace(element: Element): void;
export interface OoxmlTextParts {
document: string | null;
headers: string[];
footers: string[];
endnotes: string | null;
footnotes: string | null;
comments: string[];
}
/**
* Enumerate all OOXML text parts present in a DOCX zip.
*/
export declare function enumerateTextParts(zip: AdmZip): OoxmlTextParts;
/**
* Return a flat list of part names that should be processed by the patcher,
* cleaner (for footnote refs and paragraph patterns), verifier, and scanner.
*
* Excludes footnotes.xml because it has separator/continuationSeparator logic
* that requires special handling in the cleaner.
*/
export declare function getGeneralTextPartNames(parts: OoxmlTextParts): string[];
/**
* Return every text part, footnotes included.
*
* `getGeneralTextPartNames()` excludes `word/footnotes.xml` because the
* *cleaner* has to special-case its separator / continuationSeparator
* paragraphs. That exclusion is about mutation. Read-only passes — detecting
* which fields the source owns a sigil for, and scanning rendered output for
* doubling artifacts — have no such constraint, and a document whose footnote
* renders `8%%` while the verifier reports success is worse than one that
* fails loudly. Use this list for inspection; use the general list for
* anything that rewrites parts.
*/
export declare function getAllTextPartNames(parts: OoxmlTextParts): string[];
/**
* Copy OPC parts from one zip to another, excluding directory entries.
*
* OOXML packages are a flat set of parts; directory entries such as `word/`
* are JSZip/zip container artifacts and can make Word repair the document.
*
* `getData` may return a replacement Buffer for an entry, or `null` to drop
* the entry from the destination entirely (used for orphaned media parts).
*/
export declare function copyEntriesSkippingDirs(sourceZip: AdmZip, destinationZip: AdmZip, getData?: (entryName: string, entryData: Buffer) => Buffer | null): void;
/**
* Rebuild a zip from scratch while dropping directory entries.
*/
export declare function rezipWithoutDirEntries(zip: AdmZip): AdmZip;
//# sourceMappingURL=ooxml-parts.d.ts.map