html-minifier-next 5.0.0 → 5.0.1
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/dist/htmlminifier.cjs
CHANGED
|
@@ -3993,6 +3993,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
3993
3993
|
const stackNoCollapseWhitespace = [];
|
|
3994
3994
|
let optionalStartTag = '';
|
|
3995
3995
|
let optionalEndTag = '';
|
|
3996
|
+
let optionalEndTagEmitted = false;
|
|
3996
3997
|
const ignoredMarkupChunks = [];
|
|
3997
3998
|
const ignoredCustomMarkupChunks = [];
|
|
3998
3999
|
let uidIgnore;
|
|
@@ -4197,12 +4198,15 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
4197
4198
|
optionalStartTag = '';
|
|
4198
4199
|
// End-tag-followed-by-start-tag omission rules
|
|
4199
4200
|
if (htmlTag && canRemovePrecedingTag(optionalEndTag, tag)) {
|
|
4200
|
-
|
|
4201
|
+
if (optionalEndTagEmitted) {
|
|
4202
|
+
removeEndTag();
|
|
4203
|
+
}
|
|
4201
4204
|
// `<colgroup>` cannot be omitted if preceding `</colgroup>` is omitted
|
|
4202
4205
|
// `<tbody>` cannot be omitted if preceding `</tbody>`, `</thead>`, or `</tfoot>` is omitted
|
|
4203
4206
|
optional = !isStartTagMandatory(optionalEndTag, tag);
|
|
4204
4207
|
}
|
|
4205
4208
|
optionalEndTag = '';
|
|
4209
|
+
optionalEndTagEmitted = false;
|
|
4206
4210
|
}
|
|
4207
4211
|
|
|
4208
4212
|
// Set whitespace flags for nested tags (e.g., `<code>` within a `<pre>`)
|
|
@@ -4292,10 +4296,11 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
4292
4296
|
// `</head>` may be omitted if not followed by space or comment
|
|
4293
4297
|
// `</p>` may be omitted if no more content in non-`</a>` parent
|
|
4294
4298
|
// except for `</dt>` or `</thead>`, end tags may be omitted if no more content in parent element
|
|
4295
|
-
if (tag && optionalEndTag && !trailingElements.has(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineElements.has(tag))) {
|
|
4299
|
+
if (tag && optionalEndTag && optionalEndTagEmitted && !trailingElements.has(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineElements.has(tag))) {
|
|
4296
4300
|
removeEndTag();
|
|
4297
4301
|
}
|
|
4298
4302
|
optionalEndTag = optionalEndTags.has(tag) ? tag : '';
|
|
4303
|
+
optionalEndTagEmitted = true;
|
|
4299
4304
|
}
|
|
4300
4305
|
|
|
4301
4306
|
if (options.removeEmptyElements && isElementEmpty && canRemoveElement(tag, attrs)) {
|
|
@@ -4311,10 +4316,11 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
4311
4316
|
removeStartTag();
|
|
4312
4317
|
optionalStartTag = '';
|
|
4313
4318
|
optionalEndTag = '';
|
|
4319
|
+
optionalEndTagEmitted = false;
|
|
4314
4320
|
} else {
|
|
4315
4321
|
// Preserve the element—add closing tag
|
|
4316
4322
|
if (autoGenerated && !options.includeAutoGeneratedTags) {
|
|
4317
|
-
|
|
4323
|
+
optionalEndTagEmitted = false;
|
|
4318
4324
|
} else {
|
|
4319
4325
|
buffer.push('</' + tag + '>');
|
|
4320
4326
|
}
|
|
@@ -4327,7 +4333,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
4327
4333
|
}
|
|
4328
4334
|
} else {
|
|
4329
4335
|
if (autoGenerated && !options.includeAutoGeneratedTags) {
|
|
4330
|
-
|
|
4336
|
+
optionalEndTagEmitted = false;
|
|
4331
4337
|
} else {
|
|
4332
4338
|
buffer.push('</' + tag + '>');
|
|
4333
4339
|
}
|
|
@@ -4424,12 +4430,13 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
4424
4430
|
optionalStartTag = '';
|
|
4425
4431
|
// `</html>` or `</body>` may be omitted if not followed by comment
|
|
4426
4432
|
// `</head>`, `</colgroup>`, or `</caption>` may be omitted if not followed by space or comment
|
|
4427
|
-
if (compactElements.has(optionalEndTag) || (looseElements.has(optionalEndTag) && !/^\s/.test(text))) {
|
|
4433
|
+
if (optionalEndTagEmitted && (compactElements.has(optionalEndTag) || (looseElements.has(optionalEndTag) && !/^\s/.test(text)))) {
|
|
4428
4434
|
removeEndTag();
|
|
4429
4435
|
}
|
|
4430
|
-
// Don
|
|
4436
|
+
// Don't reset optionalEndTag if text is only whitespace and will be collapsed (not conservatively)
|
|
4431
4437
|
if (!/^\s+$/.test(text) || !options.collapseWhitespace || options.conservativeCollapse) {
|
|
4432
4438
|
optionalEndTag = '';
|
|
4439
|
+
optionalEndTagEmitted = false;
|
|
4433
4440
|
}
|
|
4434
4441
|
}
|
|
4435
4442
|
charsPrevTag = /^\s*$/.test(text) ? prevTag : 'comment';
|
|
@@ -4475,6 +4482,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
4475
4482
|
// Preceding comments suppress tag omissions
|
|
4476
4483
|
optionalStartTag = '';
|
|
4477
4484
|
optionalEndTag = '';
|
|
4485
|
+
optionalEndTagEmitted = false;
|
|
4478
4486
|
}
|
|
4479
4487
|
|
|
4480
4488
|
// Optimize whitespace collapsing between consecutive `htmlmin:ignore` placeholder comments
|
|
@@ -4567,7 +4575,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
4567
4575
|
removeStartTag();
|
|
4568
4576
|
}
|
|
4569
4577
|
// except for `</dt>` or `</thead>`, end tags may be omitted if no more content in parent element
|
|
4570
|
-
if (optionalEndTag && !trailingElements.has(optionalEndTag)) {
|
|
4578
|
+
if (optionalEndTag && optionalEndTagEmitted && !trailingElements.has(optionalEndTag)) {
|
|
4571
4579
|
removeEndTag();
|
|
4572
4580
|
}
|
|
4573
4581
|
}
|
|
@@ -6606,6 +6606,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
6606
6606
|
const stackNoCollapseWhitespace = [];
|
|
6607
6607
|
let optionalStartTag = '';
|
|
6608
6608
|
let optionalEndTag = '';
|
|
6609
|
+
let optionalEndTagEmitted = false;
|
|
6609
6610
|
const ignoredMarkupChunks = [];
|
|
6610
6611
|
const ignoredCustomMarkupChunks = [];
|
|
6611
6612
|
let uidIgnore;
|
|
@@ -6810,12 +6811,15 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
6810
6811
|
optionalStartTag = '';
|
|
6811
6812
|
// End-tag-followed-by-start-tag omission rules
|
|
6812
6813
|
if (htmlTag && canRemovePrecedingTag(optionalEndTag, tag)) {
|
|
6813
|
-
|
|
6814
|
+
if (optionalEndTagEmitted) {
|
|
6815
|
+
removeEndTag();
|
|
6816
|
+
}
|
|
6814
6817
|
// `<colgroup>` cannot be omitted if preceding `</colgroup>` is omitted
|
|
6815
6818
|
// `<tbody>` cannot be omitted if preceding `</tbody>`, `</thead>`, or `</tfoot>` is omitted
|
|
6816
6819
|
optional = !isStartTagMandatory(optionalEndTag, tag);
|
|
6817
6820
|
}
|
|
6818
6821
|
optionalEndTag = '';
|
|
6822
|
+
optionalEndTagEmitted = false;
|
|
6819
6823
|
}
|
|
6820
6824
|
|
|
6821
6825
|
// Set whitespace flags for nested tags (e.g., `<code>` within a `<pre>`)
|
|
@@ -6905,10 +6909,11 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
6905
6909
|
// `</head>` may be omitted if not followed by space or comment
|
|
6906
6910
|
// `</p>` may be omitted if no more content in non-`</a>` parent
|
|
6907
6911
|
// except for `</dt>` or `</thead>`, end tags may be omitted if no more content in parent element
|
|
6908
|
-
if (tag && optionalEndTag && !trailingElements.has(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineElements.has(tag))) {
|
|
6912
|
+
if (tag && optionalEndTag && optionalEndTagEmitted && !trailingElements.has(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineElements.has(tag))) {
|
|
6909
6913
|
removeEndTag();
|
|
6910
6914
|
}
|
|
6911
6915
|
optionalEndTag = optionalEndTags.has(tag) ? tag : '';
|
|
6916
|
+
optionalEndTagEmitted = true;
|
|
6912
6917
|
}
|
|
6913
6918
|
|
|
6914
6919
|
if (options.removeEmptyElements && isElementEmpty && canRemoveElement(tag, attrs)) {
|
|
@@ -6924,10 +6929,11 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
6924
6929
|
removeStartTag();
|
|
6925
6930
|
optionalStartTag = '';
|
|
6926
6931
|
optionalEndTag = '';
|
|
6932
|
+
optionalEndTagEmitted = false;
|
|
6927
6933
|
} else {
|
|
6928
6934
|
// Preserve the element—add closing tag
|
|
6929
6935
|
if (autoGenerated && !options.includeAutoGeneratedTags) {
|
|
6930
|
-
|
|
6936
|
+
optionalEndTagEmitted = false;
|
|
6931
6937
|
} else {
|
|
6932
6938
|
buffer.push('</' + tag + '>');
|
|
6933
6939
|
}
|
|
@@ -6940,7 +6946,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
6940
6946
|
}
|
|
6941
6947
|
} else {
|
|
6942
6948
|
if (autoGenerated && !options.includeAutoGeneratedTags) {
|
|
6943
|
-
|
|
6949
|
+
optionalEndTagEmitted = false;
|
|
6944
6950
|
} else {
|
|
6945
6951
|
buffer.push('</' + tag + '>');
|
|
6946
6952
|
}
|
|
@@ -7037,12 +7043,13 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
7037
7043
|
optionalStartTag = '';
|
|
7038
7044
|
// `</html>` or `</body>` may be omitted if not followed by comment
|
|
7039
7045
|
// `</head>`, `</colgroup>`, or `</caption>` may be omitted if not followed by space or comment
|
|
7040
|
-
if (compactElements.has(optionalEndTag) || (looseElements.has(optionalEndTag) && !/^\s/.test(text))) {
|
|
7046
|
+
if (optionalEndTagEmitted && (compactElements.has(optionalEndTag) || (looseElements.has(optionalEndTag) && !/^\s/.test(text)))) {
|
|
7041
7047
|
removeEndTag();
|
|
7042
7048
|
}
|
|
7043
|
-
// Don
|
|
7049
|
+
// Don't reset optionalEndTag if text is only whitespace and will be collapsed (not conservatively)
|
|
7044
7050
|
if (!/^\s+$/.test(text) || !options.collapseWhitespace || options.conservativeCollapse) {
|
|
7045
7051
|
optionalEndTag = '';
|
|
7052
|
+
optionalEndTagEmitted = false;
|
|
7046
7053
|
}
|
|
7047
7054
|
}
|
|
7048
7055
|
charsPrevTag = /^\s*$/.test(text) ? prevTag : 'comment';
|
|
@@ -7088,6 +7095,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
7088
7095
|
// Preceding comments suppress tag omissions
|
|
7089
7096
|
optionalStartTag = '';
|
|
7090
7097
|
optionalEndTag = '';
|
|
7098
|
+
optionalEndTagEmitted = false;
|
|
7091
7099
|
}
|
|
7092
7100
|
|
|
7093
7101
|
// Optimize whitespace collapsing between consecutive `htmlmin:ignore` placeholder comments
|
|
@@ -7180,7 +7188,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
7180
7188
|
removeStartTag();
|
|
7181
7189
|
}
|
|
7182
7190
|
// except for `</dt>` or `</thead>`, end tags may be omitted if no more content in parent element
|
|
7183
|
-
if (optionalEndTag && !trailingElements.has(optionalEndTag)) {
|
|
7191
|
+
if (optionalEndTag && optionalEndTagEmitted && !trailingElements.has(optionalEndTag)) {
|
|
7184
7192
|
removeEndTag();
|
|
7185
7193
|
}
|
|
7186
7194
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"AAsiDO,8BAJI,MAAM,YACN,eAAe,GACb,OAAO,CAAC,MAAM,CAAC,CAuB3B;;;;;;;;;;;;UA51CS,MAAM;YACN,MAAM;YACN,MAAM;mBACN,MAAM;iBACN,MAAM;kBACN,MAAM;;;;;;;;;;;;;4BAQN,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,qBAAqB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,KAAK,OAAO;;;;;;;wBAMjG,CAAC,GAAG,EAAE,MA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 async function minifyHTML(value, options, partialMarkup) {
|
|
|
870
870
|
const stackNoCollapseWhitespace = [];
|
|
871
871
|
let optionalStartTag = '';
|
|
872
872
|
let optionalEndTag = '';
|
|
873
|
+
let optionalEndTagEmitted = false;
|
|
873
874
|
const ignoredMarkupChunks = [];
|
|
874
875
|
const ignoredCustomMarkupChunks = [];
|
|
875
876
|
let uidIgnore;
|
|
@@ -1074,12 +1075,15 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1074
1075
|
optionalStartTag = '';
|
|
1075
1076
|
// End-tag-followed-by-start-tag omission rules
|
|
1076
1077
|
if (htmlTag && canRemovePrecedingTag(optionalEndTag, tag)) {
|
|
1077
|
-
|
|
1078
|
+
if (optionalEndTagEmitted) {
|
|
1079
|
+
removeEndTag();
|
|
1080
|
+
}
|
|
1078
1081
|
// `<colgroup>` cannot be omitted if preceding `</colgroup>` is omitted
|
|
1079
1082
|
// `<tbody>` cannot be omitted if preceding `</tbody>`, `</thead>`, or `</tfoot>` is omitted
|
|
1080
1083
|
optional = !isStartTagMandatory(optionalEndTag, tag);
|
|
1081
1084
|
}
|
|
1082
1085
|
optionalEndTag = '';
|
|
1086
|
+
optionalEndTagEmitted = false;
|
|
1083
1087
|
}
|
|
1084
1088
|
|
|
1085
1089
|
// Set whitespace flags for nested tags (e.g., `<code>` within a `<pre>`)
|
|
@@ -1169,10 +1173,11 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1169
1173
|
// `</head>` may be omitted if not followed by space or comment
|
|
1170
1174
|
// `</p>` may be omitted if no more content in non-`</a>` parent
|
|
1171
1175
|
// except for `</dt>` or `</thead>`, end tags may be omitted if no more content in parent element
|
|
1172
|
-
if (tag && optionalEndTag && !trailingElements.has(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineElements.has(tag))) {
|
|
1176
|
+
if (tag && optionalEndTag && optionalEndTagEmitted && !trailingElements.has(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineElements.has(tag))) {
|
|
1173
1177
|
removeEndTag();
|
|
1174
1178
|
}
|
|
1175
1179
|
optionalEndTag = optionalEndTags.has(tag) ? tag : '';
|
|
1180
|
+
optionalEndTagEmitted = true;
|
|
1176
1181
|
}
|
|
1177
1182
|
|
|
1178
1183
|
if (options.removeEmptyElements && isElementEmpty && canRemoveElement(tag, attrs)) {
|
|
@@ -1188,10 +1193,11 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1188
1193
|
removeStartTag();
|
|
1189
1194
|
optionalStartTag = '';
|
|
1190
1195
|
optionalEndTag = '';
|
|
1196
|
+
optionalEndTagEmitted = false;
|
|
1191
1197
|
} else {
|
|
1192
1198
|
// Preserve the element—add closing tag
|
|
1193
1199
|
if (autoGenerated && !options.includeAutoGeneratedTags) {
|
|
1194
|
-
|
|
1200
|
+
optionalEndTagEmitted = false;
|
|
1195
1201
|
} else {
|
|
1196
1202
|
buffer.push('</' + tag + '>');
|
|
1197
1203
|
}
|
|
@@ -1204,7 +1210,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1204
1210
|
}
|
|
1205
1211
|
} else {
|
|
1206
1212
|
if (autoGenerated && !options.includeAutoGeneratedTags) {
|
|
1207
|
-
|
|
1213
|
+
optionalEndTagEmitted = false;
|
|
1208
1214
|
} else {
|
|
1209
1215
|
buffer.push('</' + tag + '>');
|
|
1210
1216
|
}
|
|
@@ -1301,12 +1307,13 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1301
1307
|
optionalStartTag = '';
|
|
1302
1308
|
// `</html>` or `</body>` may be omitted if not followed by comment
|
|
1303
1309
|
// `</head>`, `</colgroup>`, or `</caption>` may be omitted if not followed by space or comment
|
|
1304
|
-
if (compactElements.has(optionalEndTag) || (looseElements.has(optionalEndTag) && !/^\s/.test(text))) {
|
|
1310
|
+
if (optionalEndTagEmitted && (compactElements.has(optionalEndTag) || (looseElements.has(optionalEndTag) && !/^\s/.test(text)))) {
|
|
1305
1311
|
removeEndTag();
|
|
1306
1312
|
}
|
|
1307
|
-
// Don
|
|
1313
|
+
// Don't reset optionalEndTag if text is only whitespace and will be collapsed (not conservatively)
|
|
1308
1314
|
if (!/^\s+$/.test(text) || !options.collapseWhitespace || options.conservativeCollapse) {
|
|
1309
1315
|
optionalEndTag = '';
|
|
1316
|
+
optionalEndTagEmitted = false;
|
|
1310
1317
|
}
|
|
1311
1318
|
}
|
|
1312
1319
|
charsPrevTag = /^\s*$/.test(text) ? prevTag : 'comment';
|
|
@@ -1352,6 +1359,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1352
1359
|
// Preceding comments suppress tag omissions
|
|
1353
1360
|
optionalStartTag = '';
|
|
1354
1361
|
optionalEndTag = '';
|
|
1362
|
+
optionalEndTagEmitted = false;
|
|
1355
1363
|
}
|
|
1356
1364
|
|
|
1357
1365
|
// Optimize whitespace collapsing between consecutive `htmlmin:ignore` placeholder comments
|
|
@@ -1444,7 +1452,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1444
1452
|
removeStartTag();
|
|
1445
1453
|
}
|
|
1446
1454
|
// except for `</dt>` or `</thead>`, end tags may be omitted if no more content in parent element
|
|
1447
|
-
if (optionalEndTag && !trailingElements.has(optionalEndTag)) {
|
|
1455
|
+
if (optionalEndTag && optionalEndTagEmitted && !trailingElements.has(optionalEndTag)) {
|
|
1448
1456
|
removeEndTag();
|
|
1449
1457
|
}
|
|
1450
1458
|
}
|