html-minifier-next 8.5.2 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -9
- package/cli.js +1 -1
- package/dist/types/htmlminifier.d.ts +10 -0
- package/dist/types/htmlminifier.d.ts.map +1 -1
- package/dist/types/lib/constants.d.ts +5 -2
- package/dist/types/lib/constants.d.ts.map +1 -1
- package/dist/types/lib/option-definitions.d.ts.map +1 -1
- package/dist/types/lib/options.d.ts.map +1 -1
- package/dist/types/lib/whitespace.d.ts +52 -4
- package/dist/types/lib/whitespace.d.ts.map +1 -1
- package/html-minifier-next.schema.json +4 -0
- package/package.json +5 -5
- package/src/htmlminifier.js +40 -5
- package/src/lib/constants.js +12 -1
- package/src/lib/option-definitions.js +4 -0
- package/src/lib/options.js +1 -0
- package/src/lib/unused-css.js +1 -1
- package/src/lib/whitespace.js +97 -16
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Your web page optimization precision tool: HTML Minifier Next (HMN) is a **highly effective, super-configurable, well-tested HTML minifier**, written in JavaScript, that also handles in-document CSS, JavaScript, and SVG minification.
|
|
6
6
|
|
|
7
|
-
The project was based on [HTML Minifier Terser (HMT)](https://github.com/terser/html-minifier-terser), which in turn had been based on [Juriy “kangax” Zaytsev’s HTML Minifier (HM)](https://github.com/kangax/html-minifier). HMN is **the official successor to HTML Minifier**: It’s actively maintained, richer in features, easier to use, and significantly faster. Note that HMN is largely compatible with HM and HMT but isn’t fully drop-in—find [migration guidance in the changelog](https://github.com/j9t/html-minifier-next/blob/main/CHANGELOG.md).
|
|
7
|
+
The project was based on [HTML Minifier Terser (HMT)](https://github.com/terser/html-minifier-terser), which in turn had been based on [Juriy “kangax” Zaytsev’s HTML Minifier (HM)](https://github.com/kangax/html-minifier). HMN is **the official successor to HTML Minifier**: It’s actively maintained, richer in features, easier to use, and significantly faster ([HMN engineering philosophy](https://meiert.com/blog/html-minifier-next-engineering-philosophy/)). Note that HMN is largely compatible with HM and HMT but isn’t fully drop-in—find [migration guidance in the changelog](https://github.com/j9t/html-minifier-next/blob/main/CHANGELOG.md).
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
@@ -32,7 +32,7 @@ Use `npx html-minifier-next --help` to check all available options:
|
|
|
32
32
|
|
|
33
33
|
| Option | Description | Example |
|
|
34
34
|
| --- | --- | --- |
|
|
35
|
-
| `--zero`, `-z` | Minify all HTML files in the current folder and its subfolders in place (except node_modules), using comprehensive settings (standalone—flag is ignored when combined with other options) | `npx html-minifier-next --zero` |
|
|
35
|
+
| `--zero`, `-z` | Minify all HTML files in the current folder and its subfolders in place (except node_modules), using comprehensive settings (standalone—the flag is ignored when combined with other options) | `npx html-minifier-next --zero` |
|
|
36
36
|
| `--input-dir <dir>`, `-I <dir>` | Specify an input directory | `--input-dir=src` |
|
|
37
37
|
| `--ignore-dir <patterns>`, `-X <patterns>` | Exclude directories—relative to input directory—from processing (comma-separated, overrides config file setting) | `--ignore-dir=libs`, `--ignore-dir=libs,vendor,node_modules` |
|
|
38
38
|
| `--output-dir <dir>`, `-O <dir>` | Specify an output directory | `--output-dir=dist` |
|
|
@@ -141,6 +141,7 @@ Options can be used in config files (camelCase) or via CLI flags (kebab-case wit
|
|
|
141
141
|
| `collapseAttributeWhitespace`<br>`--collapse-attribute-whitespace` | Trim and collapse whitespace characters within attribute values | `false` |
|
|
142
142
|
| `collapseBooleanAttributes`<br>`--collapse-boolean-attributes` | [Omit attribute values from boolean attributes](https://perfectionkills.com/experimenting-with-html-minifier/#collapse_boolean_attributes) | `false` |
|
|
143
143
|
| `collapseInlineTagWhitespace`<br>`--collapse-inline-tag-whitespace` | Collapse whitespace more aggressively between inline elements—use with [`collapseWhitespace`](#combining-whitespace-options) | `false` |
|
|
144
|
+
| `collapseNoBreakSpaces`<br>`--collapse-no-break-spaces` | Remove whitespace next to no-break spaces, narrow no-break spaces, and figure spaces in text (e.g., `a b` → `a b`), keeping runs of them—use with [`collapseWhitespace`](#combining-whitespace-options) | `false` |
|
|
144
145
|
| `collapseWhitespace`<br>`--collapse-whitespace` | [Collapse whitespace that contributes to text nodes in a document tree](https://perfectionkills.com/experimenting-with-html-minifier/#collapse_whitespace); [enable other whitespace options](#combining-whitespace-options) | `false` |
|
|
145
146
|
| `conservativeCollapse`<br>`--conservative-collapse` | Always collapse to one space (never remove it entirely)—use with [`collapseWhitespace`](#combining-whitespace-options) | `false` |
|
|
146
147
|
| `continueOnMinifyError`<br>`--continue-on-minify-error`<br>`--no-continue-on-minify-error` | Continue on minification errors; when `false`, minification errors throw and abort processing | `true` |
|
|
@@ -211,6 +212,7 @@ HTML Minifier Next: Ignoring `conservativeCollapse`—use with `collapseWhitespa
|
|
|
211
212
|
| `canMinifyJS` | `minifyJS`, and not [a function of your own](#javascript-minification) |
|
|
212
213
|
| `canMinifySVG` | `minifySVG`, and not [a function of your own](#svg-minification) |
|
|
213
214
|
| `collapseInlineTagWhitespace` | `collapseWhitespace` |
|
|
215
|
+
| `collapseNoBreakSpaces` | `collapseWhitespace` |
|
|
214
216
|
| `conservativeCollapse` | `collapseWhitespace` |
|
|
215
217
|
| `customEventAttributes` | `minifyJS` |
|
|
216
218
|
| `inlineCustomElements` | `collapseWhitespace` |
|
|
@@ -220,11 +222,11 @@ HTML Minifier Next: Ignoring `conservativeCollapse`—use with `collapseWhitespa
|
|
|
220
222
|
| `removeUnusedCSS` | `minifyCSS`, and not [a function of your own](#unused-css-removal) |
|
|
221
223
|
| `trimCustomFragments` | `collapseWhitespace` |
|
|
222
224
|
|
|
223
|
-
Passing the option `false`, or an empty array, asks for nothing and is not reported. `cacheCSS`, `cacheJS`, and `cacheSVG` are not
|
|
225
|
+
Passing the option `false`, or an empty array, asks for nothing and is not reported. `cacheCSS`, `cacheJS`, and `cacheSVG` are not included because they size a cache rather than transform markup, and therefore don’t change output.
|
|
224
226
|
|
|
225
227
|
### Combining whitespace options
|
|
226
228
|
|
|
227
|
-
`collapseInlineTagWhitespace`, `conservativeCollapse`, and `preserveLineBreaks` are modifiers: They do nothing on their own, and only take effect when `collapseWhitespace` is enabled.
|
|
229
|
+
`collapseInlineTagWhitespace`, `collapseNoBreakSpaces`, `conservativeCollapse`, and `preserveLineBreaks` are modifiers: They do nothing on their own, and only take effect when `collapseWhitespace` is enabled.
|
|
228
230
|
|
|
229
231
|
Given input
|
|
230
232
|
|
|
@@ -503,12 +505,11 @@ HTML Minifier Next uses in-memory caches to improve performance when processing
|
|
|
503
505
|
```js
|
|
504
506
|
const result = await minify(html, {
|
|
505
507
|
minifyCSS: true,
|
|
508
|
+
cacheCSS: 750, // CSS cache size, default: 500
|
|
506
509
|
minifyJS: true,
|
|
510
|
+
cacheJS: 250, // JS cache size, default: 500
|
|
507
511
|
minifySVG: true,
|
|
508
|
-
//
|
|
509
|
-
cacheCSS: 750, // CSS cache size, default: 500
|
|
510
|
-
cacheJS: 250, // JS cache size, default: 500
|
|
511
|
-
cacheSVG: 100 // SVG cache size, default: 500
|
|
512
|
+
cacheSVG: 100 // SVG cache size, default: 500
|
|
512
513
|
});
|
|
513
514
|
```
|
|
514
515
|
|
|
@@ -855,7 +856,7 @@ This writes a .cpuprofile file to the working directory. Load it with `npx speed
|
|
|
855
856
|
|
|
856
857
|
## Acknowledgements
|
|
857
858
|
|
|
858
|
-
With many thanks to the previous authors of and contributors to HTML Minifier, especially [Juriy “kangax” Zaytsev](https://github.com/kangax), and to everyone who helped make this new edition better, particularly [Daniel Ruf](https://github.com/DanielRuf), [Jonas Geiler](https://github.com/jonasgeiler),
|
|
859
|
+
With many thanks to the previous authors of and contributors to HTML Minifier, especially [Juriy “kangax” Zaytsev](https://github.com/kangax), and to everyone who helped make this new edition better, particularly [Daniel Ruf](https://github.com/DanielRuf), [Jonas Geiler](https://github.com/jonasgeiler), [Chris Morgan](https://github.com/chris-morgan), and [Andreas Borutta](https://github.com/fermiongithub)!
|
|
859
860
|
|
|
860
861
|
***
|
|
861
862
|
|
package/cli.js
CHANGED
|
@@ -330,7 +330,7 @@ function normalizeConfig(config) {
|
|
|
330
330
|
|
|
331
331
|
/** @type {Record<string, any>} */
|
|
332
332
|
let config = {};
|
|
333
|
-
program.option('-z, --zero', 'Minify all HTML files in the current folder and its subfolders in place (except node_modules), using comprehensive settings (standalone—flag is ignored when combined with other options)');
|
|
333
|
+
program.option('-z, --zero', 'Minify all HTML files in the current folder and its subfolders in place (except node_modules), using comprehensive settings (standalone—the flag is ignored when combined with other options)');
|
|
334
334
|
program.option('-I --input-dir <dir>', 'Specify an input directory');
|
|
335
335
|
program.option('-X --ignore-dir <patterns>', 'Exclude directories—relative to input directory—from processing (comma-separated, overrides config file setting)');
|
|
336
336
|
program.option('-O --output-dir <dir>', 'Specify an output directory');
|
|
@@ -113,6 +113,16 @@ export type MinifierOptions = {
|
|
|
113
113
|
* Default: `false`
|
|
114
114
|
*/
|
|
115
115
|
collapseInlineTagWhitespace?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Remove whitespace next to a no-break space (`U+00A0`), narrow no-break
|
|
118
|
+
* space (`U+202F`), or figure space (`U+2007`) in text (for example
|
|
119
|
+
* `a b` → `a b`), which changes how the text renders. Runs of
|
|
120
|
+
* no-break spaces are kept.
|
|
121
|
+
* Must also enable `collapseWhitespace` to have effect.
|
|
122
|
+
*
|
|
123
|
+
* Default: `false`
|
|
124
|
+
*/
|
|
125
|
+
collapseNoBreakSpaces?: boolean;
|
|
116
126
|
/**
|
|
117
127
|
* Collapse multiple whitespace characters into one where allowed. Also
|
|
118
128
|
* controls trimming behaviour in several code paths.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js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AE,MAAM,KAAK,MAAM,CAAC,CAQ5C;;;;;;;;;IAAiB,mBAAmB,AAApC,CAQA,EARO,OAAO,CAQd;;;;;;;IAAiB,eAAe,AAAhC,CAKF,EALS,OAAO,CAKhB;CAAA,CAAA;AA0EE,YAAkB,UAAU,GAG5B;;;;IAAe,IAAI,EAAZ,MAAM,CACb;;;;IAAe,IAAI,EAAZ,MAAM,CACb;;;;IAAe,IAAI,EAAZ,MAAM,CACb;;;;IAAe,KAAK,EAAb,MAAM,CACf;CAAA,CAAA;AAssDD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,IAFhB;IAAE,GAAG,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,UAAU,CAAA;CAAE,CAQhE;AA2FD;;;;GAIG;AACH,eAAO,MAAM,MAAM,UAJR,MAAM,YACN,eAAe,KACb,OAAO,CAAC,MAAM,CAsE1B,CAAC;AAIF,OAAO,EACL,OAAO,EACP,SAAS,EACT,cAAc,EACf,CAAC"}
|
|
@@ -26,7 +26,10 @@ declare const RE_EMPTY_ATTRIBUTE: RegExp;
|
|
|
26
26
|
declare const inlineElementsToKeepWhitespaceAround: Set<string>;
|
|
27
27
|
declare const inlineElementsToKeepWhitespaceWithin: Set<string>;
|
|
28
28
|
declare const inlineElementsToKeepWhitespace: Set<string>;
|
|
29
|
-
|
|
29
|
+
/** @param {Iterable<string>} names */
|
|
30
|
+
declare const toEndTags: (names: Iterable<string>) => Set<string>;
|
|
31
|
+
declare const inlineElementsToKeepWhitespaceWithinEither: Set<string>;
|
|
32
|
+
declare const formControlElementsEither: Set<string>;
|
|
30
33
|
declare const generalDefaults: {
|
|
31
34
|
autocorrect: string;
|
|
32
35
|
fetchpriority: string;
|
|
@@ -124,5 +127,5 @@ declare const svgoPluginsInline: {
|
|
|
124
127
|
};
|
|
125
128
|
}[];
|
|
126
129
|
declare const namesForeignMixedCase: Map<string, string>;
|
|
127
|
-
export { RE_WS_START, RE_WS_END, RE_WS_ONLY, RE_WS_NBSP_END, RE_ALL_WS_NBSP, RE_NBSP_LEADING_GROUP, RE_NBSP_LEAD_GROUP, RE_NBSP_TRAILING_GROUP, RE_NBSP_TRAILING_STRIP, RE_EVENT_ATTR_DEFAULT, RE_CAN_REMOVE_ATTR_QUOTES, RE_TRAILING_SEMICOLON, RE_AMP_ENTITY, RE_LEGACY_ENTITIES, RE_ESCAPE_LT, RE_ESCAPE_LT_RAW_TEXT, RE_HTML_ENCODING, RE_ATTR_WS_CHECK, RE_ATTR_WS_COLLAPSE, RE_ATTR_WS_TRIM, RE_STYLE_ELEMENT, RE_EMPTY_ATTRIBUTE, inlineElementsToKeepWhitespaceAround, inlineElementsToKeepWhitespaceWithin, inlineElementsToKeepWhitespace,
|
|
130
|
+
export { RE_WS_START, RE_WS_END, RE_WS_ONLY, RE_WS_NBSP_END, RE_ALL_WS_NBSP, RE_NBSP_LEADING_GROUP, RE_NBSP_LEAD_GROUP, RE_NBSP_TRAILING_GROUP, RE_NBSP_TRAILING_STRIP, RE_EVENT_ATTR_DEFAULT, RE_CAN_REMOVE_ATTR_QUOTES, RE_TRAILING_SEMICOLON, RE_AMP_ENTITY, RE_LEGACY_ENTITIES, RE_ESCAPE_LT, RE_ESCAPE_LT_RAW_TEXT, RE_HTML_ENCODING, RE_ATTR_WS_CHECK, RE_ATTR_WS_COLLAPSE, RE_ATTR_WS_TRIM, RE_STYLE_ELEMENT, RE_EMPTY_ATTRIBUTE, inlineElementsToKeepWhitespaceAround, inlineElementsToKeepWhitespaceWithin, inlineElementsToKeepWhitespace, inlineElementsToKeepWhitespaceWithinEither, formControlElementsEither, toEndTags, generalDefaults, tagDefaults, executableScriptsMimetypes, keepScriptsMimetypes, jsonScriptTypes, isSimpleBoolean, isBooleanValue, collapsibleValues, srcsetElements, MISSING_DEPENDENCY, namesForeignMixedCase, svgoPluginsInline, optionalStartTags, optionalEndTags, headerElements, descriptionElements, pBlockElements, pInlineElements, rubyEndTagOmission, rubyRtcEndTagOmission, optionElements, tableContentElements, tableSectionElements, cellElements, topLevelElements, compactElements, looseElements, trailingElements, htmlElements, specialContentElements, genericRawTextElements, endlessRawTextElements, escapableRawTextElements, rawTextElements };
|
|
128
131
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH,QAAA,MAAM,WAAW,QAAkB,CAAC;AACpC,QAAA,MAAM,SAAS,QAAkB,CAAC;AAClC,QAAA,MAAM,UAAU,QAAmB,CAAC;AACpC,QAAA,MAAM,cAAc,QAAqB,CAAC;AAC1C,QAAA,MAAM,cAAc,QAAsB,CAAC;AAC3C,QAAA,MAAM,qBAAqB,QAAuB,CAAC;AACnD,QAAA,MAAM,kBAAkB,QAAqB,CAAC;AAC9C,QAAA,MAAM,sBAAsB,QAAqB,CAAC;AAClD,QAAA,MAAM,sBAAsB,QAAc,CAAC;AAC3C,QAAA,MAAM,qBAAqB,QAAkB,CAAC;AAC9C,QAAA,MAAM,yBAAyB,QAA0B,CAAC;AAC1D,QAAA,MAAM,qBAAqB,QAAO,CAAC;AACnC,QAAA,MAAM,aAAa,QAAwB,CAAC;AAC5C,QAAA,MAAM,kBAAkB,QAA+oB,CAAC;AACxqB,QAAA,MAAM,YAAY,QAAO,CAAC;AAK1B,QAAA,MAAM,qBAAqB,EAAc,MAAM,CAAC,MAAM,EAAE,MAAM,CAG3D,CAAC;AAGJ,QAAA,MAAM,gBAAgB,QAA4C,CAAC;AACnE,QAAA,MAAM,gBAAgB,QAAgB,CAAC;AACvC,QAAA,MAAM,mBAAmB,QAAkB,CAAC;AAC5C,QAAA,MAAM,eAAe,QAAiC,CAAC;AACvD,QAAA,MAAM,gBAAgB,QAAkB,CAAC;AACzC,QAAA,MAAM,kBAAkB,QAE6B,CAAC;AAKtD,QAAA,MAAM,oCAAoC,aAAqY,CAAC;AAGhb,QAAA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AAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EAGjB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,YAAY,EAGZ,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,EAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"option-definitions.d.ts","sourceRoot":"","sources":["../../../src/lib/option-definitions.js"],"names":[],"mappings":"AAAA;;GAEG;AAGA,YAAkB,gBAAgB,GAClC;;;;IAAmB,WAAW,EAAnB,MAAM,CACjB;;;;IAAoB,sBAAsB,AAA1C,CACA,EADW,MAAM,CACjB;;;;IAAmB,IAAI,EAAZ,MAAM,CACnB;CAAA,CAAA;AALD;;;;;GAKG;AAEH,+CAA+C;AAC/C,QAAA,MAAM,iBAAiB,EADZ,MAAM,CAAC,MAAM,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"option-definitions.d.ts","sourceRoot":"","sources":["../../../src/lib/option-definitions.js"],"names":[],"mappings":"AAAA;;GAEG;AAGA,YAAkB,gBAAgB,GAClC;;;;IAAmB,WAAW,EAAnB,MAAM,CACjB;;;;IAAoB,sBAAsB,AAA1C,CACA,EADW,MAAM,CACjB;;;;IAAmB,IAAI,EAAZ,MAAM,CACnB;CAAA,CAAA;AALD;;;;;GAKG;AAEH,+CAA+C;AAC/C,QAAA,MAAM,iBAAiB,EADZ,MAAM,CAAC,MAAM,EAAE,gBAAgB,CA2MzC,CAAC;AAEF,QAAA,MAAM,cAAc;IAClB,qBAAqB;IACrB,oBAAoB;IAIpB,qBAAqB;IAIrB,wBAAwB;CACzB,CAAC;AAIF,OAAO,EACL,iBAAiB,EACjB,cAAc,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Whitespace: (str: string) => string;
|
|
6
6
|
/** @param {string} str */
|
|
7
|
+
declare function endsWithWhitespace(str: string): boolean;
|
|
8
|
+
/** @param {string} str */
|
|
7
9
|
declare function collapseWhitespaceAll(str: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} str
|
|
12
|
+
* @param {{decodeEntities?: boolean | undefined, preserveLineBreaks?: boolean | undefined}} options
|
|
13
|
+
*/
|
|
14
|
+
declare function collapseNoBreakSpaces(str: string, options: {
|
|
15
|
+
decodeEntities?: boolean | undefined;
|
|
16
|
+
preserveLineBreaks?: boolean | undefined;
|
|
17
|
+
}): string;
|
|
8
18
|
/**
|
|
9
19
|
* @param {string} str
|
|
10
20
|
* @param {{preserveLineBreaks?: boolean | undefined, conservativeCollapse?: boolean | undefined}} options
|
|
@@ -16,6 +26,45 @@ declare function collapseWhitespace(str: string, options: {
|
|
|
16
26
|
preserveLineBreaks?: boolean | undefined;
|
|
17
27
|
conservativeCollapse?: boolean | undefined;
|
|
18
28
|
}, trimLeft: boolean, trimRight: boolean, collapseAll?: boolean): string;
|
|
29
|
+
export type InlineSets = {
|
|
30
|
+
/**
|
|
31
|
+
* - Elements whose surrounding whitespace is kept
|
|
32
|
+
*/
|
|
33
|
+
around: Set<string>;
|
|
34
|
+
/**
|
|
35
|
+
* - The same, spelled as end tags
|
|
36
|
+
*/
|
|
37
|
+
aroundEnd: Set<string>;
|
|
38
|
+
/**
|
|
39
|
+
* - Elements whose inner whitespace is kept
|
|
40
|
+
*/
|
|
41
|
+
within: Set<string>;
|
|
42
|
+
/**
|
|
43
|
+
* - The same, spelled as end tags
|
|
44
|
+
*/
|
|
45
|
+
withinEnd: Set<string>;
|
|
46
|
+
/**
|
|
47
|
+
* - `within` under both spellings
|
|
48
|
+
*/
|
|
49
|
+
withinEither: Set<string>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* @typedef {object} InlineSets
|
|
53
|
+
* @prop {Set<string>} around - Elements whose surrounding whitespace is kept
|
|
54
|
+
* @prop {Set<string>} aroundEnd - The same, spelled as end tags
|
|
55
|
+
* @prop {Set<string>} within - Elements whose inner whitespace is kept
|
|
56
|
+
* @prop {Set<string>} withinEnd - The same, spelled as end tags
|
|
57
|
+
* @prop {Set<string>} withinEither - `within` under both spellings
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* Inline-element membership for the whitespace pass, each set paired with its end-tag
|
|
61
|
+
* spelling so a lookup takes the tag as it comes rather than slicing off the slash
|
|
62
|
+
* @param {Set<string>} around
|
|
63
|
+
* @param {Set<string>} within
|
|
64
|
+
* @returns {InlineSets}
|
|
65
|
+
*/
|
|
66
|
+
declare function buildInlineSets(around: Set<string>, within: Set<string>): InlineSets;
|
|
67
|
+
declare const defaultInlineSets: InlineSets;
|
|
19
68
|
/**
|
|
20
69
|
* @param {string} str
|
|
21
70
|
* @param {string} prevTag
|
|
@@ -23,8 +72,7 @@ declare function collapseWhitespace(str: string, options: {
|
|
|
23
72
|
* @param {Array<{name: string, value?: string}>} prevAttrs
|
|
24
73
|
* @param {Array<{name: string, value?: string}>} nextAttrs
|
|
25
74
|
* @param {{preserveLineBreaks?: boolean, conservativeCollapse?: boolean, collapseInlineTagWhitespace?: boolean}} options
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {Set<string>} inlineTextSet
|
|
75
|
+
* @param {InlineSets} inlineSets
|
|
28
76
|
*/
|
|
29
77
|
declare function collapseWhitespaceSmart(str: string, prevTag: string, nextTag: string, prevAttrs: Array<{
|
|
30
78
|
name: string;
|
|
@@ -36,10 +84,10 @@ declare function collapseWhitespaceSmart(str: string, prevTag: string, nextTag:
|
|
|
36
84
|
preserveLineBreaks?: boolean;
|
|
37
85
|
conservativeCollapse?: boolean;
|
|
38
86
|
collapseInlineTagWhitespace?: boolean;
|
|
39
|
-
},
|
|
87
|
+
}, inlineSets: InlineSets): string;
|
|
40
88
|
/** @param {string} tag */
|
|
41
89
|
declare function canCollapseWhitespace(tag: string): boolean;
|
|
42
90
|
/** @param {string} tag */
|
|
43
91
|
declare function canTrimWhitespace(tag: string): boolean;
|
|
44
|
-
export { trimWhitespace, collapseWhitespaceAll, collapseWhitespace, collapseWhitespaceSmart, canCollapseWhitespace, canTrimWhitespace };
|
|
92
|
+
export { buildInlineSets, defaultInlineSets, endsWithWhitespace, trimWhitespace, collapseWhitespaceAll, collapseNoBreakSpaces, collapseWhitespace, collapseWhitespaceSmart, canCollapseWhitespace, canTrimWhitespace };
|
|
45
93
|
//# sourceMappingURL=whitespace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whitespace.d.ts","sourceRoot":"","sources":["../../../src/lib/whitespace.js"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"whitespace.d.ts","sourceRoot":"","sources":["../../../src/lib/whitespace.js"],"names":[],"mappings":"AAAA;;GAEG;AAyBH,0BAA0B;AAC1B,QAAA,MAAM,cAAc,QADR,MAAM,WAQjB,CAAC;AAaF,0BAA0B;AAC1B,iBAAS,kBAAkB,CAAC,GAAG,EADnB,MACmB,WAE9B;AAaD,0BAA0B;AAC1B,iBAAS,qBAAqB,CAAC,GAAG,EADtB,MACsB,UAOjC;AAwCD;;;GAGG;AACH,iBAAS,qBAAqB,CAAC,GAAG,EAHvB,MAGuB,EAAE,OAAO,EAFhC;IAAC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAAC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAE/C,UAU1C;AAID;;;;;;GAMG;AACH,iBAAS,kBAAkB,CAAC,GAAG,EANpB,MAMoB,EAAE,OAAO,EAL7B;IAAC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAAC,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAKxD,EAAE,QAAQ,EAJvC,OAIuC,EAAE,SAAS,EAHlD,OAGkD,EAAE,WAAW,AAFvE,CAA8B,EAAtB,OAEuE,UA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,EACd,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EAClB,CAAC"}
|
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
"description": "Collapse whitespace more aggressively between inline elements—use with `--collapse-whitespace`",
|
|
68
68
|
"type": "boolean"
|
|
69
69
|
},
|
|
70
|
+
"collapseNoBreakSpaces": {
|
|
71
|
+
"description": "Remove whitespace next to no-break spaces, narrow no-break spaces, and figure spaces in text (e.g., `a b` → `a b`), keeping runs of them—use with `--collapse-whitespace`",
|
|
72
|
+
"type": "boolean"
|
|
73
|
+
},
|
|
70
74
|
"collapseWhitespace": {
|
|
71
75
|
"description": "Collapse whitespace that contributes to text nodes in a document tree",
|
|
72
76
|
"type": "boolean"
|
package/package.json
CHANGED
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
},
|
|
15
15
|
"description": "Highly effective, super-configurable, well-tested web page minifier (enhanced successor to HTML Minifier)",
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@commitlint/cli": "^21.2.
|
|
17
|
+
"@commitlint/cli": "^21.2.3",
|
|
18
18
|
"@eslint/js": "^10.0.1",
|
|
19
19
|
"@swc/core": "^1.16.2",
|
|
20
|
-
"@types/node": "^26.6.
|
|
21
|
-
"eslint": "^10.
|
|
20
|
+
"@types/node": "^26.6.3",
|
|
21
|
+
"eslint": "^10.11.0",
|
|
22
22
|
"globals": "^17.12.0",
|
|
23
23
|
"typescript": "^7.0.2",
|
|
24
|
-
"vite": "^8.3.
|
|
24
|
+
"vite": "^8.3.1"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
27
|
"node": ">=22.13"
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
},
|
|
96
96
|
"type": "module",
|
|
97
97
|
"types": "dist/types/htmlminifier.d.ts",
|
|
98
|
-
"version": "8.
|
|
98
|
+
"version": "8.6.0"
|
|
99
99
|
}
|
package/src/htmlminifier.js
CHANGED
|
@@ -32,8 +32,12 @@ import {
|
|
|
32
32
|
} from './lib/constants.js';
|
|
33
33
|
|
|
34
34
|
import {
|
|
35
|
+
buildInlineSets,
|
|
36
|
+
defaultInlineSets,
|
|
37
|
+
endsWithWhitespace,
|
|
35
38
|
trimWhitespace,
|
|
36
39
|
collapseWhitespaceAll,
|
|
40
|
+
collapseNoBreakSpaces,
|
|
37
41
|
collapseWhitespace,
|
|
38
42
|
collapseWhitespaceSmart,
|
|
39
43
|
canCollapseWhitespace as defaultCanCollapseWhitespace,
|
|
@@ -182,6 +186,15 @@ import { toFragment, replaceCustomFragments } from './lib/fragments.js';
|
|
|
182
186
|
*
|
|
183
187
|
* Default: `false`
|
|
184
188
|
*
|
|
189
|
+
* @prop {boolean} [collapseNoBreakSpaces]
|
|
190
|
+
* Remove whitespace next to a no-break space (`U+00A0`), narrow no-break
|
|
191
|
+
* space (`U+202F`), or figure space (`U+2007`) in text (for example
|
|
192
|
+
* `a b` → `a b`), which changes how the text renders. Runs of
|
|
193
|
+
* no-break spaces are kept.
|
|
194
|
+
* Must also enable `collapseWhitespace` to have effect.
|
|
195
|
+
*
|
|
196
|
+
* Default: `false`
|
|
197
|
+
*
|
|
185
198
|
* @prop {boolean} [collapseWhitespace]
|
|
186
199
|
* Collapse multiple whitespace characters into one where allowed. Also
|
|
187
200
|
* controls trimming behaviour in several code paths.
|
|
@@ -1102,6 +1115,9 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1102
1115
|
const inlineElements = normalizedCustomElements.length
|
|
1103
1116
|
? new Set([...inlineElementsToKeepWhitespaceAround, ...normalizedCustomElements])
|
|
1104
1117
|
: inlineElementsToKeepWhitespaceAround;
|
|
1118
|
+
const inlineSets = normalizedCustomElements.length
|
|
1119
|
+
? buildInlineSets(inlineElements, inlineTextSet)
|
|
1120
|
+
: defaultInlineSets;
|
|
1105
1121
|
|
|
1106
1122
|
// Parse `removeEmptyElementsExcept` option
|
|
1107
1123
|
/** @type {Array<{tag: string, attrs: {[x: string]: string | undefined} | null}>} */
|
|
@@ -1364,13 +1380,27 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1364
1380
|
|
|
1365
1381
|
// Look for trailing whitespaces, bypass any inline tags
|
|
1366
1382
|
function trimTrailingWhitespace(/** @type {number} */ index, /** @type {string} */ nextTag) {
|
|
1383
|
+
// Nothing to the left of the text is in play here, so only its trailing run can
|
|
1384
|
+
// change—unless preserved line breaks bring the leading run into play, too
|
|
1385
|
+
const trailingOnly = !options.preserveLineBreaks;
|
|
1367
1386
|
for (let prevTag = ''; index >= 0 && canTrimWhitespace(prevTag, emptyAttrs); index--) {
|
|
1368
1387
|
const str = buffer[index] ?? '';
|
|
1369
1388
|
const endTagName = matchPlainEndTag(str);
|
|
1370
1389
|
if (endTagName !== null) {
|
|
1371
1390
|
prevTag = endTagName;
|
|
1372
|
-
|
|
1373
|
-
|
|
1391
|
+
continue;
|
|
1392
|
+
}
|
|
1393
|
+
// A tag ends the search, and so does text that survives collapsing. Text with no
|
|
1394
|
+
// trailing run comes back from the call unchanged, so it can end the search on
|
|
1395
|
+
// the spot; empty text cannot, as the search has to carry on past it
|
|
1396
|
+
if (str.charCodeAt(str.length - 1) === 62 /* > */) {
|
|
1397
|
+
break;
|
|
1398
|
+
}
|
|
1399
|
+
if (trailingOnly && str && !endsWithWhitespace(str)) {
|
|
1400
|
+
break;
|
|
1401
|
+
}
|
|
1402
|
+
buffer[index] = collapseWhitespaceSmart(str, '', nextTag, emptyAttrs, emptyAttrs, options, inlineSets);
|
|
1403
|
+
if (buffer[index]) {
|
|
1374
1404
|
break;
|
|
1375
1405
|
}
|
|
1376
1406
|
}
|
|
@@ -1386,7 +1416,9 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1386
1416
|
// minification run then removes
|
|
1387
1417
|
while (charsIndex > 0) {
|
|
1388
1418
|
const item = buffer[charsIndex] ?? '';
|
|
1389
|
-
|
|
1419
|
+
// Comments and empty entries only, as `<!…` or nothing at all
|
|
1420
|
+
const skippable = item === '' || (item.charCodeAt(0) === 60 /* < */ && item.charCodeAt(1) === 33 /* ! */);
|
|
1421
|
+
if (!skippable || (uidIgnore && item.indexOf(uidIgnore) !== -1)) {
|
|
1390
1422
|
break;
|
|
1391
1423
|
}
|
|
1392
1424
|
charsIndex--;
|
|
@@ -1473,12 +1505,12 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1473
1505
|
}
|
|
1474
1506
|
trimTrailingWhitespace(tagIndex - 1, 'br');
|
|
1475
1507
|
}
|
|
1476
|
-
} else if (
|
|
1508
|
+
} else if (inlineSets.withinEither.has(textPrevTag)) {
|
|
1477
1509
|
text = collapseWhitespace(text, options, /(?:^|\s)$/.test(currentChars), false);
|
|
1478
1510
|
}
|
|
1479
1511
|
}
|
|
1480
1512
|
if (textPrevTag || textNextTag) {
|
|
1481
|
-
text = collapseWhitespaceSmart(text, effectivePrevTag, textNextTag, textPrevAttrs, textNextAttrs, options,
|
|
1513
|
+
text = collapseWhitespaceSmart(text, effectivePrevTag, textNextTag, textPrevAttrs, textNextAttrs, options, inlineSets);
|
|
1482
1514
|
} else {
|
|
1483
1515
|
text = collapseWhitespace(text, options, true, true);
|
|
1484
1516
|
}
|
|
@@ -1489,6 +1521,9 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1489
1521
|
if (!stackNoCollapseWhitespace.length && textNextTag !== 'html' && !(textPrevTag && textNextTag)) {
|
|
1490
1522
|
text = collapseWhitespace(text, options, false, false, true);
|
|
1491
1523
|
}
|
|
1524
|
+
if (options.collapseNoBreakSpaces && !stackNoCollapseWhitespace.length && !holdsRawText()) {
|
|
1525
|
+
text = collapseNoBreakSpaces(text, options);
|
|
1526
|
+
}
|
|
1492
1527
|
}
|
|
1493
1528
|
return text;
|
|
1494
1529
|
}
|
package/src/lib/constants.js
CHANGED
|
@@ -50,6 +50,15 @@ const inlineElementsToKeepWhitespace = new Set(['comment', 'img', 'input', 'wbr'
|
|
|
50
50
|
// Form control elements (for conditional whitespace collapsing)
|
|
51
51
|
const formControlElements = new Set(['input', 'button', 'select', 'textarea', 'output', 'meter', 'progress']);
|
|
52
52
|
|
|
53
|
+
// End-tag spellings (`/a`) of a set of element names
|
|
54
|
+
/** @param {Iterable<string>} names */
|
|
55
|
+
const toEndTags = names => new Set(Array.from(names, name => '/' + name));
|
|
56
|
+
|
|
57
|
+
// Membership under either spelling, for the whitespace checks that ignore the slash;
|
|
58
|
+
// looking a tag up as it comes keeps the hot path from slicing one string per call
|
|
59
|
+
const inlineElementsToKeepWhitespaceWithinEither = new Set([...inlineElementsToKeepWhitespaceWithin, ...toEndTags(inlineElementsToKeepWhitespaceWithin)]);
|
|
60
|
+
const formControlElementsEither = new Set([...formControlElements, ...toEndTags(formControlElements)]);
|
|
61
|
+
|
|
53
62
|
// Default attribute values
|
|
54
63
|
|
|
55
64
|
// Default attribute values (could apply to any element)
|
|
@@ -285,7 +294,9 @@ export {
|
|
|
285
294
|
inlineElementsToKeepWhitespaceAround,
|
|
286
295
|
inlineElementsToKeepWhitespaceWithin,
|
|
287
296
|
inlineElementsToKeepWhitespace,
|
|
288
|
-
|
|
297
|
+
inlineElementsToKeepWhitespaceWithinEither,
|
|
298
|
+
formControlElementsEither,
|
|
299
|
+
toEndTags,
|
|
289
300
|
|
|
290
301
|
// Default values
|
|
291
302
|
generalDefaults,
|
|
@@ -39,6 +39,10 @@ const optionDefinitions = {
|
|
|
39
39
|
description: 'Collapse whitespace more aggressively between inline elements—use with `--collapse-whitespace`',
|
|
40
40
|
type: 'boolean'
|
|
41
41
|
},
|
|
42
|
+
collapseNoBreakSpaces: {
|
|
43
|
+
description: 'Remove whitespace next to no-break spaces, narrow no-break spaces, and figure spaces in text (e.g., `a b` → `a b`), keeping runs of them—use with `--collapse-whitespace`',
|
|
44
|
+
type: 'boolean'
|
|
45
|
+
},
|
|
42
46
|
collapseWhitespace: {
|
|
43
47
|
description: 'Collapse whitespace that contributes to text nodes in a document tree',
|
|
44
48
|
type: 'boolean'
|
package/src/lib/options.js
CHANGED
|
@@ -138,6 +138,7 @@ const optionDependencies = [
|
|
|
138
138
|
{ option: 'canMinifyJS', requires: 'minifyJS', unusable: replacedByOwnFunction('minifyJS'), clear: true },
|
|
139
139
|
{ option: 'canMinifySVG', requires: 'minifySVG', unusable: replacedByOwnFunction('minifySVG'), clear: true },
|
|
140
140
|
{ option: 'collapseInlineTagWhitespace', requires: 'collapseWhitespace' },
|
|
141
|
+
{ option: 'collapseNoBreakSpaces', requires: 'collapseWhitespace' },
|
|
141
142
|
{ option: 'conservativeCollapse', requires: 'collapseWhitespace' },
|
|
142
143
|
{ option: 'customEventAttributes', requires: 'minifyJS' },
|
|
143
144
|
{ option: 'inlineCustomElements', requires: 'collapseWhitespace' },
|
package/src/lib/unused-css.js
CHANGED
|
@@ -70,7 +70,7 @@ function unescapeIdentifier(identifier) {
|
|
|
70
70
|
if (!hex) {
|
|
71
71
|
return literal;
|
|
72
72
|
}
|
|
73
|
-
// Per CSS Syntax spec, a null, surrogate, or out-of-range escape becomes U+FFFD
|
|
73
|
+
// Per CSS Syntax spec, a null, surrogate, or out-of-range escape becomes `U+FFFD`
|
|
74
74
|
const code = parseInt(hex, 16);
|
|
75
75
|
return (code === 0 || code > 0x10FFFF || (code >= 0xD800 && code <= 0xDFFF))
|
|
76
76
|
? '\uFFFD'
|
package/src/lib/whitespace.js
CHANGED
|
@@ -9,14 +9,18 @@ import {
|
|
|
9
9
|
RE_NBSP_TRAILING_GROUP,
|
|
10
10
|
RE_NBSP_TRAILING_STRIP,
|
|
11
11
|
inlineElementsToKeepWhitespace,
|
|
12
|
+
inlineElementsToKeepWhitespaceAround,
|
|
12
13
|
inlineElementsToKeepWhitespaceWithin,
|
|
13
|
-
|
|
14
|
+
inlineElementsToKeepWhitespaceWithinEither,
|
|
15
|
+
formControlElementsEither,
|
|
16
|
+
toEndTags
|
|
14
17
|
} from './constants.js';
|
|
15
18
|
|
|
16
19
|
const RE_ANY_WS_NBSP = /[ \n\r\t\f\xA0]/;
|
|
17
20
|
const RE_TAB_NBSP = /[\t\xA0]/;
|
|
18
21
|
const RE_ASCII_WS_RUN = /[ \n\r\f]+/g;
|
|
19
|
-
|
|
22
|
+
// Every reason `collapseWhitespaceAllKnown` has to do any work at all, in one scan
|
|
23
|
+
const RE_COLLAPSIBLE = /[\t\xA0\n\r\f]| {2}/;
|
|
20
24
|
const RE_NON_WS = /\S/;
|
|
21
25
|
|
|
22
26
|
// Trim whitespace
|
|
@@ -41,6 +45,12 @@ function isWsOrNbsp(code) {
|
|
|
41
45
|
return code === 32 || code === 10 || code === 13 || code === 9 || code === 12 || code === 160;
|
|
42
46
|
}
|
|
43
47
|
|
|
48
|
+
// Whether the last character is whitespace, no-break space included
|
|
49
|
+
/** @param {string} str */
|
|
50
|
+
function endsWithWhitespace(str) {
|
|
51
|
+
return str.length > 0 && isWsOrNbsp(str.charCodeAt(str.length - 1));
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
// Collapse all whitespace
|
|
45
55
|
|
|
46
56
|
// Module scope so the hot path doesn’t allocate a closure per call
|
|
@@ -65,14 +75,57 @@ function collapseWhitespaceAll(str) {
|
|
|
65
75
|
// As `collapseWhitespaceAll`, for callers that already know `str` holds whitespace
|
|
66
76
|
/** @param {string} str */
|
|
67
77
|
function collapseWhitespaceAllKnown(str) {
|
|
78
|
+
// Most text reaching here is already collapsed, so settle that in one scan rather
|
|
79
|
+
// than two—single spaces with no tab and no no-break space leave nothing to do
|
|
80
|
+
if (!RE_COLLAPSIBLE.test(str)) {
|
|
81
|
+
return str;
|
|
82
|
+
}
|
|
68
83
|
// Only a tab or a no-break space makes the replacement depend on the run itself;
|
|
69
84
|
// without either, every run becomes one space and no per-match callback is needed
|
|
70
85
|
if (!RE_TAB_NBSP.test(str)) {
|
|
71
|
-
return
|
|
86
|
+
return str.replace(RE_ASCII_WS_RUN, ' ');
|
|
72
87
|
}
|
|
73
88
|
return str.replace(RE_ALL_WS_NBSP, collapseRun);
|
|
74
89
|
}
|
|
75
90
|
|
|
91
|
+
// Collapse whitespace into adjacent no-break spaces
|
|
92
|
+
|
|
93
|
+
// A no-break space (`U+00A0`), narrow no-break space (`U+202F`), or figure space (`U+2007`),
|
|
94
|
+
// literal or as a character reference; numeric references and ` ` also work without
|
|
95
|
+
// the semicolon in text
|
|
96
|
+
const RE_NO_BREAK_SPACE_WS = /([ \n\r\t\f]*)(\xA0|\u202F|\u2007|&(?:nbsp;?|NonBreakingSpace;|numsp;|#0*(?:160|8239|8199)(?![0-9]);?|#[xX]0*(?:[aA]0|202[fF]|2007)(?![0-9a-fA-F]);?))([ \n\r\t\f]*)/g;
|
|
97
|
+
// Decoded text holds references only as text, so there the characters alone count
|
|
98
|
+
const RE_NO_BREAK_SPACE_CHAR_WS = /([ \n\r\t\f]*)([\xA0\u202F\u2007])([ \n\r\t\f]*)/g;
|
|
99
|
+
const RE_LINE_BREAK = /[\n\r]/;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @param {string} _match
|
|
103
|
+
* @param {string} before
|
|
104
|
+
* @param {string} noBreakSpace
|
|
105
|
+
* @param {string} after
|
|
106
|
+
*/
|
|
107
|
+
function keepLineBreaks(_match, before, noBreakSpace, after) {
|
|
108
|
+
return (RE_LINE_BREAK.test(before) ? before : '') + noBreakSpace + (RE_LINE_BREAK.test(after) ? after : '');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Callers pass text whose whitespace runs are already collapsed, as each match
|
|
112
|
+
// rescans the run in front of it
|
|
113
|
+
/**
|
|
114
|
+
* @param {string} str
|
|
115
|
+
* @param {{decodeEntities?: boolean | undefined, preserveLineBreaks?: boolean | undefined}} options
|
|
116
|
+
*/
|
|
117
|
+
function collapseNoBreakSpaces(str, options) {
|
|
118
|
+
const decoded = Boolean(options.decodeEntities);
|
|
119
|
+
if (!str || (str.indexOf('\xA0') === -1 && str.indexOf('\u202F') === -1 && str.indexOf('\u2007') === -1 && (decoded || str.indexOf('&') === -1))) {
|
|
120
|
+
return str;
|
|
121
|
+
}
|
|
122
|
+
const pattern = decoded ? RE_NO_BREAK_SPACE_CHAR_WS : RE_NO_BREAK_SPACE_WS;
|
|
123
|
+
if (options.preserveLineBreaks) {
|
|
124
|
+
return str.replace(pattern, keepLineBreaks);
|
|
125
|
+
}
|
|
126
|
+
return str.replace(pattern, '$2');
|
|
127
|
+
}
|
|
128
|
+
|
|
76
129
|
// Collapse whitespace with options
|
|
77
130
|
|
|
78
131
|
/**
|
|
@@ -199,6 +252,36 @@ function collapseWhitespaceKnown(str, options, trimLeft, trimRight, collapseAll)
|
|
|
199
252
|
|
|
200
253
|
// Collapse whitespace smartly based on surrounding tags
|
|
201
254
|
|
|
255
|
+
/**
|
|
256
|
+
* @typedef {object} InlineSets
|
|
257
|
+
* @prop {Set<string>} around - Elements whose surrounding whitespace is kept
|
|
258
|
+
* @prop {Set<string>} aroundEnd - The same, spelled as end tags
|
|
259
|
+
* @prop {Set<string>} within - Elements whose inner whitespace is kept
|
|
260
|
+
* @prop {Set<string>} withinEnd - The same, spelled as end tags
|
|
261
|
+
* @prop {Set<string>} withinEither - `within` under both spellings
|
|
262
|
+
*/
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Inline-element membership for the whitespace pass, each set paired with its end-tag
|
|
266
|
+
* spelling so a lookup takes the tag as it comes rather than slicing off the slash
|
|
267
|
+
* @param {Set<string>} around
|
|
268
|
+
* @param {Set<string>} within
|
|
269
|
+
* @returns {InlineSets}
|
|
270
|
+
*/
|
|
271
|
+
function buildInlineSets(around, within) {
|
|
272
|
+
const withinEnd = toEndTags(within);
|
|
273
|
+
return {
|
|
274
|
+
around,
|
|
275
|
+
aroundEnd: toEndTags(around),
|
|
276
|
+
within,
|
|
277
|
+
withinEnd,
|
|
278
|
+
withinEither: new Set([...within, ...withinEnd])
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// The sets for a document without custom inline elements, built once
|
|
283
|
+
const defaultInlineSets = buildInlineSets(inlineElementsToKeepWhitespaceAround, inlineElementsToKeepWhitespaceWithin);
|
|
284
|
+
|
|
202
285
|
// Check if an input element has `type="hidden"`; module-scope so the hot path
|
|
203
286
|
// doesn’t allocate a closure per text node
|
|
204
287
|
/**
|
|
@@ -221,10 +304,9 @@ function isHiddenInput(attrs) {
|
|
|
221
304
|
* @param {Array<{name: string, value?: string}>} prevAttrs
|
|
222
305
|
* @param {Array<{name: string, value?: string}>} nextAttrs
|
|
223
306
|
* @param {{preserveLineBreaks?: boolean, conservativeCollapse?: boolean, collapseInlineTagWhitespace?: boolean}} options
|
|
224
|
-
* @param {
|
|
225
|
-
* @param {Set<string>} inlineTextSet
|
|
307
|
+
* @param {InlineSets} inlineSets
|
|
226
308
|
*/
|
|
227
|
-
function collapseWhitespaceSmart(str, prevTag, nextTag, prevAttrs, nextAttrs, options,
|
|
309
|
+
function collapseWhitespaceSmart(str, prevTag, nextTag, prevAttrs, nextAttrs, options, inlineSets) {
|
|
228
310
|
if (!str) return str;
|
|
229
311
|
|
|
230
312
|
// Fast path: No whitespace at all—every decision below would leave `str`
|
|
@@ -253,7 +335,7 @@ function collapseWhitespaceSmart(str, prevTag, nextTag, prevAttrs, nextAttrs, op
|
|
|
253
335
|
}
|
|
254
336
|
// Aggressive mode: Collapse between all form controls
|
|
255
337
|
if (inlineOption && (!trimLeft || !trimRight) &&
|
|
256
|
-
|
|
338
|
+
formControlElementsEither.has(prevTag) && formControlElementsEither.has(nextTag)) {
|
|
257
339
|
trimLeft = true;
|
|
258
340
|
trimRight = true;
|
|
259
341
|
}
|
|
@@ -262,21 +344,21 @@ function collapseWhitespaceSmart(str, prevTag, nextTag, prevAttrs, nextAttrs, op
|
|
|
262
344
|
if (trimLeft) {
|
|
263
345
|
if (inlineOption) {
|
|
264
346
|
// Still preserve whitespace around inline text elements
|
|
265
|
-
if (
|
|
347
|
+
if (inlineElementsToKeepWhitespaceWithinEither.has(prevTag)) {
|
|
266
348
|
trimLeft = false;
|
|
267
349
|
}
|
|
268
350
|
} else {
|
|
269
|
-
trimLeft = prevTag.charCodeAt(0) === 47 /* / */ ? !
|
|
351
|
+
trimLeft = prevTag.charCodeAt(0) === 47 /* / */ ? !inlineSets.aroundEnd.has(prevTag) : !inlineSets.within.has(prevTag);
|
|
270
352
|
}
|
|
271
353
|
}
|
|
272
354
|
|
|
273
355
|
if (trimRight) {
|
|
274
356
|
if (inlineOption) {
|
|
275
|
-
if (
|
|
357
|
+
if (inlineElementsToKeepWhitespaceWithinEither.has(nextTag)) {
|
|
276
358
|
trimRight = false;
|
|
277
359
|
}
|
|
278
360
|
} else {
|
|
279
|
-
trimRight = nextTag.charCodeAt(0) === 47 /* / */ ? !
|
|
361
|
+
trimRight = nextTag.charCodeAt(0) === 47 /* / */ ? !inlineSets.withinEnd.has(nextTag) : !inlineSets.around.has(nextTag);
|
|
280
362
|
}
|
|
281
363
|
}
|
|
282
364
|
|
|
@@ -287,11 +369,6 @@ function collapseWhitespaceSmart(str, prevTag, nextTag, prevAttrs, nextAttrs, op
|
|
|
287
369
|
return collapseWhitespaceKnown(str, options, trimLeft, trimRight, collapseAll);
|
|
288
370
|
}
|
|
289
371
|
|
|
290
|
-
/** @param {string} tag */
|
|
291
|
-
function stripSlash(tag) {
|
|
292
|
-
return tag && tag.charCodeAt(0) === 47 /* / */ ? tag.slice(1) : tag;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
372
|
// Collapse/trim whitespace for given tag
|
|
296
373
|
|
|
297
374
|
// `xmp`, `listing`, and `plaintext` render preformatted, as `pre` does
|
|
@@ -312,8 +389,12 @@ function canTrimWhitespace(tag) {
|
|
|
312
389
|
// Exports
|
|
313
390
|
|
|
314
391
|
export {
|
|
392
|
+
buildInlineSets,
|
|
393
|
+
defaultInlineSets,
|
|
394
|
+
endsWithWhitespace,
|
|
315
395
|
trimWhitespace,
|
|
316
396
|
collapseWhitespaceAll,
|
|
397
|
+
collapseNoBreakSpaces,
|
|
317
398
|
collapseWhitespace,
|
|
318
399
|
collapseWhitespaceSmart,
|
|
319
400
|
canCollapseWhitespace,
|