html-minifier 0.7.1 → 0.7.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/cli.js +58 -51
- package/dist/htmlminifier.js +1 -1
- package/dist/htmlminifier.min.js +1 -1
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* The MIT License (MIT)
|
|
6
6
|
*
|
|
7
|
-
* Copyright (c) 2014 Zoltan Frombach
|
|
7
|
+
* Copyright (c) 2014-2015 Zoltan Frombach
|
|
8
8
|
*
|
|
9
9
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
10
10
|
* this software and associated documentation files (the "Software"), to deal in
|
|
@@ -69,7 +69,10 @@ var mainOptions = {
|
|
|
69
69
|
preventAttributesEscaping: [[false, 'Prevents the escaping of the values of attributes.']],
|
|
70
70
|
useShortDoctype: [[false, 'Replaces the doctype with the short (HTML5) doctype']],
|
|
71
71
|
removeEmptyAttributes: [[false, 'Remove all attributes with whitespace-only values']],
|
|
72
|
+
removeScriptTypeAttributes: [[false, 'Remove type="text/javascript" from script tags. Other type attribute values are left intact.']],
|
|
73
|
+
removeStyleLinkTypeAttributes: [[false, 'Remove type="text/css" from style and link tags. Other type attribute values are left intact.']],
|
|
72
74
|
removeOptionalTags: [[false, 'Remove unrequired tags']],
|
|
75
|
+
removeIgnored: [[false, 'Remove all tags starting and ending with <%, %>, <?, ?>']],
|
|
73
76
|
removeEmptyElements: [[false, 'Remove all elements with empty contents']],
|
|
74
77
|
lint: [[false, 'Toggle linting']],
|
|
75
78
|
keepClosingSlash: [[false, 'Keep the trailing slash on singleton elements']],
|
|
@@ -79,7 +82,10 @@ var mainOptions = {
|
|
|
79
82
|
minifyURLs: [[false, 'Minify URLs in various attributes (uses relateurl)']],
|
|
80
83
|
ignoreCustomComments: [[false, 'Array of regex\'es that allow to ignore certain comments, when matched', 'string'], 'json'],
|
|
81
84
|
processScripts: [[false, 'Array of strings corresponding to types of script elements to process through minifier (e.g. "text/ng-template", "text/x-handlebars-template", etc.)', 'string'], 'json'],
|
|
82
|
-
maxLineLength: [[false, 'Max line length', 'number'], true]
|
|
85
|
+
maxLineLength: [[false, 'Max line length', 'number'], true],
|
|
86
|
+
customAttrAssign: [[false, 'Arrays of regex\'es that allow to support custom attribute assign expressions (e.g. \'<div flex?="{{mode != cover}}"></div>\')', 'string'], 'json'],
|
|
87
|
+
customAttrSurround: [[false, 'Arrays of regex\'es that allow to support custom attribute surround expressions (e.g. <input {{#if value}}checked="checked"{{/if}}>)', 'string'], 'json'],
|
|
88
|
+
customAttrCollapse: [[false, 'Regex that specifies custom attribute to strip newlines from (e.g. /ng\-class/)', 'string'], true]
|
|
83
89
|
};
|
|
84
90
|
|
|
85
91
|
var cliOptions = {
|
|
@@ -97,6 +103,56 @@ cli.parse(cliOptions);
|
|
|
97
103
|
|
|
98
104
|
cli.main(function(args, options) {
|
|
99
105
|
|
|
106
|
+
function parseJSONOption(value) {
|
|
107
|
+
if (value !== null) {
|
|
108
|
+
var jsonArray;
|
|
109
|
+
try {
|
|
110
|
+
jsonArray = JSON.parse(value);
|
|
111
|
+
}
|
|
112
|
+
catch (e) {}
|
|
113
|
+
if (jsonArray instanceof Array) {
|
|
114
|
+
return jsonArray;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
return [value];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function runMinify(original) {
|
|
123
|
+
var status = 0;
|
|
124
|
+
var minified = null;
|
|
125
|
+
try {
|
|
126
|
+
minified = minify(original, minifyOptions);
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
status = 3;
|
|
130
|
+
process.stderr.write('Error: Minification error');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (minifyOptions.lint) {
|
|
134
|
+
minifyOptions.lint.populate();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (minified !== null) {
|
|
138
|
+
// Write the output
|
|
139
|
+
try {
|
|
140
|
+
if (output !== null) {
|
|
141
|
+
fs.writeFileSync(path.resolve(output), minified);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
process.stdout.write(minified);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
status = 4;
|
|
149
|
+
process.stderr.write('Error: Cannot write to output');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
cli.exit(status);
|
|
154
|
+
}
|
|
155
|
+
|
|
100
156
|
if (options.version) {
|
|
101
157
|
process.stderr.write(appName + ' v' + appVersion);
|
|
102
158
|
cli.exit(0);
|
|
@@ -165,53 +221,4 @@ cli.main(function(args, options) {
|
|
|
165
221
|
process.stdin.pipe(concat({ encoding: 'string' }, runMinify));
|
|
166
222
|
}
|
|
167
223
|
|
|
168
|
-
function parseJSONOption(value) {
|
|
169
|
-
if (value !== null) {
|
|
170
|
-
var jsonArray;
|
|
171
|
-
try {
|
|
172
|
-
jsonArray = JSON.parse(value);
|
|
173
|
-
}
|
|
174
|
-
catch (e) {}
|
|
175
|
-
if (jsonArray instanceof Array) {
|
|
176
|
-
return jsonArray;
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
return [value];
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function runMinify(original) {
|
|
185
|
-
var status = 0;
|
|
186
|
-
var minified = null;
|
|
187
|
-
try {
|
|
188
|
-
minified = minify(original, minifyOptions);
|
|
189
|
-
}
|
|
190
|
-
catch (e) {
|
|
191
|
-
status = 3;
|
|
192
|
-
process.stderr.write('Error: Minification error');
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (minifyOptions.lint) {
|
|
196
|
-
minifyOptions.lint.populate();
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (minified !== null) {
|
|
200
|
-
// Write the output
|
|
201
|
-
try {
|
|
202
|
-
if (output !== null) {
|
|
203
|
-
fs.writeFileSync(path.resolve(output), minified);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
process.stdout.write(minified);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
catch (e) {
|
|
210
|
-
status = 4;
|
|
211
|
-
process.stderr.write('Error: Cannot write to output');
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
cli.exit(status);
|
|
216
|
-
}
|
|
217
224
|
});
|
package/dist/htmlminifier.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* HTMLMinifier v0.7.
|
|
2
|
+
* HTMLMinifier v0.7.2 (http://kangax.github.io/html-minifier/)
|
|
3
3
|
* Copyright 2010-2015 Juriy "kangax" Zaytsev
|
|
4
4
|
* Licensed under MIT (https://github.com/kangax/html-minifier/blob/gh-pages/LICENSE)
|
|
5
5
|
*/
|
package/dist/htmlminifier.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* HTMLMinifier v0.7.
|
|
2
|
+
* HTMLMinifier v0.7.2 (http://kangax.github.io/html-minifier/)
|
|
3
3
|
* Copyright 2010-2015 Juriy "kangax" Zaytsev
|
|
4
4
|
* Licensed under MIT (https://github.com/kangax/html-minifier/blob/gh-pages/LICENSE)
|
|
5
5
|
*/
|