html-minifier-next 4.12.0 → 4.12.2
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
CHANGED
|
@@ -343,13 +343,15 @@ html-minifier-next --input-dir=src --output-dir=dist --dry --collapse-whitespace
|
|
|
343
343
|
|
|
344
344
|
If you have chunks of markup you would like preserved, you can wrap them with `<!-- htmlmin:ignore -->`.
|
|
345
345
|
|
|
346
|
-
### Minifying JSON
|
|
346
|
+
### Minifying JSON content
|
|
347
347
|
|
|
348
|
-
|
|
348
|
+
JSON script types are minified automatically without configuration, including `application/json`, `application/ld+json`, `application/manifest+json`, `application/vnd.geo+json`, `application/problem+json`, `application/merge-patch+json`, `application/json-patch+json`, `importmap`, and `speculationrules`. Malformed JSON is preserved by default (with `continueOnMinifyError: true`).
|
|
349
349
|
|
|
350
|
-
|
|
350
|
+
Note: The `processScripts` option is only for script types containing HTML templates (e.g., `text/ng-template`, `text/x-handlebars-template`), not for JSON.
|
|
351
351
|
|
|
352
|
-
|
|
352
|
+
### Preserving SVG and MathML elements
|
|
353
|
+
|
|
354
|
+
SVG and MathML elements are automatically recognized as foreign elements, and when they are minified, both case-sensitivity and self-closing slashes are preserved, regardless of the minification settings used for the rest of the file. This ensures valid output for these namespaced elements.
|
|
353
355
|
|
|
354
356
|
### Working with invalid or partial markup
|
|
355
357
|
|
package/dist/htmlminifier.cjs
CHANGED
|
@@ -1714,6 +1714,9 @@ const jsonScriptTypes = new Set([
|
|
|
1714
1714
|
'application/ld+json',
|
|
1715
1715
|
'application/manifest+json',
|
|
1716
1716
|
'application/vnd.geo+json',
|
|
1717
|
+
'application/problem+json',
|
|
1718
|
+
'application/merge-patch+json',
|
|
1719
|
+
'application/json-patch+json',
|
|
1717
1720
|
'importmap',
|
|
1718
1721
|
'speculationrules',
|
|
1719
1722
|
]);
|
|
@@ -2815,7 +2818,8 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
2815
2818
|
wantsNextTag: !!(options.collapseWhitespace || options.collapseInlineTagWhitespace || options.conservativeCollapse),
|
|
2816
2819
|
|
|
2817
2820
|
start: async function (tag, attrs, unary, unarySlash, autoGenerated) {
|
|
2818
|
-
|
|
2821
|
+
const lowerTag = tag.toLowerCase();
|
|
2822
|
+
if (lowerTag === 'svg' || lowerTag === 'math') {
|
|
2819
2823
|
options = Object.create(options);
|
|
2820
2824
|
options.caseSensitive = true;
|
|
2821
2825
|
options.keepClosingSlash = true;
|
|
@@ -2901,7 +2905,8 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
2901
2905
|
}
|
|
2902
2906
|
},
|
|
2903
2907
|
end: function (tag, attrs, autoGenerated) {
|
|
2904
|
-
|
|
2908
|
+
const lowerTag = tag.toLowerCase();
|
|
2909
|
+
if (lowerTag === 'svg' || lowerTag === 'math') {
|
|
2905
2910
|
options = Object.getPrototypeOf(options);
|
|
2906
2911
|
}
|
|
2907
2912
|
tag = options.name(tag);
|
|
@@ -6856,6 +6856,9 @@ const jsonScriptTypes = new Set([
|
|
|
6856
6856
|
'application/ld+json',
|
|
6857
6857
|
'application/manifest+json',
|
|
6858
6858
|
'application/vnd.geo+json',
|
|
6859
|
+
'application/problem+json',
|
|
6860
|
+
'application/merge-patch+json',
|
|
6861
|
+
'application/json-patch+json',
|
|
6859
6862
|
'importmap',
|
|
6860
6863
|
'speculationrules',
|
|
6861
6864
|
]);
|
|
@@ -7957,7 +7960,8 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
7957
7960
|
wantsNextTag: !!(options.collapseWhitespace || options.collapseInlineTagWhitespace || options.conservativeCollapse),
|
|
7958
7961
|
|
|
7959
7962
|
start: async function (tag, attrs, unary, unarySlash, autoGenerated) {
|
|
7960
|
-
|
|
7963
|
+
const lowerTag = tag.toLowerCase();
|
|
7964
|
+
if (lowerTag === 'svg' || lowerTag === 'math') {
|
|
7961
7965
|
options = Object.create(options);
|
|
7962
7966
|
options.caseSensitive = true;
|
|
7963
7967
|
options.keepClosingSlash = true;
|
|
@@ -8043,7 +8047,8 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
8043
8047
|
}
|
|
8044
8048
|
},
|
|
8045
8049
|
end: function (tag, attrs, autoGenerated) {
|
|
8046
|
-
|
|
8050
|
+
const lowerTag = tag.toLowerCase();
|
|
8051
|
+
if (lowerTag === 'svg' || lowerTag === 'math') {
|
|
8047
8052
|
options = Object.getPrototypeOf(options);
|
|
8048
8053
|
}
|
|
8049
8054
|
tag = options.name(tag);
|
|
@@ -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":"AA86EO,8BAJI,MAAM,YACN,eAAe,GACb,OAAO,CAAC,MAAM,CAAC,CAQ3B;;;;;;;;;;;;UAr5ES,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,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,EAAE,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,KAAK,OAAO;;;;;;;;oBAMhH,OAAO;;;;;;;;;kCAON,OAAO;;;;;;;;gCAQR,OAAO;;;;;;;;kCAOP,OAAO;;;;;;;;yBAOP,OAAO;;;;;;;;2BAOP,OAAO;;;;;;;;4BAOP,OAAO;;;;;;;2BAOP,OAAO;;;;;;;;uBAMP,MAAM,EAAE;;;;;;yBAOR,MAAM;;;;;;yBAKN,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;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;;;0BAQtD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;gCAOP,MAAM,EAAE;;;;;;;;yBAyBR,OAAO;;;;;;;;gCAOP,OAAO;;;;;;;iCAOP,OAAO;;;;;;;oCAMP,OAAO;;;;;;;;;;0BAMP,OAAO;;;;;;;;;qBASP,OAAO,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;;;;;;;;;oBAQzD,OAAO,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;;;;;;;;0BAQrC,OAAO;;;;;;;sBAOP,OAAO;;wBA3YkC,cAAc;0BAAd,cAAc;+BAAd,cAAc"}
|
package/package.json
CHANGED
package/src/htmlminifier.js
CHANGED
|
@@ -910,6 +910,9 @@ const jsonScriptTypes = new Set([
|
|
|
910
910
|
'application/ld+json',
|
|
911
911
|
'application/manifest+json',
|
|
912
912
|
'application/vnd.geo+json',
|
|
913
|
+
'application/problem+json',
|
|
914
|
+
'application/merge-patch+json',
|
|
915
|
+
'application/json-patch+json',
|
|
913
916
|
'importmap',
|
|
914
917
|
'speculationrules',
|
|
915
918
|
]);
|
|
@@ -2011,7 +2014,8 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
2011
2014
|
wantsNextTag: !!(options.collapseWhitespace || options.collapseInlineTagWhitespace || options.conservativeCollapse),
|
|
2012
2015
|
|
|
2013
2016
|
start: async function (tag, attrs, unary, unarySlash, autoGenerated) {
|
|
2014
|
-
|
|
2017
|
+
const lowerTag = tag.toLowerCase();
|
|
2018
|
+
if (lowerTag === 'svg' || lowerTag === 'math') {
|
|
2015
2019
|
options = Object.create(options);
|
|
2016
2020
|
options.caseSensitive = true;
|
|
2017
2021
|
options.keepClosingSlash = true;
|
|
@@ -2097,7 +2101,8 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
2097
2101
|
}
|
|
2098
2102
|
},
|
|
2099
2103
|
end: function (tag, attrs, autoGenerated) {
|
|
2100
|
-
|
|
2104
|
+
const lowerTag = tag.toLowerCase();
|
|
2105
|
+
if (lowerTag === 'svg' || lowerTag === 'math') {
|
|
2101
2106
|
options = Object.getPrototypeOf(options);
|
|
2102
2107
|
}
|
|
2103
2108
|
tag = options.name(tag);
|