html-minifier 0.6.9 → 0.8.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/CHANGELOG.md +12 -0
- package/LICENSE +1 -1
- package/README.md +42 -13
- package/cli.js +120 -93
- package/dist/htmlminifier.js +135 -50
- package/dist/htmlminifier.min.js +4 -4
- package/package.json +21 -22
- package/src/htmllint.js +168 -0
- package/src/htmlminifier.js +834 -0
- package/src/htmlparser.js +560 -0
package/dist/htmlminifier.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* HTMLMinifier v0.
|
|
3
|
-
* Copyright 2010-
|
|
4
|
-
* Licensed under MIT
|
|
2
|
+
* HTMLMinifier v0.8.0 (http://kangax.github.io/html-minifier/)
|
|
3
|
+
* Copyright 2010-2015 Juriy "kangax" Zaytsev
|
|
4
|
+
* Licensed under the MIT license
|
|
5
5
|
*/
|
|
6
6
|
/*!
|
|
7
7
|
* HTML Parser By John Resig (ejohn.org)
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
'use strict';
|
|
38
38
|
|
|
39
39
|
// Regular Expressions for parsing tags and attributes
|
|
40
|
-
var singleAttrIdentifier = /([\w
|
|
40
|
+
var singleAttrIdentifier = /([\w:\.-]+)/,
|
|
41
41
|
singleAttrAssign = /=/,
|
|
42
42
|
singleAttrAssigns = [ singleAttrAssign ],
|
|
43
43
|
singleAttrValues = [
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
var customStartTagAttrs;
|
|
82
82
|
|
|
83
83
|
var startTagAttrs = new RegExp(
|
|
84
|
-
'(?:\\s*[\\w
|
|
84
|
+
'(?:\\s*[\\w:\\.-]+'
|
|
85
85
|
+ '(?:\\s*'
|
|
86
86
|
+ '(?:' + joinSingleAttrAssigns(handler) + ')'
|
|
87
87
|
+ '\\s*(?:(?:"[^"]*")|(?:\'[^\']*\')|[^>\\s]+)'
|
|
@@ -235,8 +235,8 @@
|
|
|
235
235
|
chars = false;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
// Start tag:
|
|
239
238
|
}
|
|
239
|
+
// Start tag:
|
|
240
240
|
else if ( /^</.test( html ) ) {
|
|
241
241
|
match = html.match( startTag );
|
|
242
242
|
if ( match ) {
|
|
@@ -322,7 +322,7 @@
|
|
|
322
322
|
var attrs = [];
|
|
323
323
|
|
|
324
324
|
rest.replace(attr, function () {
|
|
325
|
-
var name, value, fallbackValue, customOpen, customClose, customAssign;
|
|
325
|
+
var name, value, fallbackValue, customOpen, customClose, customAssign, quote;
|
|
326
326
|
var ncp = 7; // number of captured parts, scalar
|
|
327
327
|
|
|
328
328
|
// hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
|
|
@@ -337,6 +337,12 @@
|
|
|
337
337
|
customAssign = arguments[2];
|
|
338
338
|
fallbackValue = arguments[3];
|
|
339
339
|
value = fallbackValue || arguments[4] || arguments[5];
|
|
340
|
+
|
|
341
|
+
if (customAssign) {
|
|
342
|
+
quote = arguments[0].charAt(name.length + customAssign.length);
|
|
343
|
+
quote = (quote === '\'' || quote === '"') ? quote : '';
|
|
344
|
+
}
|
|
345
|
+
|
|
340
346
|
}
|
|
341
347
|
else if ( handler.customAttrSurround ) {
|
|
342
348
|
for ( var i = handler.customAttrSurround.length - 1; i >= 0; i-- ) {
|
|
@@ -366,7 +372,8 @@
|
|
|
366
372
|
}),
|
|
367
373
|
customAssign: customAssign || '=',
|
|
368
374
|
customOpen: customOpen || '',
|
|
369
|
-
customClose: customClose || ''
|
|
375
|
+
customClose: customClose || '',
|
|
376
|
+
quote: quote || ''
|
|
370
377
|
});
|
|
371
378
|
});
|
|
372
379
|
|
|
@@ -612,15 +619,15 @@
|
|
|
612
619
|
lineBreakAfter = /[\t\n\r ]*[\n\r]+[\t ]*$/,
|
|
613
620
|
preserveBefore = lineBreakBefore.test(str) ? '\n' : ' ',
|
|
614
621
|
preserveAfter = lineBreakAfter.test(str) ? '\n' : ' ',
|
|
615
|
-
lineBreakStamp = '
|
|
622
|
+
lineBreakStamp = 'htmlmincollapsedlinebreak';
|
|
616
623
|
|
|
617
|
-
if (prevTag && prevTag !== 'img' && prevTag !== 'input' && (prevTag.substr(0,1) !== '/'
|
|
618
|
-
|| (
|
|
624
|
+
if (prevTag && prevTag !== 'img' && prevTag !== 'input' && (prevTag.substr(0, 1) !== '/'
|
|
625
|
+
|| (prevTag.substr(0, 1) === '/' && tags.indexOf(prevTag.substr(1)) === -1))) {
|
|
619
626
|
str = str.replace(/^\s+/, options.conservativeCollapse ? ' ' : options.preserveLineBreaks ? preserveBefore : '');
|
|
620
627
|
}
|
|
621
628
|
|
|
622
|
-
if (nextTag && nextTag !== 'img' && nextTag !== 'input' && (nextTag.substr(0,1) === '/'
|
|
623
|
-
|| (
|
|
629
|
+
if (nextTag && nextTag !== 'img' && nextTag !== 'input' && (nextTag.substr(0, 1) === '/'
|
|
630
|
+
|| (nextTag.substr(0, 1) !== '/' && tags.indexOf(nextTag) === -1))) {
|
|
624
631
|
str = str.replace(/\s+$/, options.conservativeCollapse ? ' ' : options.preserveLineBreaks ? preserveAfter : '');
|
|
625
632
|
}
|
|
626
633
|
|
|
@@ -634,7 +641,7 @@
|
|
|
634
641
|
// strip non space whitespace then compress spaces to one
|
|
635
642
|
return str
|
|
636
643
|
.replace(/[\t\n\r]+/g, ' ').replace(/[ ]+/g, ' ')
|
|
637
|
-
.replace(lineBreakStamp, '\n');
|
|
644
|
+
.replace(new RegExp(lineBreakStamp, 'g'), '\n');
|
|
638
645
|
}
|
|
639
646
|
|
|
640
647
|
return str;
|
|
@@ -666,13 +673,13 @@
|
|
|
666
673
|
|
|
667
674
|
function canRemoveAttributeQuotes(value) {
|
|
668
675
|
// http://mathiasbynens.be/notes/unquoted-attribute-values
|
|
669
|
-
return (/^[^\x20\t\n\f\r"'`=<>]+$/).test(value) && !(/\/$/
|
|
676
|
+
return (/^[^\x20\t\n\f\r"'`=<>]+$/).test(value) && !(/\/$/).test(value) &&
|
|
670
677
|
// make sure trailing slash is not interpreted as HTML self-closing tag
|
|
671
678
|
!(/\/$/).test(value);
|
|
672
679
|
}
|
|
673
680
|
|
|
674
681
|
function attributesInclude(attributes, attribute) {
|
|
675
|
-
for (var i = attributes.length; i--;
|
|
682
|
+
for (var i = attributes.length; i--;) {
|
|
676
683
|
if (attributes[i].name.toLowerCase() === attribute) {
|
|
677
684
|
return true;
|
|
678
685
|
}
|
|
@@ -718,6 +725,31 @@
|
|
|
718
725
|
);
|
|
719
726
|
}
|
|
720
727
|
|
|
728
|
+
// https://mathiasbynens.be/demo/javascript-mime-type
|
|
729
|
+
// https://developer.mozilla.org/en/docs/Web/HTML/Element/script#attr-type
|
|
730
|
+
var executableScriptsMimetypes = {
|
|
731
|
+
'text/javascript': 1,
|
|
732
|
+
'text/ecmascript': 1,
|
|
733
|
+
'text/jscript': 1,
|
|
734
|
+
'application/javascript': 1,
|
|
735
|
+
'application/x-javascript': 1,
|
|
736
|
+
'application/ecmascript': 1
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
function isExecutableScript(tag, attrs) {
|
|
740
|
+
if (tag !== 'script') {
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
743
|
+
for (var i = 0, len = attrs.length; i < len; i++) {
|
|
744
|
+
var attrName = attrs[i].name.toLowerCase();
|
|
745
|
+
if (attrName === 'type') {
|
|
746
|
+
return attrs[i].value === '' ||
|
|
747
|
+
executableScriptsMimetypes[attrs[i].value] === 1;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return true;
|
|
751
|
+
}
|
|
752
|
+
|
|
721
753
|
function isStyleLinkTypeAttribute(tag, attrName, attrValue) {
|
|
722
754
|
return (
|
|
723
755
|
(tag === 'style' || tag === 'link') &&
|
|
@@ -801,7 +833,7 @@
|
|
|
801
833
|
attrValue = attrValue.replace(/\s*;\s*$/, '');
|
|
802
834
|
}
|
|
803
835
|
if (options.minifyCSS) {
|
|
804
|
-
return minifyCSS(attrValue, options.minifyCSS);
|
|
836
|
+
return minifyCSS(attrValue, options.minifyCSS, true);
|
|
805
837
|
}
|
|
806
838
|
return attrValue;
|
|
807
839
|
}
|
|
@@ -825,6 +857,22 @@
|
|
|
825
857
|
}
|
|
826
858
|
}
|
|
827
859
|
|
|
860
|
+
// Wrap CSS declarations for CleanCSS > 3.x
|
|
861
|
+
// See https://github.com/jakubpawlowicz/clean-css/issues/418
|
|
862
|
+
function wrapCSS(text) {
|
|
863
|
+
return '*{' + text + '}';
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
function unwrapCSS(text) {
|
|
867
|
+
var matches = text.match(/^\*\{([\s\S]*)\}$/m);
|
|
868
|
+
if (matches && matches[1]) {
|
|
869
|
+
return matches[1];
|
|
870
|
+
}
|
|
871
|
+
else {
|
|
872
|
+
return text;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
|
|
828
876
|
function cleanConditionalComment(comment) {
|
|
829
877
|
return comment
|
|
830
878
|
.replace(/^(\[[^\]]+\]>)\s*/, '$1')
|
|
@@ -863,7 +911,7 @@
|
|
|
863
911
|
}
|
|
864
912
|
|
|
865
913
|
function isOptionalTag(tag) {
|
|
866
|
-
return (/^(?:html|t?body|t?head|tfoot|tr|td|th|dt|dd|option|colgroup|source)$/).test(tag);
|
|
914
|
+
return (/^(?:html|t?body|t?head|tfoot|tr|td|th|dt|dd|option|colgroup|source|track)$/).test(tag);
|
|
867
915
|
}
|
|
868
916
|
|
|
869
917
|
var reEmptyAttribute = new RegExp(
|
|
@@ -915,7 +963,8 @@
|
|
|
915
963
|
function normalizeAttribute(attr, attrs, tag, unarySlash, index, options) {
|
|
916
964
|
|
|
917
965
|
var attrName = options.caseSensitive ? attr.name : attr.name.toLowerCase(),
|
|
918
|
-
attrValue = attr.escaped,
|
|
966
|
+
attrValue = options.preventAttributesEscaping ? attr.value : attr.escaped,
|
|
967
|
+
attrQuote = options.preventAttributesEscaping ? attr.quote : (options.quoteCharacter === '\'' ? '\'' : '"'),
|
|
919
968
|
attrFragment,
|
|
920
969
|
emittedAttrValue,
|
|
921
970
|
isTerminalOfUnarySlash = unarySlash && index === attrs.length - 1;
|
|
@@ -935,7 +984,7 @@
|
|
|
935
984
|
|
|
936
985
|
if (attrValue !== undefined && !options.removeAttributeQuotes ||
|
|
937
986
|
!canRemoveAttributeQuotes(attrValue) || isTerminalOfUnarySlash) {
|
|
938
|
-
emittedAttrValue =
|
|
987
|
+
emittedAttrValue = attrQuote + attrValue + attrQuote;
|
|
939
988
|
}
|
|
940
989
|
else {
|
|
941
990
|
emittedAttrValue = attrValue;
|
|
@@ -959,7 +1008,7 @@
|
|
|
959
1008
|
|
|
960
1009
|
function setDefaultTesters(options) {
|
|
961
1010
|
|
|
962
|
-
var defaultTesters = ['canCollapseWhitespace','canTrimWhitespace'];
|
|
1011
|
+
var defaultTesters = ['canCollapseWhitespace', 'canTrimWhitespace'];
|
|
963
1012
|
|
|
964
1013
|
for (var i = 0, len = defaultTesters.length; i < len; i++) {
|
|
965
1014
|
if (!options[defaultTesters[i]]) {
|
|
@@ -1006,7 +1055,9 @@
|
|
|
1006
1055
|
options = { };
|
|
1007
1056
|
}
|
|
1008
1057
|
options.fromString = true;
|
|
1009
|
-
options.output
|
|
1058
|
+
var outputOptions = options.output || {};
|
|
1059
|
+
outputOptions.inline_script = true;
|
|
1060
|
+
options.output = outputOptions;
|
|
1010
1061
|
|
|
1011
1062
|
try {
|
|
1012
1063
|
// try to get global reference first
|
|
@@ -1054,20 +1105,28 @@
|
|
|
1054
1105
|
return text;
|
|
1055
1106
|
}
|
|
1056
1107
|
|
|
1057
|
-
function minifyCSS(text, options) {
|
|
1108
|
+
function minifyCSS(text, options, inline) {
|
|
1058
1109
|
if (typeof options !== 'object') {
|
|
1059
1110
|
options = { };
|
|
1060
1111
|
}
|
|
1061
|
-
if (typeof options.
|
|
1062
|
-
options.
|
|
1112
|
+
if (typeof options.advanced === 'undefined') {
|
|
1113
|
+
options.advanced = false;
|
|
1063
1114
|
}
|
|
1064
1115
|
try {
|
|
1116
|
+
var cleanCSS;
|
|
1117
|
+
|
|
1065
1118
|
if (typeof CleanCSS !== 'undefined') {
|
|
1066
|
-
|
|
1119
|
+
cleanCSS = new CleanCSS(options);
|
|
1067
1120
|
}
|
|
1068
1121
|
else if (typeof require === 'function') {
|
|
1069
1122
|
var CleanCSSModule = require('clean-css');
|
|
1070
|
-
|
|
1123
|
+
cleanCSS = new CleanCSSModule(options);
|
|
1124
|
+
}
|
|
1125
|
+
if (inline) {
|
|
1126
|
+
return unwrapCSS(cleanCSS.minify(wrapCSS(text)).styles);
|
|
1127
|
+
}
|
|
1128
|
+
else {
|
|
1129
|
+
return cleanCSS.minify(text).styles;
|
|
1071
1130
|
}
|
|
1072
1131
|
}
|
|
1073
1132
|
catch (err) {
|
|
@@ -1079,6 +1138,8 @@
|
|
|
1079
1138
|
function minify(value, options) {
|
|
1080
1139
|
|
|
1081
1140
|
options = options || {};
|
|
1141
|
+
var optionsStack = [];
|
|
1142
|
+
|
|
1082
1143
|
value = trimWhitespace(value);
|
|
1083
1144
|
setDefaultTesters(options);
|
|
1084
1145
|
|
|
@@ -1110,14 +1171,27 @@
|
|
|
1110
1171
|
new HTMLParser(value, {
|
|
1111
1172
|
html5: typeof options.html5 !== 'undefined' ? options.html5 : true,
|
|
1112
1173
|
|
|
1113
|
-
start: function(
|
|
1114
|
-
|
|
1174
|
+
start: function(tag, attrs, unary, unarySlash) {
|
|
1115
1175
|
if (isIgnoring) {
|
|
1116
1176
|
buffer.push('<' + tag, attrsToMarkup(attrs), unarySlash ? '/' : '', '>');
|
|
1117
1177
|
return;
|
|
1118
1178
|
}
|
|
1119
1179
|
|
|
1120
|
-
|
|
1180
|
+
var lowerTag = tag.toLowerCase();
|
|
1181
|
+
|
|
1182
|
+
if (lowerTag === 'svg') {
|
|
1183
|
+
optionsStack.push(options);
|
|
1184
|
+
var nextOptions = {};
|
|
1185
|
+
for (var key in options) {
|
|
1186
|
+
nextOptions[key] = options[key];
|
|
1187
|
+
}
|
|
1188
|
+
nextOptions.keepClosingSlash = true;
|
|
1189
|
+
nextOptions.caseSensitive = true;
|
|
1190
|
+
options = nextOptions;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
tag = options.caseSensitive ? tag : lowerTag;
|
|
1194
|
+
|
|
1121
1195
|
currentTag = tag;
|
|
1122
1196
|
currentChars = '';
|
|
1123
1197
|
currentAttrs = attrs;
|
|
@@ -1134,31 +1208,40 @@
|
|
|
1134
1208
|
|
|
1135
1209
|
var openTag = '<' + tag;
|
|
1136
1210
|
var closeTag = ((unarySlash && options.keepClosingSlash) ? '/' : '') + '>';
|
|
1137
|
-
if (
|
|
1211
|
+
if (attrs.length === 0) {
|
|
1138
1212
|
openTag += closeTag;
|
|
1139
1213
|
}
|
|
1140
1214
|
|
|
1141
1215
|
buffer.push(openTag);
|
|
1142
1216
|
|
|
1143
|
-
|
|
1217
|
+
if (lint) {
|
|
1218
|
+
lint.testElement(tag);
|
|
1219
|
+
}
|
|
1144
1220
|
|
|
1145
1221
|
var token;
|
|
1146
|
-
for (
|
|
1147
|
-
|
|
1222
|
+
for (var i = 0, len = attrs.length; i < len; i++) {
|
|
1223
|
+
if (lint) {
|
|
1224
|
+
lint.testAttribute(tag, attrs[i].name.toLowerCase(), attrs[i].escaped);
|
|
1225
|
+
}
|
|
1148
1226
|
token = normalizeAttribute(attrs[i], attrs, tag, unarySlash, i, options);
|
|
1149
|
-
if (
|
|
1227
|
+
if (i === len - 1) {
|
|
1150
1228
|
token += closeTag;
|
|
1151
1229
|
}
|
|
1152
1230
|
buffer.push(token);
|
|
1153
1231
|
}
|
|
1154
1232
|
},
|
|
1155
|
-
end: function(
|
|
1233
|
+
end: function(tag, attrs) {
|
|
1156
1234
|
|
|
1157
1235
|
if (isIgnoring) {
|
|
1158
1236
|
buffer.push('</' + tag + '>');
|
|
1159
1237
|
return;
|
|
1160
1238
|
}
|
|
1161
1239
|
|
|
1240
|
+
var lowerTag = tag.toLowerCase();
|
|
1241
|
+
if (lowerTag === 'svg') {
|
|
1242
|
+
options = optionsStack.pop();
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1162
1245
|
// check if current tag is in a whitespace stack
|
|
1163
1246
|
if (options.collapseWhitespace) {
|
|
1164
1247
|
if (stackNoTrimWhitespace.length &&
|
|
@@ -1174,8 +1257,8 @@
|
|
|
1174
1257
|
var isElementEmpty = currentChars === '' && tag === currentTag;
|
|
1175
1258
|
if ((options.removeEmptyElements && isElementEmpty && canRemoveElement(tag, attrs))) {
|
|
1176
1259
|
// remove last "element" from buffer, return
|
|
1177
|
-
for (
|
|
1178
|
-
if (
|
|
1260
|
+
for (var i = buffer.length - 1; i >= 0; i--) {
|
|
1261
|
+
if (/^<[^\/!]/.test(buffer[i])) {
|
|
1179
1262
|
buffer.splice(i);
|
|
1180
1263
|
break;
|
|
1181
1264
|
}
|
|
@@ -1188,14 +1271,14 @@
|
|
|
1188
1271
|
}
|
|
1189
1272
|
else {
|
|
1190
1273
|
// push end tag to buffer
|
|
1191
|
-
buffer.push('</' + (options.caseSensitive ? tag :
|
|
1274
|
+
buffer.push('</' + (options.caseSensitive ? tag : lowerTag) + '>');
|
|
1192
1275
|
results.push.apply(results, buffer);
|
|
1193
1276
|
}
|
|
1194
1277
|
// flush buffer
|
|
1195
1278
|
buffer.length = 0;
|
|
1196
1279
|
currentChars = '';
|
|
1197
1280
|
},
|
|
1198
|
-
chars: function(
|
|
1281
|
+
chars: function(text, prevTag, nextTag) {
|
|
1199
1282
|
prevTag = prevTag === '' ? 'comment' : prevTag;
|
|
1200
1283
|
nextTag = nextTag === '' ? 'comment' : nextTag;
|
|
1201
1284
|
|
|
@@ -1215,7 +1298,7 @@
|
|
|
1215
1298
|
text = processScript(text, options, currentAttrs);
|
|
1216
1299
|
}
|
|
1217
1300
|
}
|
|
1218
|
-
if (
|
|
1301
|
+
if (options.minifyJS && isExecutableScript(currentTag, currentAttrs)) {
|
|
1219
1302
|
text = minifyJS(text, options.minifyJS);
|
|
1220
1303
|
}
|
|
1221
1304
|
if (currentTag === 'style' && options.minifyCSS) {
|
|
@@ -1232,10 +1315,12 @@
|
|
|
1232
1315
|
}
|
|
1233
1316
|
}
|
|
1234
1317
|
currentChars = text;
|
|
1235
|
-
|
|
1318
|
+
if (lint) {
|
|
1319
|
+
lint.testChars(text);
|
|
1320
|
+
}
|
|
1236
1321
|
buffer.push(text);
|
|
1237
1322
|
},
|
|
1238
|
-
comment: function(
|
|
1323
|
+
comment: function(text, nonStandard) {
|
|
1239
1324
|
|
|
1240
1325
|
var prefix = nonStandard ? '<!' : '<!--';
|
|
1241
1326
|
var suffix = nonStandard ? '>' : '-->';
|
|
@@ -1276,16 +1361,16 @@
|
|
|
1276
1361
|
return str;
|
|
1277
1362
|
}
|
|
1278
1363
|
|
|
1279
|
-
function joinResultSegments(
|
|
1364
|
+
function joinResultSegments(results, options) {
|
|
1280
1365
|
var str;
|
|
1281
1366
|
var maxLineLength = options.maxLineLength;
|
|
1282
|
-
if (
|
|
1367
|
+
if (maxLineLength) {
|
|
1283
1368
|
var token;
|
|
1284
1369
|
var lines = [];
|
|
1285
1370
|
var line = '';
|
|
1286
|
-
for (
|
|
1371
|
+
for (var i = 0, len = results.length; i < len; i++) {
|
|
1287
1372
|
token = results[i];
|
|
1288
|
-
if (
|
|
1373
|
+
if (line.length + token.length < maxLineLength) {
|
|
1289
1374
|
line += token;
|
|
1290
1375
|
}
|
|
1291
1376
|
else {
|
|
@@ -1305,14 +1390,14 @@
|
|
|
1305
1390
|
}
|
|
1306
1391
|
|
|
1307
1392
|
// for CommonJS enviroments, export everything
|
|
1308
|
-
if (
|
|
1393
|
+
if (typeof exports !== 'undefined') {
|
|
1309
1394
|
exports.minify = minify;
|
|
1310
1395
|
}
|
|
1311
1396
|
else {
|
|
1312
1397
|
global.minify = minify;
|
|
1313
1398
|
}
|
|
1314
1399
|
|
|
1315
|
-
}(this));
|
|
1400
|
+
}(typeof exports === 'undefined' ? this : exports));
|
|
1316
1401
|
|
|
1317
1402
|
/*!
|
|
1318
1403
|
* HTMLLint (to be used in conjunction with HTMLMinifier)
|
|
@@ -1335,7 +1420,7 @@
|
|
|
1335
1420
|
return (/^on[a-z]+/).test(attrName);
|
|
1336
1421
|
}
|
|
1337
1422
|
function isStyleAttribute(attrName) {
|
|
1338
|
-
return (
|
|
1423
|
+
return (attrName.toLowerCase() === 'style');
|
|
1339
1424
|
}
|
|
1340
1425
|
function isDeprecatedAttribute(tag, attrName) {
|
|
1341
1426
|
return (
|
package/dist/htmlminifier.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* HTMLMinifier v0.
|
|
3
|
-
* Copyright 2010-
|
|
4
|
-
* Licensed under MIT
|
|
2
|
+
* HTMLMinifier v0.8.0 (http://kangax.github.io/html-minifier/)
|
|
3
|
+
* Copyright 2010-2015 Juriy "kangax" Zaytsev
|
|
4
|
+
* Licensed under the MIT license
|
|
5
5
|
*/
|
|
6
|
-
!function(a){"use strict";function b(a){var b,c=new RegExp("(?:\\s*[\\w:.-]+(?:\\s*(?:"+d(a)+")\\s*(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>\\s]+))?)*");if(a.customAttrSurround){for(var e=[],f=a.customAttrSurround.length-1;f>=0;f--)e[f]="(?:\\s*"+a.customAttrSurround[f][0].source+c.source+a.customAttrSurround[f][1].source+")";e.unshift(c.source),b=new RegExp("((?:"+e.join("|")+")*)")}else b=new RegExp("("+c.source+")");return new RegExp(j.source+b.source+k.source)}function c(a){var b=new RegExp(f.source+"(?:\\s*("+d(a)+")\\s*(?:"+i.join("|")+"))?");if(a.customAttrSurround){for(var c=[],e=a.customAttrSurround.length-1;e>=0;e--)c[e]="(?:("+a.customAttrSurround[e][0].source+")"+b.source+"("+a.customAttrSurround[e][1].source+"))";return c.unshift("(?:"+b.source+")"),new RegExp(c.join("|"),"g")}return new RegExp(b.source,"g")}function d(a){return h.concat(a.customAttrAssign||[]).map(function(a){return"(?:"+a.source+")"}).join("|")}function e(a){for(var b={},c=a.split(","),d=0;d<c.length;d++)b[c[d]]=!0,b[c[d].toUpperCase()]=!0;return b}var f=/([\w:.-]+)/,g=/=/,h=[g],i=[/"((?:\\.|[^"])*)"/.source,/'((?:\\.|[^'])*)'/.source,/([^>\s]+)/.source],j=/^<([\w:-]+)/,k=/\s*(\/?)>/,l=/^<\/([\w:-]+)[^>]*>/,m=/\/>$/,n=/^<!DOCTYPE [^>]+>/i,o=!1;"x".replace(/x(.)?/g,function(a,b){o=""===b});var p,q,r,s=e("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed,wbr"),t=e("a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,noscript,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,svg,textarea,tt,u,var"),u=e("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),v=e("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),w=e("script,style,noscript"),x={},y=a.HTMLParser=function(a,d){function e(a,b,c,e){for(var g=!1;!d.html5&&y.last()&&t[y.last()];)f("",y.last());u[b]&&y.last()===b&&f("",b),e=s[b]||!!e;var h=[];c.replace(B,function(){var a,b,c,e,f,g,i=7;if(o&&-1===arguments[0].indexOf('""')&&(""===arguments[3]&&(arguments[3]=void 0),""===arguments[4]&&(arguments[4]=void 0),""===arguments[5]&&(arguments[5]=void 0)),a=arguments[1])g=arguments[2],c=arguments[3],b=c||arguments[4]||arguments[5];else if(d.customAttrSurround)for(var j=d.customAttrSurround.length-1;j>=0;j--)if(a=arguments[j*i+7],g=arguments[j*i+8],a){c=arguments[j*i+9],b=c||arguments[j*i+10]||arguments[j*i+11],e=arguments[j*i+6],f=arguments[j*i+12];break}void 0===b&&(b=v[a]?a:c),h.push({name:a,value:b,escaped:b&&b.replace(/(^|.)("+)/g,function(a){return a.replace(/"/g,""")}),customAssign:g||"=",customOpen:e||"",customClose:f||""})}),e?g=a.match(m):y.push({tag:b,attrs:h}),d.start&&d.start(b,h,e,g)}function f(a,b){var c;if(b){var e=b.toLowerCase();for(c=y.length-1;c>=0&&y[c].tag.toLowerCase()!==e;c--);}else c=0;if(c>=0){for(var f=y.length-1;f>=c;f--)d.end&&d.end(y[f].tag,y[f].attrs);y.length=c}}var g,h,i,j,k,y=[],z=a;y.last=function(){var a=this[this.length-1];return a&&a.tag};for(var A=b(d),B=c(d);a;){if(h=!0,y.last()&&w[y.last()])p=y.last().toLowerCase(),q=x[p]||(x[p]=new RegExp("([\\s\\S]*?)</"+p+"[^>]*>","i")),a=a.replace(q,function(a,b){return"script"!==p&&"style"!==p&&"noscript"!==p&&(b=b.replace(/<!--([\s\S]*?)-->/g,"$1").replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g,"$1")),d.chars&&d.chars(b),""}),f("",p);else if(/^<!--/.test(a)&&(g=a.indexOf("-->"),g>=0&&(d.comment&&d.comment(a.substring(4,g)),a=a.substring(g+3),h=!1)),/^<!\[/.test(a)?(g=a.indexOf("]>"),g>=0&&(d.comment&&d.comment(a.substring(2,g+1),!0),a=a.substring(g+2),h=!1)):/^<\?/.test(a)?(g=a.indexOf("?>",2),g>=0&&(d.chars&&d.chars(a.substring(0,g+2)),a=a.substring(g+2))):/^<%/.test(a)?(g=a.indexOf("%>",2),g>=0&&(d.chars&&d.chars(a.substring(0,g+2)),a=a.substring(g+2))):(i=n.exec(a))?(d.doctype&&d.doctype(i[0]),a=a.substring(i[0].length),h=!1):/^<\//.test(a)?(i=a.match(l),i&&(a=a.substring(i[0].length),i[0].replace(l,f),j="/"+i[1].toLowerCase(),h=!1)):/^</.test(a)&&(i=a.match(A),i&&(a=a.substring(i[0].length),i[0].replace(A,e),j=i[1].toLowerCase(),h=!1)),h){g=a.indexOf("<");var C=0>g?a:a.substring(0,g);a=0>g?"":a.substring(g),r=a.match(A),r?k=r[1]:(r=a.match(l),k=r?"/"+r[1]:""),d.chars&&d.chars(C,j,k)}if(a===z)throw"Parse Error: "+a;z=a}f()};a.HTMLtoXML=function(a){var b="";return new y(a,{start:function(a,c,d){b+="<"+a;for(var e=0;e<c.length;e++)b+=" "+c[e].name+'="'+c[e].escaped+'"';b+=(d?"/":"")+">"},end:function(a){b+="</"+a+">"},chars:function(a){b+=a},comment:function(a){b+="<!--"+a+"-->"},ignore:function(a){b+=a}}),b},a.HTMLtoDOM=function(a,b){var c=e("html,head,body,title"),d={link:"head",base:"head"};b?b=b.ownerDocument||b.getOwnerDocument&&b.getOwnerDocument()||b:"undefined"!=typeof DOMDocument?b=new DOMDocument:"undefined"!=typeof document&&document.implementation&&document.implementation.createDocument?b=document.implementation.createDocument("","",null):"undefined"!=typeof ActiveX&&(b=new ActiveXObject("Msxml.DOMDocument"));var f=[],g=b.documentElement||b.getDocumentElement&&b.getDocumentElement();if(!g&&b.createElement&&!function(){var a=b.createElement("html"),c=b.createElement("head");c.appendChild(b.createElement("title")),a.appendChild(c),a.appendChild(b.createElement("body")),b.appendChild(a)}(),b.getElementsByTagName)for(var h in c)c[h]=b.getElementsByTagName(h)[0];var i=c.body;return new y(a,{start:function(a,e,g){if(c[a])return void(i=c[a]);var h=b.createElement(a);for(var j in e)h.setAttribute(e[j].name,e[j].value);d[a]&&"boolean"!=typeof c[d[a]]?c[d[a]].appendChild(h):i&&i.appendChild&&i.appendChild(h),g||(f.push(h),i=h)},end:function(){f.length-=1,i=f[f.length-1]},chars:function(a){i.appendChild(b.createTextNode(a))},comment:function(){},ignore:function(){}}),b}}("undefined"==typeof exports?this:exports),function(a){"use strict";function b(a){return a?a.replace(/[\t\n\r ]+/g," "):a}function c(a,b,c,d){var e=["a","abbr","acronym","b","bdi","bdo","big","button","cite","code","del","dfn","em","font","i","ins","kbd","mark","q","rt","rp","s","samp","small","span","strike","strong","sub","sup","svg","time","tt","u","var"],f=/^[\t ]*[\n\r]+[\t\n\r ]*/,g=/[\t\n\r ]*[\n\r]+[\t ]*$/,h=f.test(a)?"\n":" ",i=g.test(a)?"\n":" ",j="[{htmlmin-lb}]";return b&&"img"!==b&&"input"!==b&&("/"!==b.substr(0,1)||"/"===b.substr(0,1)&&-1===e.indexOf(b.substr(1)))&&(a=a.replace(/^\s+/,d.conservativeCollapse?" ":d.preserveLineBreaks?h:"")),c&&"img"!==c&&"input"!==c&&("/"===c.substr(0,1)||"/"!==c.substr(0,1)&&-1===e.indexOf(c))&&(a=a.replace(/\s+$/,d.conservativeCollapse?" ":d.preserveLineBreaks?i:"")),b&&c?(d.preserveLineBreaks&&(a=a.replace(f,j).replace(g,j)),a.replace(/[\t\n\r]+/g," ").replace(/[ ]+/g," ").replace(j,"\n")):a}function d(a){return/\[if[^\]]+\]/.test(a)||/\s*((?:<!)?\[endif\])$/.test(a)}function e(a,b){if(/^!/.test(a))return!0;if(b.ignoreCustomComments)for(var c=0,d=b.ignoreCustomComments.length;d>c;c++)if(b.ignoreCustomComments[c].test(a))return!0;return!1}function f(a){return/^on[a-z]+/.test(a)}function g(a){return/^[^\x20\t\n\f\r"'`=<>]+$/.test(a)&&!/\/$/.test(a)&&!/\/$/.test(a)}function h(a,b){for(var c=a.length;c--;)if(a[c].name.toLowerCase()===b)return!0;return!1}function i(a,b,c,d){return c=c?J(c.toLowerCase()):"","script"===a&&"language"===b&&"javascript"===c||"form"===a&&"method"===b&&"get"===c||"input"===a&&"type"===b&&"text"===c||"script"===a&&"charset"===b&&!h(d,"src")||"a"===a&&"name"===b&&h(d,"id")||"area"===a&&"shape"===b&&"rect"===c}function j(a,b,c){return"script"===a&&"type"===b&&"text/javascript"===J(c.toLowerCase())}function k(a,b,c){return("style"===a||"link"===a)&&"type"===b&&"text/css"===J(c.toLowerCase())}function l(a,b){var c=/^(?:allowfullscreen|async|autofocus|autoplay|checked|compact|controls|declare|default|defaultchecked|defaultmuted|defaultselected|defer|disabled|enabled|formnovalidate|hidden|indeterminate|inert|ismap|itemscope|loop|multiple|muted|nohref|noresize|noshade|novalidate|nowrap|open|pauseonexit|readonly|required|reversed|scoped|seamless|selected|sortable|spellcheck|truespeed|typemustmatch|visible)$/i.test(a);if(c)return!0;var d=K[a.toLowerCase()];return d?-1===d.indexOf(b.toLowerCase()):!1}function m(a,b){return/^(?:a|area|link|base)$/.test(b)&&"href"===a||"img"===b&&/^(?:src|longdesc|usemap)$/.test(a)||"object"===b&&/^(?:classid|codebase|data|usemap)$/.test(a)||"q"===b&&"cite"===a||"blockquote"===b&&"cite"===a||("ins"===b||"del"===b)&&"cite"===a||"form"===b&&"action"===a||"input"===b&&("src"===a||"usemap"===a)||"head"===b&&"profile"===a||"script"===b&&("src"===a||"for"===a)}function n(a,b){return/^(?:a|area|object|button)$/.test(b)&&"tabindex"===a||"input"===b&&("maxlength"===a||"tabindex"===a)||"select"===b&&("size"===a||"tabindex"===a)||"textarea"===b&&/^(?:rows|cols|tabindex)$/.test(a)||"colgroup"===b&&"span"===a||"col"===b&&"span"===a||("th"===b||"td"===b)&&("rowspan"===a||"colspan"===a)}function o(a,c,d,e,g){if(d&&f(c)){if(d=J(d).replace(/^javascript:\s*/i,"").replace(/\s*;$/,""),e.minifyJS){var h="(function(){"+d+"})()",i=D(h,e.minifyJS);return i.slice(12,i.length-4).replace(/"/g,""")}return d}return"class"===c?b(J(d)):m(c,a)?(d=J(d),e.minifyURLs?C(d,e.minifyURLs):d):n(c,a)?J(d):"style"===c?(d=J(d),d&&(d=d.replace(/\s*;\s*$/,"")),e.minifyCSS?E(d,e.minifyCSS):d):(p(a,g)&&"content"===c?d=d.replace(/1\.0/g,"1").replace(/\s+/g,""):d&&e.customAttrCollapse&&e.customAttrCollapse.test(c)&&(d=d.replace(/\n+/g,"")),d)}function p(a,b){if("meta"!==a)return!1;for(var c=0,d=b.length;d>c;c++)if("name"===b[c].name&&"viewport"===b[c].value)return!0}function q(a){return a.replace(/^(\[[^\]]+\]>)\s*/,"$1").replace(/\s*(<!\[endif\])$/,"$1")}function r(a){return a.replace(/^(?:\s*\/\*\s*<!\[CDATA\[\s*\*\/|\s*\/\/\s*<!\[CDATA\[.*)/,"").replace(/(?:\/\*\s*\]\]>\s*\*\/|\/\/\s*\]\]>)\s*$/,"")}function s(a,b,c){for(var d=0,e=c.length;e>d;d++)if("type"===c[d].name.toLowerCase()&&b.processScripts.indexOf(c[d].value)>-1)return F(a,b);return a}function t(a,b){return a.replace(L[b],"").replace(M[b],"")}function u(a){return/^(?:html|t?body|t?head|tfoot|tr|td|th|dt|dd|option|colgroup|source)$/.test(a)}function v(a,b,c){var d=!c||/^\s*$/.test(c);return d?"input"===a&&"value"===b||N.test(b):!1}function w(a,b){if("textarea"===a)return!1;if("script"===a)for(var c=b.length-1;c>=0;c--)if("src"===b[c].name)return!1;return!0}function x(a){return!/^(?:script|style|pre|textarea)$/.test(a)}function y(a){return!/^(?:pre|textarea)$/.test(a)}function z(a){for(var b="",c=0,d=a.length;d>c;c++)b+=" "+a[c].name+(l(a[c].value)?"":'="'+a[c].value+'"');return b}function A(a,b,c,d,e,f){var h,m,n=f.caseSensitive?a.name:a.name.toLowerCase(),p=a.escaped,q=d&&e===b.length-1;return f.removeRedundantAttributes&&i(c,n,p,b)||f.removeScriptTypeAttributes&&j(c,n,p)||f.removeStyleLinkTypeAttributes&&k(c,n,p)?"":(p=o(c,n,p,f,b),m=void 0!==p&&!f.removeAttributeQuotes||!g(p)||q?'"'+p+'"':p,f.removeEmptyAttributes&&v(c,n,p)?"":(h=void 0===p||f.collapseBooleanAttributes&&l(n,p)?n:n+a.customAssign+m," "+a.customOpen+h+a.customClose))}function B(a){for(var b=["canCollapseWhitespace","canTrimWhitespace"],c=0,d=b.length;d>c;c++)a[b[c]]||(a[b[c]]=function(){return!1})}function C(b,c){"object"!=typeof c&&(c={});try{var d=a.RelateUrl;return"undefined"==typeof d&&"function"==typeof require&&(d=require("relateurl")),d&&d.relate?d.relate(b,c):b}catch(e){H(e)}return b}function D(b,c){"object"!=typeof c&&(c={}),c.fromString=!0,c.output={inline_script:!0};try{var d=a.UglifyJS;if("undefined"==typeof d&&"function"==typeof require&&(d=require("uglify-js")),!d)return b;if(d.minify)return d.minify(b,c).code;if(d.parse){var e=d.parse(b);e.figure_out_scope();var f=d.Compressor(),g=e.transform(f);g.figure_out_scope(),g.compute_char_frequency(),c.mangle!==!1&&g.mangle_names();var h=d.OutputStream(c.output);return g.print(h),h.toString()}return b}catch(i){H(i)}return b}function E(a,b){"object"!=typeof b&&(b={}),"undefined"==typeof b.noAdvanced&&(b.noAdvanced=!0);try{if("undefined"!=typeof CleanCSS)return new CleanCSS(b).minify(a);if("function"==typeof require){var c=require("clean-css");return new c(b).minify(a)}}catch(d){H(d)}return a}function F(a,f){function g(a,b){return x(a)||f.canCollapseWhitespace(a,b)}function h(a,b){return y(a)||f.canTrimWhitespace(a,b)}f=f||{},a=J(a),B(f);var i=[],j=[],k="",l="",m=[],n=[],o=[],p=f.lint,v=!1,C=new Date;f.removeIgnored&&(a=a.replace(/<\?[^\?]+\?>/g,"").replace(/<%[^%]+%>/g,"")),new I(a,{html5:"undefined"!=typeof f.html5?f.html5:!0,start:function(a,b,c,d){if(v)return void j.push("<"+a,z(b),d?"/":"",">");a=f.caseSensitive?a:a.toLowerCase(),l=a,k="",m=b,f.collapseWhitespace&&(h(a,b)||n.push(a),g(a,b)||o.push(a));var e="<"+a,i=(d&&f.keepClosingSlash?"/":"")+">";0===b.length&&(e+=i),j.push(e),p&&p.testElement(a);for(var q,r=0,s=b.length;s>r;r++)p&&p.testAttribute(a,b[r].name.toLowerCase(),b[r].escaped),q=A(b[r],b,a,d,r,f),r===s-1&&(q+=i),j.push(q)},end:function(a,b){if(v)return void j.push("</"+a+">");f.collapseWhitespace&&(n.length&&a===n[n.length-1]&&n.pop(),o.length&&a===o[o.length-1]&&o.pop());var c=""===k&&a===l;if(f.removeEmptyElements&&c&&w(a,b)){for(var d=j.length-1;d>=0;d--)if(/^<[^\/!]/.test(j[d])){j.splice(d);break}}else f.removeOptionalTags&&u(a)||(j.push("</"+(f.caseSensitive?a:a.toLowerCase())+">"),i.push.apply(i,j),j.length=0,k="")},chars:function(a,d,e){return d=""===d?"comment":d,e=""===e?"comment":e,v?void j.push(a):(("script"===l||"style"===l)&&(f.removeCommentsFromCDATA&&(a=t(a,l)),f.removeCDATASectionsFromCDATA&&(a=r(a)),f.processScripts&&(a=s(a,f,m))),"script"===l&&f.minifyJS&&(a=D(a,f.minifyJS)),"style"===l&&f.minifyCSS&&(a=E(a,f.minifyCSS)),f.collapseWhitespace&&(n.length||(a=d&&"comment"!==d||e&&"comment"!==e?c(a,d,e,f):J(a)),o.length||(a=d&&e||"html"===e?a:b(a))),k=a,p&&p.testChars(a),void j.push(a))},comment:function(a,b){var c=b?"<!":"<!--",g=b?">":"-->";return/^\s*htmlmin:ignore/.test(a)?(v=!v,void(f.removeComments||j.push("<!--"+a+"-->"))):(a=f.removeComments?d(a)?c+q(a)+g:e(a,f)?"<!--"+a+"-->":"":c+a+g,void j.push(a))},doctype:function(a){j.push(f.useShortDoctype?"<!DOCTYPE html>":b(a))},customAttrAssign:f.customAttrAssign,customAttrSurround:f.customAttrSurround}),i.push.apply(i,j);var F=G(i,f);return H("minified in: "+(new Date-C)+"ms"),F}function G(a,b){var c,d=b.maxLineLength;if(d){for(var e,f=[],g="",h=0,i=a.length;i>h;h++)e=a[h],g.length+e.length<d?g+=e:(f.push(g.replace(/^\n/,"")),g=e);f.push(g),c=f.join("\n")}else c=a.join("");return c}var H,I;H=a.console&&a.console.log?function(b){a.console.log(b)}:function(){},a.HTMLParser?I=a.HTMLParser:"function"==typeof require&&(I=require("./htmlparser").HTMLParser);var J=function(a){return"string"!=typeof a?a:a.replace(/^\s+/,"").replace(/\s+$/,"")};String.prototype.trim&&(J=function(a){return"string"!=typeof a?a:a.trim()});var K={draggable:["true","false"]},L={script:/^\s*(?:\/\/)?\s*<!--.*\n?/,style:/^\s*<!--\s*/},M={script:/\s*(?:\/\/)?\s*-->\s*$/,style:/\s*-->\s*$/},N=new RegExp("^(?:class|id|style|title|lang|dir|on(?:focus|blur|change|click|dblclick|mouse(?:down|up|over|move|out)|key(?:press|down|up)))$");"undefined"!=typeof exports?exports.minify=F:a.minify=F}(this),function(a){"use strict";function b(a){return/^(?:big|small|hr|blink|marquee)$/.test(a)}function c(a){return/^(?:applet|basefont|center|dir|font|isindex|strike)$/.test(a)}function d(a){return/^on[a-z]+/.test(a)}function e(a){return"style"===a.toLowerCase()}function f(a,b){return"align"===b&&/^(?:caption|applet|iframe|img|imput|object|legend|table|hr|div|h[1-6]|p)$/.test(a)||"alink"===b&&"body"===a||"alt"===b&&"applet"===a||"archive"===b&&"applet"===a||"background"===b&&"body"===a||"bgcolor"===b&&/^(?:table|t[rdh]|body)$/.test(a)||"border"===b&&/^(?:img|object)$/.test(a)||"clear"===b&&"br"===a||"code"===b&&"applet"===a||"codebase"===b&&"applet"===a||"color"===b&&/^(?:base(?:font)?)$/.test(a)||"compact"===b&&/^(?:dir|[dou]l|menu)$/.test(a)||"face"===b&&/^base(?:font)?$/.test(a)||"height"===b&&/^(?:t[dh]|applet)$/.test(a)||"hspace"===b&&/^(?:applet|img|object)$/.test(a)||"language"===b&&"script"===a||"link"===b&&"body"===a||"name"===b&&"applet"===a||"noshade"===b&&"hr"===a||"nowrap"===b&&/^t[dh]$/.test(a)||"object"===b&&"applet"===a||"prompt"===b&&"isindex"===a||"size"===b&&/^(?:hr|font|basefont)$/.test(a)||"start"===b&&"ol"===a||"text"===b&&"body"===a||"type"===b&&/^(?:li|ol|ul)$/.test(a)||"value"===b&&"li"===a||"version"===b&&"html"===a||"vlink"===b&&"body"===a||"vspace"===b&&/^(?:applet|img|object)$/.test(a)||"width"===b&&/^(?:hr|td|th|applet|pre)$/.test(a)}function g(a,b){return"href"===a&&/^\s*javascript\s*:\s*void\s*(\s+0|\(\s*0\s*\))\s*$/i.test(b)}function h(){this.log=[],this._lastElement=null,this._isElementRepeated=!1}h.prototype.testElement=function(a){c(a)?this.log.push('Found <span class="deprecated-element">deprecated</span> <strong><code><'+a+"></code></strong> element"):b(a)?this.log.push('Found <span class="presentational-element">presentational</span> <strong><code><'+a+"></code></strong> element"):this.checkRepeatingElement(a)},h.prototype.checkRepeatingElement=function(a){"br"===a&&"br"===this._lastElement?this._isElementRepeated=!0:this._isElementRepeated&&(this._reportRepeatingElement(),this._isElementRepeated=!1),this._lastElement=a},h.prototype._reportRepeatingElement=function(){this.log.push("Found <code><br></code> sequence. Try replacing it with styling.")},h.prototype.testAttribute=function(a,b,c){d(b)?this.log.push('Found <span class="event-attribute">event attribute</span> (<strong>'+b+"</strong>) on <strong><code><"+a+"></code></strong> element."):f(a,b)?this.log.push('Found <span class="deprecated-attribute">deprecated</span> <strong>'+b+"</strong> attribute on <strong><code><"+a+"></code></strong> element."):e(b)?this.log.push('Found <span class="style-attribute">style attribute</span> on <strong><code><'+a+"></code></strong> element."):g(b,c)&&this.log.push('Found <span class="inaccessible-attribute">inaccessible attribute</span> (on <strong><code><'+a+"></code></strong> element).")},h.prototype.testChars=function(a){this._lastElement="",/( \s*){2,}/.test(a)&&this.log.push("Found repeating <strong><code>&nbsp;</code></strong> sequence. Try replacing it with styling.")},h.prototype.test=function(a,b,c){this.testElement(a),this.testAttribute(a,b,c)},h.prototype.populate=function(a){if(this._isElementRepeated&&this._reportRepeatingElement(),this.log.length)if(a)a.innerHTML="<ol><li>"+this.log.join("<li>")+"</ol>";else{var b=" - "+this.log.join("\n - ").replace(/(<([^>]+)>)/gi,"").replace(/</g,"<").replace(/>/g,">");console.log(b)}},a.HTMLLint=h}("undefined"==typeof exports?this:exports);
|
|
6
|
+
!function(a){"use strict";function b(a){var b,c=new RegExp("(?:\\s*[\\w:\\.-]+(?:\\s*(?:"+d(a)+")\\s*(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>\\s]+))?)*");if(a.customAttrSurround){for(var e=[],f=a.customAttrSurround.length-1;f>=0;f--)e[f]="(?:\\s*"+a.customAttrSurround[f][0].source+c.source+a.customAttrSurround[f][1].source+")";e.unshift(c.source),b=new RegExp("((?:"+e.join("|")+")*)")}else b=new RegExp("("+c.source+")");return new RegExp(j.source+b.source+k.source)}function c(a){var b=new RegExp(f.source+"(?:\\s*("+d(a)+")\\s*(?:"+i.join("|")+"))?");if(a.customAttrSurround){for(var c=[],e=a.customAttrSurround.length-1;e>=0;e--)c[e]="(?:("+a.customAttrSurround[e][0].source+")"+b.source+"("+a.customAttrSurround[e][1].source+"))";return c.unshift("(?:"+b.source+")"),new RegExp(c.join("|"),"g")}return new RegExp(b.source,"g")}function d(a){return h.concat(a.customAttrAssign||[]).map(function(a){return"(?:"+a.source+")"}).join("|")}function e(a){for(var b={},c=a.split(","),d=0;d<c.length;d++)b[c[d]]=!0,b[c[d].toUpperCase()]=!0;return b}var f=/([\w:\.-]+)/,g=/=/,h=[g],i=[/"((?:\\.|[^"])*)"/.source,/'((?:\\.|[^'])*)'/.source,/([^>\s]+)/.source],j=/^<([\w:-]+)/,k=/\s*(\/?)>/,l=/^<\/([\w:-]+)[^>]*>/,m=/\/>$/,n=/^<!DOCTYPE [^>]+>/i,o=!1;"x".replace(/x(.)?/g,function(a,b){o=""===b});var p,q,r,s=e("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed,wbr"),t=e("a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,noscript,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,svg,textarea,tt,u,var"),u=e("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),v=e("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),w=e("script,style,noscript"),x={},y=a.HTMLParser=function(a,d){function e(a,b,c,e){for(var g=!1;!d.html5&&y.last()&&t[y.last()];)f("",y.last());u[b]&&y.last()===b&&f("",b),e=s[b]||!!e;var h=[];c.replace(B,function(){var a,b,c,e,f,g,i,j=7;if(o&&-1===arguments[0].indexOf('""')&&(""===arguments[3]&&(arguments[3]=void 0),""===arguments[4]&&(arguments[4]=void 0),""===arguments[5]&&(arguments[5]=void 0)),a=arguments[1])g=arguments[2],c=arguments[3],b=c||arguments[4]||arguments[5],g&&(i=arguments[0].charAt(a.length+g.length),i="'"===i||'"'===i?i:"");else if(d.customAttrSurround)for(var k=d.customAttrSurround.length-1;k>=0;k--)if(a=arguments[k*j+7],g=arguments[k*j+8],a){c=arguments[k*j+9],b=c||arguments[k*j+10]||arguments[k*j+11],e=arguments[k*j+6],f=arguments[k*j+12];break}void 0===b&&(b=v[a]?a:c),h.push({name:a,value:b,escaped:b&&b.replace(/(^|.)("+)/g,function(a){return a.replace(/"/g,""")}),customAssign:g||"=",customOpen:e||"",customClose:f||"",quote:i||""})}),e?g=a.match(m):y.push({tag:b,attrs:h}),d.start&&d.start(b,h,e,g)}function f(a,b){var c;if(b){var e=b.toLowerCase();for(c=y.length-1;c>=0&&y[c].tag.toLowerCase()!==e;c--);}else c=0;if(c>=0){for(var f=y.length-1;f>=c;f--)d.end&&d.end(y[f].tag,y[f].attrs);y.length=c}}var g,h,i,j,k,y=[],z=a;y.last=function(){var a=this[this.length-1];return a&&a.tag};for(var A=b(d),B=c(d);a;){if(h=!0,y.last()&&w[y.last()])p=y.last().toLowerCase(),q=x[p]||(x[p]=new RegExp("([\\s\\S]*?)</"+p+"[^>]*>","i")),a=a.replace(q,function(a,b){return"script"!==p&&"style"!==p&&"noscript"!==p&&(b=b.replace(/<!--([\s\S]*?)-->/g,"$1").replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g,"$1")),d.chars&&d.chars(b),""}),f("",p);else if(/^<!--/.test(a)&&(g=a.indexOf("-->"),g>=0&&(d.comment&&d.comment(a.substring(4,g)),a=a.substring(g+3),h=!1)),/^<!\[/.test(a)?(g=a.indexOf("]>"),g>=0&&(d.comment&&d.comment(a.substring(2,g+1),!0),a=a.substring(g+2),h=!1)):/^<\?/.test(a)?(g=a.indexOf("?>",2),g>=0&&(d.chars&&d.chars(a.substring(0,g+2)),a=a.substring(g+2))):/^<%/.test(a)?(g=a.indexOf("%>",2),g>=0&&(d.chars&&d.chars(a.substring(0,g+2)),a=a.substring(g+2))):(i=n.exec(a))?(d.doctype&&d.doctype(i[0]),a=a.substring(i[0].length),h=!1):/^<\//.test(a)?(i=a.match(l),i&&(a=a.substring(i[0].length),i[0].replace(l,f),j="/"+i[1].toLowerCase(),h=!1)):/^</.test(a)&&(i=a.match(A),i&&(a=a.substring(i[0].length),i[0].replace(A,e),j=i[1].toLowerCase(),h=!1)),h){g=a.indexOf("<");var C=0>g?a:a.substring(0,g);a=0>g?"":a.substring(g),r=a.match(A),r?k=r[1]:(r=a.match(l),k=r?"/"+r[1]:""),d.chars&&d.chars(C,j,k)}if(a===z)throw"Parse Error: "+a;z=a}f()};a.HTMLtoXML=function(a){var b="";return new y(a,{start:function(a,c,d){b+="<"+a;for(var e=0;e<c.length;e++)b+=" "+c[e].name+'="'+c[e].escaped+'"';b+=(d?"/":"")+">"},end:function(a){b+="</"+a+">"},chars:function(a){b+=a},comment:function(a){b+="<!--"+a+"-->"},ignore:function(a){b+=a}}),b},a.HTMLtoDOM=function(a,b){var c=e("html,head,body,title"),d={link:"head",base:"head"};b?b=b.ownerDocument||b.getOwnerDocument&&b.getOwnerDocument()||b:"undefined"!=typeof DOMDocument?b=new DOMDocument:"undefined"!=typeof document&&document.implementation&&document.implementation.createDocument?b=document.implementation.createDocument("","",null):"undefined"!=typeof ActiveX&&(b=new ActiveXObject("Msxml.DOMDocument"));var f=[],g=b.documentElement||b.getDocumentElement&&b.getDocumentElement();if(!g&&b.createElement&&!function(){var a=b.createElement("html"),c=b.createElement("head");c.appendChild(b.createElement("title")),a.appendChild(c),a.appendChild(b.createElement("body")),b.appendChild(a)}(),b.getElementsByTagName)for(var h in c)c[h]=b.getElementsByTagName(h)[0];var i=c.body;return new y(a,{start:function(a,e,g){if(c[a])return void(i=c[a]);var h=b.createElement(a);for(var j in e)h.setAttribute(e[j].name,e[j].value);d[a]&&"boolean"!=typeof c[d[a]]?c[d[a]].appendChild(h):i&&i.appendChild&&i.appendChild(h),g||(f.push(h),i=h)},end:function(){f.length-=1,i=f[f.length-1]},chars:function(a){i.appendChild(b.createTextNode(a))},comment:function(){},ignore:function(){}}),b}}("undefined"==typeof exports?this:exports),function(a){"use strict";function b(a){return a?a.replace(/[\t\n\r ]+/g," "):a}function c(a,b,c,d){var e=["a","abbr","acronym","b","bdi","bdo","big","button","cite","code","del","dfn","em","font","i","ins","kbd","mark","q","rt","rp","s","samp","small","span","strike","strong","sub","sup","svg","time","tt","u","var"],f=/^[\t ]*[\n\r]+[\t\n\r ]*/,g=/[\t\n\r ]*[\n\r]+[\t ]*$/,h=f.test(a)?"\n":" ",i=g.test(a)?"\n":" ",j="htmlmincollapsedlinebreak";return b&&"img"!==b&&"input"!==b&&("/"!==b.substr(0,1)||"/"===b.substr(0,1)&&-1===e.indexOf(b.substr(1)))&&(a=a.replace(/^\s+/,d.conservativeCollapse?" ":d.preserveLineBreaks?h:"")),c&&"img"!==c&&"input"!==c&&("/"===c.substr(0,1)||"/"!==c.substr(0,1)&&-1===e.indexOf(c))&&(a=a.replace(/\s+$/,d.conservativeCollapse?" ":d.preserveLineBreaks?i:"")),b&&c?(d.preserveLineBreaks&&(a=a.replace(f,j).replace(g,j)),a.replace(/[\t\n\r]+/g," ").replace(/[ ]+/g," ").replace(new RegExp(j,"g"),"\n")):a}function d(a){return/\[if[^\]]+\]/.test(a)||/\s*((?:<!)?\[endif\])$/.test(a)}function e(a,b){if(/^!/.test(a))return!0;if(b.ignoreCustomComments)for(var c=0,d=b.ignoreCustomComments.length;d>c;c++)if(b.ignoreCustomComments[c].test(a))return!0;return!1}function f(a){return/^on[a-z]+/.test(a)}function g(a){return/^[^\x20\t\n\f\r"'`=<>]+$/.test(a)&&!/\/$/.test(a)&&!/\/$/.test(a)}function h(a,b){for(var c=a.length;c--;)if(a[c].name.toLowerCase()===b)return!0;return!1}function i(a,b,c,d){return c=c?M(c.toLowerCase()):"","script"===a&&"language"===b&&"javascript"===c||"form"===a&&"method"===b&&"get"===c||"input"===a&&"type"===b&&"text"===c||"script"===a&&"charset"===b&&!h(d,"src")||"a"===a&&"name"===b&&h(d,"id")||"area"===a&&"shape"===b&&"rect"===c}function j(a,b,c){return"script"===a&&"type"===b&&"text/javascript"===M(c.toLowerCase())}function k(a,b){if("script"!==a)return!1;for(var c=0,d=b.length;d>c;c++){var e=b[c].name.toLowerCase();if("type"===e)return""===b[c].value||1===N[b[c].value]}return!0}function l(a,b,c){return("style"===a||"link"===a)&&"type"===b&&"text/css"===M(c.toLowerCase())}function m(a,b){var c=/^(?:allowfullscreen|async|autofocus|autoplay|checked|compact|controls|declare|default|defaultchecked|defaultmuted|defaultselected|defer|disabled|enabled|formnovalidate|hidden|indeterminate|inert|ismap|itemscope|loop|multiple|muted|nohref|noresize|noshade|novalidate|nowrap|open|pauseonexit|readonly|required|reversed|scoped|seamless|selected|sortable|spellcheck|truespeed|typemustmatch|visible)$/i.test(a);if(c)return!0;var d=O[a.toLowerCase()];return d?-1===d.indexOf(b.toLowerCase()):!1}function n(a,b){return/^(?:a|area|link|base)$/.test(b)&&"href"===a||"img"===b&&/^(?:src|longdesc|usemap)$/.test(a)||"object"===b&&/^(?:classid|codebase|data|usemap)$/.test(a)||"q"===b&&"cite"===a||"blockquote"===b&&"cite"===a||("ins"===b||"del"===b)&&"cite"===a||"form"===b&&"action"===a||"input"===b&&("src"===a||"usemap"===a)||"head"===b&&"profile"===a||"script"===b&&("src"===a||"for"===a)}function o(a,b){return/^(?:a|area|object|button)$/.test(b)&&"tabindex"===a||"input"===b&&("maxlength"===a||"tabindex"===a)||"select"===b&&("size"===a||"tabindex"===a)||"textarea"===b&&/^(?:rows|cols|tabindex)$/.test(a)||"colgroup"===b&&"span"===a||"col"===b&&"span"===a||("th"===b||"td"===b)&&("rowspan"===a||"colspan"===a)}function p(a,c,d,e,g){if(d&&f(c)){if(d=M(d).replace(/^javascript:\s*/i,"").replace(/\s*;$/,""),e.minifyJS){var h="(function(){"+d+"})()",i=G(h,e.minifyJS);return i.slice(12,i.length-4).replace(/"/g,""")}return d}return"class"===c?b(M(d)):n(c,a)?(d=M(d),e.minifyURLs?F(d,e.minifyURLs):d):o(c,a)?M(d):"style"===c?(d=M(d),d&&(d=d.replace(/\s*;\s*$/,"")),e.minifyCSS?H(d,e.minifyCSS,!0):d):(q(a,g)&&"content"===c?d=d.replace(/1\.0/g,"1").replace(/\s+/g,""):d&&e.customAttrCollapse&&e.customAttrCollapse.test(c)&&(d=d.replace(/\n+/g,"")),d)}function q(a,b){if("meta"!==a)return!1;for(var c=0,d=b.length;d>c;c++)if("name"===b[c].name&&"viewport"===b[c].value)return!0}function r(a){return"*{"+a+"}"}function s(a){var b=a.match(/^\*\{([\s\S]*)\}$/m);return b&&b[1]?b[1]:a}function t(a){return a.replace(/^(\[[^\]]+\]>)\s*/,"$1").replace(/\s*(<!\[endif\])$/,"$1")}function u(a){return a.replace(/^(?:\s*\/\*\s*<!\[CDATA\[\s*\*\/|\s*\/\/\s*<!\[CDATA\[.*)/,"").replace(/(?:\/\*\s*\]\]>\s*\*\/|\/\/\s*\]\]>)\s*$/,"")}function v(a,b,c){for(var d=0,e=c.length;e>d;d++)if("type"===c[d].name.toLowerCase()&&b.processScripts.indexOf(c[d].value)>-1)return I(a,b);return a}function w(a,b){return a.replace(P[b],"").replace(Q[b],"")}function x(a){return/^(?:html|t?body|t?head|tfoot|tr|td|th|dt|dd|option|colgroup|source|track)$/.test(a)}function y(a,b,c){var d=!c||/^\s*$/.test(c);return d?"input"===a&&"value"===b||R.test(b):!1}function z(a,b){if("textarea"===a)return!1;if("script"===a)for(var c=b.length-1;c>=0;c--)if("src"===b[c].name)return!1;return!0}function A(a){return!/^(?:script|style|pre|textarea)$/.test(a)}function B(a){return!/^(?:pre|textarea)$/.test(a)}function C(a){for(var b="",c=0,d=a.length;d>c;c++)b+=" "+a[c].name+(m(a[c].value)?"":'="'+a[c].value+'"');return b}function D(a,b,c,d,e,f){var h,k,n=f.caseSensitive?a.name:a.name.toLowerCase(),o=f.preventAttributesEscaping?a.value:a.escaped,q=f.preventAttributesEscaping?a.quote:"'"===f.quoteCharacter?"'":'"',r=d&&e===b.length-1;return f.removeRedundantAttributes&&i(c,n,o,b)||f.removeScriptTypeAttributes&&j(c,n,o)||f.removeStyleLinkTypeAttributes&&l(c,n,o)?"":(o=p(c,n,o,f,b),k=void 0!==o&&!f.removeAttributeQuotes||!g(o)||r?q+o+q:o,f.removeEmptyAttributes&&y(c,n,o)?"":(h=void 0===o||f.collapseBooleanAttributes&&m(n,o)?n:n+a.customAssign+k," "+a.customOpen+h+a.customClose))}function E(a){for(var b=["canCollapseWhitespace","canTrimWhitespace"],c=0,d=b.length;d>c;c++)a[b[c]]||(a[b[c]]=function(){return!1})}function F(b,c){"object"!=typeof c&&(c={});try{var d=a.RelateUrl;return"undefined"==typeof d&&"function"==typeof require&&(d=require("relateurl")),d&&d.relate?d.relate(b,c):b}catch(e){K(e)}return b}function G(b,c){"object"!=typeof c&&(c={}),c.fromString=!0;var d=c.output||{};d.inline_script=!0,c.output=d;try{var e=a.UglifyJS;if("undefined"==typeof e&&"function"==typeof require&&(e=require("uglify-js")),!e)return b;if(e.minify)return e.minify(b,c).code;if(e.parse){var f=e.parse(b);f.figure_out_scope();var g=e.Compressor(),h=f.transform(g);h.figure_out_scope(),h.compute_char_frequency(),c.mangle!==!1&&h.mangle_names();var i=e.OutputStream(c.output);return h.print(i),i.toString()}return b}catch(j){K(j)}return b}function H(a,b,c){"object"!=typeof b&&(b={}),"undefined"==typeof b.advanced&&(b.advanced=!1);try{var d;if("undefined"!=typeof CleanCSS)d=new CleanCSS(b);else if("function"==typeof require){var e=require("clean-css");d=new e(b)}return c?s(d.minify(r(a)).styles):d.minify(a).styles}catch(f){K(f)}return a}function I(a,f){function g(a,b){return A(a)||f.canCollapseWhitespace(a,b)}function h(a,b){return B(a)||f.canTrimWhitespace(a,b)}f=f||{};var i=[];a=M(a),E(f);var j=[],l=[],m="",n="",o=[],p=[],q=[],r=f.lint,s=!1,y=new Date;f.removeIgnored&&(a=a.replace(/<\?[^\?]+\?>/g,"").replace(/<%[^%]+%>/g,"")),new L(a,{html5:"undefined"!=typeof f.html5?f.html5:!0,start:function(a,b,c,d){if(s)return void l.push("<"+a,C(b),d?"/":"",">");var e=a.toLowerCase();if("svg"===e){i.push(f);var j={};for(var k in f)j[k]=f[k];j.keepClosingSlash=!0,j.caseSensitive=!0,f=j}a=f.caseSensitive?a:e,n=a,m="",o=b,f.collapseWhitespace&&(h(a,b)||p.push(a),g(a,b)||q.push(a));var t="<"+a,u=(d&&f.keepClosingSlash?"/":"")+">";0===b.length&&(t+=u),l.push(t),r&&r.testElement(a);for(var v,w=0,x=b.length;x>w;w++)r&&r.testAttribute(a,b[w].name.toLowerCase(),b[w].escaped),v=D(b[w],b,a,d,w,f),w===x-1&&(v+=u),l.push(v)},end:function(a,b){if(s)return void l.push("</"+a+">");var c=a.toLowerCase();"svg"===c&&(f=i.pop()),f.collapseWhitespace&&(p.length&&a===p[p.length-1]&&p.pop(),q.length&&a===q[q.length-1]&&q.pop());var d=""===m&&a===n;if(f.removeEmptyElements&&d&&z(a,b)){for(var e=l.length-1;e>=0;e--)if(/^<[^\/!]/.test(l[e])){l.splice(e);break}}else f.removeOptionalTags&&x(a)||(l.push("</"+(f.caseSensitive?a:c)+">"),j.push.apply(j,l),l.length=0,m="")},chars:function(a,d,e){return d=""===d?"comment":d,e=""===e?"comment":e,s?void l.push(a):(("script"===n||"style"===n)&&(f.removeCommentsFromCDATA&&(a=w(a,n)),f.removeCDATASectionsFromCDATA&&(a=u(a)),f.processScripts&&(a=v(a,f,o))),f.minifyJS&&k(n,o)&&(a=G(a,f.minifyJS)),"style"===n&&f.minifyCSS&&(a=H(a,f.minifyCSS)),f.collapseWhitespace&&(p.length||(a=d&&"comment"!==d||e&&"comment"!==e?c(a,d,e,f):M(a)),q.length||(a=d&&e||"html"===e?a:b(a))),m=a,r&&r.testChars(a),void l.push(a))},comment:function(a,b){var c=b?"<!":"<!--",g=b?">":"-->";return/^\s*htmlmin:ignore/.test(a)?(s=!s,void(f.removeComments||l.push("<!--"+a+"-->"))):(a=f.removeComments?d(a)?c+t(a)+g:e(a,f)?"<!--"+a+"-->":"":c+a+g,void l.push(a))},doctype:function(a){l.push(f.useShortDoctype?"<!DOCTYPE html>":b(a))},customAttrAssign:f.customAttrAssign,customAttrSurround:f.customAttrSurround}),j.push.apply(j,l);var F=J(j,f);return K("minified in: "+(new Date-y)+"ms"),F}function J(a,b){var c,d=b.maxLineLength;if(d){for(var e,f=[],g="",h=0,i=a.length;i>h;h++)e=a[h],g.length+e.length<d?g+=e:(f.push(g.replace(/^\n/,"")),g=e);f.push(g),c=f.join("\n")}else c=a.join("");return c}var K,L;K=a.console&&a.console.log?function(b){a.console.log(b)}:function(){},a.HTMLParser?L=a.HTMLParser:"function"==typeof require&&(L=require("./htmlparser").HTMLParser);var M=function(a){return"string"!=typeof a?a:a.replace(/^\s+/,"").replace(/\s+$/,"")};String.prototype.trim&&(M=function(a){return"string"!=typeof a?a:a.trim()});var N={"text/javascript":1,"text/ecmascript":1,"text/jscript":1,"application/javascript":1,"application/x-javascript":1,"application/ecmascript":1},O={draggable:["true","false"]},P={script:/^\s*(?:\/\/)?\s*<!--.*\n?/,style:/^\s*<!--\s*/},Q={script:/\s*(?:\/\/)?\s*-->\s*$/,style:/\s*-->\s*$/},R=new RegExp("^(?:class|id|style|title|lang|dir|on(?:focus|blur|change|click|dblclick|mouse(?:down|up|over|move|out)|key(?:press|down|up)))$");"undefined"!=typeof exports?exports.minify=I:a.minify=I}("undefined"==typeof exports?this:exports),function(a){"use strict";function b(a){return/^(?:big|small|hr|blink|marquee)$/.test(a)}function c(a){return/^(?:applet|basefont|center|dir|font|isindex|strike)$/.test(a)}function d(a){return/^on[a-z]+/.test(a)}function e(a){return"style"===a.toLowerCase()}function f(a,b){return"align"===b&&/^(?:caption|applet|iframe|img|imput|object|legend|table|hr|div|h[1-6]|p)$/.test(a)||"alink"===b&&"body"===a||"alt"===b&&"applet"===a||"archive"===b&&"applet"===a||"background"===b&&"body"===a||"bgcolor"===b&&/^(?:table|t[rdh]|body)$/.test(a)||"border"===b&&/^(?:img|object)$/.test(a)||"clear"===b&&"br"===a||"code"===b&&"applet"===a||"codebase"===b&&"applet"===a||"color"===b&&/^(?:base(?:font)?)$/.test(a)||"compact"===b&&/^(?:dir|[dou]l|menu)$/.test(a)||"face"===b&&/^base(?:font)?$/.test(a)||"height"===b&&/^(?:t[dh]|applet)$/.test(a)||"hspace"===b&&/^(?:applet|img|object)$/.test(a)||"language"===b&&"script"===a||"link"===b&&"body"===a||"name"===b&&"applet"===a||"noshade"===b&&"hr"===a||"nowrap"===b&&/^t[dh]$/.test(a)||"object"===b&&"applet"===a||"prompt"===b&&"isindex"===a||"size"===b&&/^(?:hr|font|basefont)$/.test(a)||"start"===b&&"ol"===a||"text"===b&&"body"===a||"type"===b&&/^(?:li|ol|ul)$/.test(a)||"value"===b&&"li"===a||"version"===b&&"html"===a||"vlink"===b&&"body"===a||"vspace"===b&&/^(?:applet|img|object)$/.test(a)||"width"===b&&/^(?:hr|td|th|applet|pre)$/.test(a)}function g(a,b){return"href"===a&&/^\s*javascript\s*:\s*void\s*(\s+0|\(\s*0\s*\))\s*$/i.test(b)}function h(){this.log=[],this._lastElement=null,this._isElementRepeated=!1}h.prototype.testElement=function(a){c(a)?this.log.push('Found <span class="deprecated-element">deprecated</span> <strong><code><'+a+"></code></strong> element"):b(a)?this.log.push('Found <span class="presentational-element">presentational</span> <strong><code><'+a+"></code></strong> element"):this.checkRepeatingElement(a)},h.prototype.checkRepeatingElement=function(a){"br"===a&&"br"===this._lastElement?this._isElementRepeated=!0:this._isElementRepeated&&(this._reportRepeatingElement(),this._isElementRepeated=!1),this._lastElement=a},h.prototype._reportRepeatingElement=function(){this.log.push("Found <code><br></code> sequence. Try replacing it with styling.")},h.prototype.testAttribute=function(a,b,c){d(b)?this.log.push('Found <span class="event-attribute">event attribute</span> (<strong>'+b+"</strong>) on <strong><code><"+a+"></code></strong> element."):f(a,b)?this.log.push('Found <span class="deprecated-attribute">deprecated</span> <strong>'+b+"</strong> attribute on <strong><code><"+a+"></code></strong> element."):e(b)?this.log.push('Found <span class="style-attribute">style attribute</span> on <strong><code><'+a+"></code></strong> element."):g(b,c)&&this.log.push('Found <span class="inaccessible-attribute">inaccessible attribute</span> (on <strong><code><'+a+"></code></strong> element).")},h.prototype.testChars=function(a){this._lastElement="",/( \s*){2,}/.test(a)&&this.log.push("Found repeating <strong><code>&nbsp;</code></strong> sequence. Try replacing it with styling.")},h.prototype.test=function(a,b,c){this.testElement(a),this.testAttribute(a,b,c)},h.prototype.populate=function(a){if(this._isElementRepeated&&this._reportRepeatingElement(),this.log.length)if(a)a.innerHTML="<ol><li>"+this.log.join("<li>")+"</ol>";else{var b=" - "+this.log.join("\n - ").replace(/(<([^>]+)>)/gi,"").replace(/</g,"<").replace(/>/g,">");console.log(b)}},a.HTMLLint=h}("undefined"==typeof exports?this:exports);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-minifier",
|
|
3
3
|
"description": "HTML minifier with lint-like capabilities.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"html",
|
|
7
7
|
"minifier",
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
"Hugo Wetterberg <hugo@wetterberg.nu>",
|
|
18
18
|
"Zoltan Frombach <tssajo@gmail.com>"
|
|
19
19
|
],
|
|
20
|
-
"license":
|
|
21
|
-
|
|
22
|
-
"
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"bin": {
|
|
22
|
+
"html-minifier": "./cli.js"
|
|
23
23
|
},
|
|
24
|
-
"
|
|
24
|
+
"main": "src/htmlminifier.js",
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
|
27
|
-
"url": "https://github.com/kangax/html-minifier"
|
|
27
|
+
"url": "git+https://github.com/kangax/html-minifier.git"
|
|
28
28
|
},
|
|
29
29
|
"bugs": {
|
|
30
30
|
"url": "https://github.com/kangax/html-minifier/issues"
|
|
@@ -32,38 +32,37 @@
|
|
|
32
32
|
"engines": {
|
|
33
33
|
"node": ">=0.10.0"
|
|
34
34
|
},
|
|
35
|
-
"directories": {
|
|
36
|
-
"test": "tests"
|
|
37
|
-
},
|
|
38
35
|
"scripts": {
|
|
39
36
|
"test": "grunt test"
|
|
40
37
|
},
|
|
41
38
|
"dependencies": {
|
|
42
|
-
"change-case": "2.
|
|
43
|
-
"clean-css": "
|
|
44
|
-
"cli": "0.
|
|
45
|
-
"
|
|
46
|
-
"relateurl": "0.2.x"
|
|
39
|
+
"change-case": "2.3.x",
|
|
40
|
+
"clean-css": "3.4.x",
|
|
41
|
+
"cli": "0.10.x",
|
|
42
|
+
"concat-stream": "1.5.x",
|
|
43
|
+
"relateurl": "0.2.x",
|
|
44
|
+
"uglify-js": "2.4.x"
|
|
47
45
|
},
|
|
48
46
|
"devDependencies": {
|
|
47
|
+
"chalk": "1.1.x",
|
|
49
48
|
"cli-table": "0.3.x",
|
|
50
49
|
"grunt": "0.4.x",
|
|
51
50
|
"grunt-contrib-concat": "0.5.x",
|
|
52
|
-
"grunt-contrib-jshint": "0.
|
|
53
|
-
"grunt-contrib-qunit": "0.
|
|
54
|
-
"grunt-contrib-uglify": "0.
|
|
51
|
+
"grunt-contrib-jshint": "0.11.x",
|
|
52
|
+
"grunt-contrib-qunit": "0.7.x",
|
|
53
|
+
"grunt-contrib-uglify": "0.9.x",
|
|
55
54
|
"grunt-exec": "0.4.x",
|
|
56
|
-
"grunt-jscs": "
|
|
57
|
-
"load-grunt-tasks": "
|
|
55
|
+
"grunt-jscs": "2.1.x",
|
|
56
|
+
"load-grunt-tasks": "3.2.x",
|
|
58
57
|
"qunit": "0.7.x",
|
|
59
|
-
"time-grunt": "1.
|
|
58
|
+
"time-grunt": "1.2.x"
|
|
60
59
|
},
|
|
61
60
|
"files": [
|
|
62
61
|
"dist",
|
|
62
|
+
"src",
|
|
63
63
|
"cli.js",
|
|
64
64
|
"sample-cli-config-file.conf",
|
|
65
65
|
"CHANGELOG.md",
|
|
66
66
|
"LICENSE"
|
|
67
|
-
]
|
|
68
|
-
"main": "./dist/htmlminifier.js"
|
|
67
|
+
]
|
|
69
68
|
}
|