UNPKG

html-minifier

Version:

Highly effective, super-configurable, well-tested web page minifier

99 lines • 3.96 kB
/** * Whitespace trimming and collapsing */ /** @param {string} str */ declare const trimWhitespace: (str: string) => string; /** @param {number} code */ declare function isAsciiWhitespace(code: number): code is 9 | 10 | 12 | 13 | 32; /** @param {string} str */ declare function isAllWhitespace(str: string): boolean; /** @param {string} str */ declare function endsWithWhitespace(str: string): boolean; /** @param {string} str */ declare function collapseWhitespaceAll(str: string): string; /** * @param {string} str * @param {{decodeEntities?: boolean | undefined, preserveLineBreaks?: boolean | undefined}} options */ declare function collapseNoBreakSpaces(str: string, options: { decodeEntities?: boolean | undefined; preserveLineBreaks?: boolean | undefined; }): string; /** * @param {string} str * @param {{preserveLineBreaks?: boolean | undefined, conservativeCollapse?: boolean | undefined}} options * @param {boolean} trimLeft * @param {boolean} trimRight * @param {boolean} [collapseAll] * @param {boolean} [keepUntrimmed] - Whether a side not trimmed keeps its line breaks as written */ declare function collapseWhitespace(str: string, options: { preserveLineBreaks?: boolean | undefined; conservativeCollapse?: boolean | undefined; }, trimLeft: boolean, trimRight: boolean, collapseAll?: boolean, keepUntrimmed?: boolean): string; export type InlineSets = { /** * - Elements whose surrounding whitespace is kept */ around: Set<string>; /** * - The same, spelled as end tags */ aroundEnd: Set<string>; /** * - Elements whose inner whitespace is kept */ within: Set<string>; /** * - The same, spelled as end tags */ withinEnd: Set<string>; /** * - `within` under both spellings */ withinEither: Set<string>; }; /** * @typedef {object} InlineSets * @prop {Set<string>} around - Elements whose surrounding whitespace is kept * @prop {Set<string>} aroundEnd - The same, spelled as end tags * @prop {Set<string>} within - Elements whose inner whitespace is kept * @prop {Set<string>} withinEnd - The same, spelled as end tags * @prop {Set<string>} withinEither - `within` under both spellings */ /** * Inline-element membership for the whitespace pass, each set paired with its end-tag * spelling so a lookup takes the tag as it comes rather than slicing off the slash * @param {Set<string>} around * @param {Set<string>} within * @returns {InlineSets} */ declare function buildInlineSets(around: Set<string>, within: Set<string>): InlineSets; declare const defaultInlineSets: InlineSets; /** * @param {string} str * @param {string} prevTag * @param {string} nextTag * @param {Array<{name: string, value?: string}>} prevAttrs * @param {Array<{name: string, value?: string}>} nextAttrs * @param {{preserveLineBreaks?: boolean, conservativeCollapse?: boolean, collapseInlineTagWhitespace?: boolean}} options * @param {InlineSets} inlineSets * @param {boolean} [collapseInside] - False where `canCollapseWhitespace` keeps runs inside the text as they are */ declare function collapseWhitespaceSmart(str: string, prevTag: string, nextTag: string, prevAttrs: Array<{ name: string; value?: string; }>, nextAttrs: Array<{ name: string; value?: string; }>, options: { preserveLineBreaks?: boolean; conservativeCollapse?: boolean; collapseInlineTagWhitespace?: boolean; }, inlineSets: InlineSets, collapseInside?: boolean): string; /** @param {string} tag */ declare function canCollapseWhitespace(tag: string): boolean; /** @param {string} tag */ declare function canTrimWhitespace(tag: string): boolean; export { buildInlineSets, defaultInlineSets, endsWithWhitespace, isAsciiWhitespace, trimWhitespace, collapseWhitespaceAll, collapseNoBreakSpaces, collapseWhitespace, collapseWhitespaceSmart, canCollapseWhitespace, canTrimWhitespace, isAllWhitespace }; //# sourceMappingURL=whitespace.d.ts.map