From 8217b9e5e9a110c130628d3cf2cd2a53cea56768 Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Wed, 2 Mar 2016 16:06:55 +0800 Subject: [PATCH 1/4] fix collapseWhitespace & removeEmptyElements trailing whitespace combined with start tag --- dist/htmlminifier.js | 31 +++++++++++++++++++------------ dist/htmlminifier.min.js | 2 +- src/htmlminifier.js | 31 +++++++++++++++++++------------ tests/minifier.js | 14 ++++++++++---- 4 files changed, 49 insertions(+), 29 deletions(-) diff --git a/dist/htmlminifier.js b/dist/htmlminifier.js index 53ac04c4..fc0e175b 100644 --- a/dist/htmlminifier.js +++ b/dist/htmlminifier.js @@ -1324,6 +1324,21 @@ buffer.length = Math.max(0, index); } + function squashTrailingWhitespace(nextTag) { + var charsIndex; + if (buffer.length > 1 && buffer[buffer.length - 1] === '' && /\s+$/.test(buffer[buffer.length - 2])) { + charsIndex = buffer.length - 2; + } + else if (buffer.length > 0 && /\s+$/.test(buffer[buffer.length - 1])) { + charsIndex = buffer.length - 1; + } + if (charsIndex > 0) { + buffer[charsIndex] = buffer[charsIndex].replace(/\s+$/, function(text) { + return collapseWhitespaceSmart(text, 'comment', nextTag, options); + }); + } + } + new HTMLParser(value, { partialMarkup: partialMarkup, html5: typeof options.html5 !== 'undefined' ? options.html5 : true, @@ -1376,6 +1391,9 @@ // set whitespace flags for nested tags (eg. within a
)
         if (options.collapseWhitespace) {
+          if (!stackNoTrimWhitespace.length) {
+            squashTrailingWhitespace(tag);
+          }
           if (!_canTrimWhitespace(tag, attrs)) {
             stackNoTrimWhitespace.push(tag);
           }
@@ -1431,18 +1449,7 @@
             }
           }
           else {
-            var charsIndex;
-            if (buffer.length > 1 && buffer[buffer.length - 1] === '' && /\s+$/.test(buffer[buffer.length - 2])) {
-              charsIndex = buffer.length - 2;
-            }
-            else if (buffer.length > 0 && /\s+$/.test(buffer[buffer.length - 1])) {
-              charsIndex = buffer.length - 1;
-            }
-            if (charsIndex > 0) {
-              buffer[charsIndex] = buffer[charsIndex].replace(/\s+$/, function(text) {
-                return collapseWhitespaceSmart(text, 'comment', '/' + tag, options);
-              });
-            }
+            squashTrailingWhitespace('/' + tag);
           }
           if (stackNoCollapseWhitespace.length &&
             tag === stackNoCollapseWhitespace[stackNoCollapseWhitespace.length - 1]) {
diff --git a/dist/htmlminifier.min.js b/dist/htmlminifier.min.js
index e1c24c7c..78485fa7 100644
--- a/dist/htmlminifier.min.js
+++ b/dist/htmlminifier.min.js
@@ -3,4 +3,4 @@
  * Copyright 2010-2016 Juriy "kangax" Zaytsev
  * Licensed under the MIT license
  */
-!function(a){"use strict";function b(a){var b,c=new RegExp("[\\w:\\.-]+(?:\\s*(?:"+d(a)+")\\s*(?:\"[^\"]*\"+?|'[^']*'+?|[^>\\s\"']+?))?");if(a.customAttrSurround){for(var e=[],f=a.customAttrSurround.length-1;f>=0;f--)e[f]="(?:"+a.customAttrSurround[f][0].source+"\\s*"+c.source+"\\s*"+a.customAttrSurround[f][1].source+")";e.unshift("(?:"+c.source+")"),b=new RegExp("((?:\\s*(?:"+e.join("|")+"))*)")}else b=new RegExp("((?:\\s*"+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+")\\s*"+b.source+"\\s*("+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\s]+)/.source],j=/^<([\w:-]+)/,k=/\s*(\/?)>/,l=/^<\/([\w:-]+)[^>]*>/,m=/\/>$/,n=/^]+>/i,o=!1;"x".replace(/x(.)?/g,function(a,b){o=""===b});var p=e("area,base,basefont,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),q=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"),r=e("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),s=e("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),t=e("script,style"),u={},v=a.HTMLParser=function(a,d){function e(a,b,c,e){for(var h=!1;!d.html5&&g&&q[g];)f("",g);r[b]&&g===b&&f("",b),e=p[b]||"html"===b&&"head"===g||!!e;var i=[];c.replace(w,function(){var a,b,c,e,f,g,h,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&&(h=arguments[0].charAt(a.length+g.length),h="'"===h||'"'===h?h:"");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=s[a]?a:c),i.push({name:a,value:b,customAssign:g||"=",customOpen:e||"",customClose:f||"",quote:h||""})}),e?h=a.match(m):(k.push({tag:b,attrs:i}),g=b),d.start&&d.start(b,i,e,h)}function f(a,b){var c;if(b){var e=b.toLowerCase();for(c=k.length-1;c>=0&&k[c].tag.toLowerCase()!==e;c--);}else c=0;if(c>=0){for(var f=k.length-1;f>=c;f--)d.end&&d.end(k[f].tag,k[f].attrs);k.length=c,g=c&&k[c-1].tag}}for(var g,h,i,j,k=[],v=b(d),w=c(d);a;){if(h=a,g&&t[g]){var x=g.toLowerCase(),y=u[x]||(u[x]=new RegExp("([\\s\\S]*?)]*>","i"));a=a.replace(y,function(a,b){return"script"!==x&&"style"!==x&&"noscript"!==x&&(b=b.replace(//g,"$1").replace(//g,"$1")),d.chars&&d.chars(b),""}),f("",x)}else{var z=a.indexOf("<");if(0===z){if(/^");if(A>=0){d.comment&&d.comment(a.substring(4,A)),a=a.substring(A+3),i="";continue}}if(/^");if(B>=0){d.comment&&d.comment(a.substring(2,B+1),!0),a=a.substring(B+2),i="";continue}}var C=a.match(n);if(C){d.doctype&&d.doctype(C[0]),a=a.substring(C[0].length),i="";continue}var D=a.match(l);if(D){a=a.substring(D[0].length),D[0].replace(l,f),i="/"+D[1].toLowerCase();continue}var E=a.match(v);if(E){a=a.substring(E[0].length),E[0].replace(v,e),i=E[1].toLowerCase();continue}}var F;z>=0?(F=a.substring(0,z),a=a.substring(z)):(F=a,a="");var G=a.match(v);G?j=G[1]:(G=a.match(l),j=G?"/"+G[1]:""),d.chars&&d.chars(F,i,j),i=""}if(a===h)throw"Parse Error: "+a}d.partialMarkup||f()};a.HTMLtoXML=function(a){var b="";return new v(a,{start:function(a,c,d){b+="<"+a;for(var e=0;e"},end:function(a){b+=""},chars:function(a){b+=a},comment:function(a){b+=""},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 v(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){var b={};return a.forEach(function(a){b[a]=1}),function(a){return 1===b[a]}}function d(a){return c(a.split(/,/))}function e(a,c,d,e,f){var g="",h="";return c.preserveLineBreaks&&(a=a.replace(/^[\t ]*[\n\r][\t\n\r ]*/,function(){return g="\n",""}).replace(/[\t\n\r ]*[\n\r][\t ]*$/,function(){return h="\n",""})),d&&(a=a.replace(/^\s+/,!g&&c.conservativeCollapse?" ":"")),e&&(a=a.replace(/\s+$/,!h&&c.conservativeCollapse?" ":"")),f&&(a=b(a)),g+a+h}function f(a,b,c,d){var f=b&&!V(b);f&&!d.collapseInlineTagWhitespace&&(f="/"===b.charAt(0)?!T(b.slice(1)):!U(b));var g=c&&!V(c);return g&&!d.collapseInlineTagWhitespace&&(g="/"===c.charAt(0)?!U(c.slice(1)):!T(c)),e(a,d,f,g,b&&c)}function g(a){return/^\[if\s[^\]]+\]|\[endif\]$/.test(a)}function h(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 i(a,b){var c=b.customEventAttributes;if(c){for(var d=c.length;d--;)if(c[d].test(a))return!0;return!1}return/^on[a-z]{3,}$/.test(a)}function j(a){return/^[^\x20\t\n\f\r"'`=<>]+$/.test(a)}function k(a,b){for(var c=a.length;c--;)if(a[c].name.toLowerCase()===b)return!0;return!1}function l(a,b,c,d){return c=c?S(c.toLowerCase()):"","script"===a&&"language"===b&&"javascript"===c||"form"===a&&"method"===b&&"get"===c||"input"===a&&"type"===b&&"text"===c||"script"===a&&"charset"===b&&!k(d,"src")||"a"===a&&"name"===b&&k(d,"id")||"area"===a&&"shape"===b&&"rect"===c}function m(a,b,c){return"script"===a&&"type"===b&&"text/javascript"===S(c.toLowerCase())}function n(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){var f=S(b[c].value).split(/;/,2)[0].toLowerCase();return""===f||W(f)}}return!0}function o(a,b,c){return("style"===a||"link"===a)&&"type"===b&&"text/css"===S(c.toLowerCase())}function p(a,b){return X(a)||"draggable"===a&&!Y(b)}function q(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 r(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 s(a,b){if("link"!==a)return!1;for(var c=0,d=b.length;d>c;c++)if("rel"===b[c].name&&"canonical"===b[c].value)return!0}function t(a,c,d,e,f){if(d&&i(c,e)){if(d=S(d).replace(/^javascript:\s*/i,"").replace(/\s*;$/,""),e.minifyJS){var g=L(Z+d+$,e.minifyJS);return g.slice(Z.length,-$.length)}return d}return"class"===c?b(S(d)):q(c,a)?(d=S(d),e.minifyURLs&&!s(a,f)?K(d,e.minifyURLs):d):r(c,a)?S(d):"style"===c?(d=S(d),d&&(d=d.replace(/\s*;\s*$/,"")),e.minifyCSS?M(d,e.minifyCSS,!0):d):(u(a,f)&&"content"===c?d=d.replace(/\s+/g,"").replace(/[0-9]+\.[0-9]+/g,function(a){return(+a).toString()}):d&&e.customAttrCollapse&&e.customAttrCollapse.test(c)&&(d=d.replace(/\n+|\r+|\s{2,}/g,"")),d)}function u(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 v(a){return"*{"+a+"}"}function w(a){var b=a.match(/^\*\{([\s\S]*)\}$/m);return b&&b[1]?b[1]:a}function x(a,b){return a.replace(/^(\[if\s[^\]]+\]>)([\s\S]*?)(\s*\*\/|\/\/\s*\]\]>)\s*$/,"")}function z(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 O(a,b);return a}function A(a,b){return a.replace(_[b],"").replace(aa[b],"")}function B(a,b){switch(a){case"html":case"head":return!0;case"body":return!da(b);case"colgroup":return"col"===b;case"tbody":return"tr"===b}return!1}function C(a,b){switch(b){case"colgroup":return"colgroup"===a;case"tbody":return la(a)}return!1}function D(a,b){switch(a){case"html":case"head":case"body":case"colgroup":case"caption":return!0;case"li":case"optgroup":case"tr":return b===a;case"dt":case"dd":return ea(b);case"p":return fa(b);case"rb":case"rt":case"rp":return ha(b);case"rtc":return ia(b);case"option":return ja(b);case"thead":case"tbody":return ka(b);case"tfoot":return"tbody"===b;case"td":case"th":return ma(b)}return!1}function E(a,b,c){var d=!c||/^\s*$/.test(c);return d?"input"===a&&"value"===b||sa.test(b):!1}function F(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 G(a){return!/^(?:script|style|pre|textarea)$/.test(a)}function H(a){return!/^(?:pre|textarea)$/.test(a)}function I(a,b,c,d,e,f,g){var h,i,k=f.caseSensitive?a.name:a.name.toLowerCase(),n=a.value,q=a.quote;if(f.removeRedundantAttributes&&l(c,k,n,b)||f.removeScriptTypeAttributes&&m(c,k,n)||f.removeStyleLinkTypeAttributes&&o(c,k,n))return"";if(n=t(c,k,n,f,b),f.removeEmptyAttributes&&E(c,k,n))return"";if(void 0!==n&&!f.removeAttributeQuotes||!j(n)){if(!f.preventAttributesEscaping){if(void 0!==f.quoteCharacter)q="'"===f.quoteCharacter?"'":'"';else{var r=(n.match(/'/g)||[]).length,s=(n.match(/"/g)||[]).length;q=s>r?"'":'"'}n='"'===q?n.replace(/"/g,"""):n.replace(/'/g,"'")}i=q+n+q,g||f.removeTagWhitespace||(i+=" ")}else i=!g||d||/\/$/.test(n)?n+" ":n;return void 0===n||f.collapseBooleanAttributes&&p(k.toLowerCase(),n.toLowerCase())?(h=k,g||(h+=" ")):h=k+a.customAssign+i,a.customOpen+h+a.customClose}function J(a){for(var b=["canCollapseWhitespace","canTrimWhitespace"],c=0,d=b.length;d>c;c++)a[b[c]]||(a[b[c]]=function(){return!1})}function K(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){Q(e)}return b}function L(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){Q(j)}return b}function M(b,c,d){"object"!=typeof c&&(c={}),"undefined"==typeof c.advanced&&(c.advanced=!1);try{var e=a.CleanCSS;"undefined"==typeof e&&"function"==typeof require&&(e=require("clean-css"));var f=new e(c);return d?w(f.minify(v(b)).styles):f.minify(b).styles}catch(g){Q(g)}return b}function N(a){var b;do b=Math.random().toString(36).slice(2);while(~a.indexOf(b));return b}function O(a,c,d){function i(a,b){return G(a)||c.canCollapseWhitespace(a,b)}function j(a,b){return H(a)||c.canTrimWhitespace(a,b)}function k(){for(var a=s.length-1;a>0&&!/^<[^\/!]/.test(s[a]);)a--;s.length=Math.max(0,a)}function l(){for(var a=s.length-1;a>0&&!/^<\//.test(s[a]);)a--;s.length=Math.max(0,a)}c=c||{};var m=[];J(c),a=c.collapseWhitespace?S(a):a;var o,p,q,r,s=[],t="",u="",v=[],w=[],E=[],K="",O="",T=c.lint,V=Date.now(),W=[],X=[];a=a.replace(/([\s\S]*?)/g,function(b,c){q||(q="");var d=q+W.length;return W.push(c),d});var Y=(c.ignoreCustomFragments||[/<%[\s\S]*?%>/,/<\?[\s\S]*?\?>/]).map(function(a){return a.source});if(Y.length){var Z=new RegExp("\\s*(?:"+Y.join("|")+")+\\s*","g");a=a.replace(Z,function(b){r||(r=N(a));var c=r+X.length;return X.push(b),"	"+c+"	"})}new R(a,{partialMarkup:d,html5:"undefined"!=typeof c.html5?c.html5:!0,start:function(a,b,d,e){var f=a.toLowerCase();if("svg"===f){m.push(c);var g={};for(var h in c)g[h]=c[h];g.keepClosingSlash=!0,g.caseSensitive=!0,c=g}a=c.caseSensitive?a:f,u=a,o=a,U(a)||(t=""),p=!1,v=b;var n=c.removeOptionalTags;if(n){var q=ra(a);q&&B(K,a)&&k(),K="",q&&D(O,a)&&(l(),n=!C(O,a)),O=""}c.collapseWhitespace&&(j(a,b)||w.push(a),i(a,b)||E.push(a));var r="<"+a,x=e&&c.keepClosingSlash;s.push(r),T&&T.testElement(a);for(var y,z=[],A=!0,F=b.length;--F>=0;)T&&T.testAttribute(a,b[F].name.toLowerCase(),b[F].value),y=I(b[F],b,a,x,F,c,A),y&&(A=!1,z.unshift(y));z.length>0?(s.push(" "),s.push.apply(s,z)):n&&ba(a)&&(K=a),s.push(s.pop()+(x?"/":"")+">")},end:function(a,b){var d=a.toLowerCase();if("svg"===d&&(c=m.pop()),a=c.caseSensitive?a:d,c.collapseWhitespace){if(w.length)a===w[w.length-1]&&w.pop();else{var e;s.length>1&&""===s[s.length-1]&&/\s+$/.test(s[s.length-2])?e=s.length-2:s.length>0&&/\s+$/.test(s[s.length-1])&&(e=s.length-1),e>0&&(s[e]=s[e].replace(/\s+$/,function(b){return f(b,"comment","/"+a,c)}))}E.length&&a===E[E.length-1]&&E.pop()}var g=!1;a===u&&(u="",g=!p),c.removeOptionalTags&&(g&&na(K)&&k(),K="",!ra(a)||!O||qa(O)||"p"===O&&ga(a)||l(),O=ca(a)?a:""),c.removeEmptyElements&&g&&F(a,b)?(k(),K="",O=""):(s.push(""),o="/"+a,U(a)||(t=""))},chars:function(a,d,g){if(d=""===d?"comment":d,g=""===g?"comment":g,c.collapseWhitespace){if(!w.length){if("comment"===d){var h=""===s[s.length-1];if(h&&(d=o),s.length>1&&(h||/ $/.test(t))){var i=s.length-2;s[i]=s[i].replace(/\s+$/,function(b){return a=b+a,""})}}if(d&&U("/"===d.charAt(0)?d.slice(1):d)&&(a=e(a,c,/(?:^|\s)$/.test(t))),a=d||g?f(a,d,g,c):S(a),!a&&/\s$/.test(t)&&d&&"/"===d.charAt(0))for(var m=s.length-2,q=d.slice(1);m>=0&&j(q);m--){var r=s[m],x=r.match(/^<\/([\w:-]+)>$/);if(x)q=x[1];else if(/>$/.test(r)||(s[m]=f(r,null,g,c)))break}}E.length||(a=d&&g||"html"===g?a:b(a))}"script"!==u&&"style"!==u||(c.removeCommentsFromCDATA&&(a=A(a,u)),c.removeCDATASectionsFromCDATA&&(a=y(a)),c.processScripts&&(a=z(a,c,v))),c.minifyJS&&n(u,v)&&(a=L(a,c.minifyJS),";"===a.charAt(a.length-1)&&(a=a.slice(0,-1))),"style"===u&&c.minifyCSS&&(a=M(a,c.minifyCSS)),c.removeOptionalTags&&a&&(("html"===K||"body"===K&&!/^\s/.test(a))&&k(),K="",(oa(O)||pa(O)&&!/^\s/.test(a))&&l(),O=""),o=/^\s*$/.test(a)?d:"comment",t+=a,a&&(p=!0),T&&T.testChars(a),s.push(a)},comment:function(a,b){var d=b?"":"-->";a=g(a)?d+x(a,c)+e:c.removeComments?h(a,c)?"":"":d+a+e,c.removeOptionalTags&&a&&(K="",O=""),s.push(a)},doctype:function(a){s.push(c.useShortDoctype?"":b(a))},customAttrAssign:c.customAttrAssign,customAttrSurround:c.customAttrSurround}),c.removeOptionalTags&&(na(K)&&k(),O&&!qa(O)&&l());var $=P(s,c);return r&&($=$.replace(new RegExp("(\\s*)"+r+"([0-9]+)(\\s*)","g"),function(a,b,d,f){var g=X[+d];return c.collapseWhitespace?("	"!==b&&(g=b+g),"	"!==f&&(g+=f),e(g,{preserveLineBreaks:c.preserveLineBreaks,conservativeCollapse:!0},/^\s/.test(g),/\s$/.test(g))):g})),q&&($=$.replace(new RegExp(q+"([0-9]+)","g"),function(a,b){return W[+b]})),Q("minified in: "+(Date.now()-V)+"ms"),$}function P(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\s*$/,style:/\s*-->\s*$/},ba=d("html,head,body,colgroup,tbody"),ca=d("html,head,body,li,dt,dd,p,rb,rt,rtc,rp,optgroup,option,colgroup,caption,thead,tbody,tfoot,tr,td,th"),da=d("meta,link,script,style,template,noscript"),ea=d("dt,dd"),fa=d("address,article,aside,blockquote,details,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,main,menu,nav,ol,p,pre,section,table,ul"),ga=d("a,audio,del,ins,map,noscript,video"),ha=d("rb,rt,rtc,rp"),ia=d("rb,rtc,rp"),ja=d("option,optgroup"),ka=d("tbody,tfoot"),la=d("thead,tbody,tfoot"),ma=d("td,th"),na=d("html,head,body"),oa=d("html,body"),pa=d("head,colgroup,caption"),qa=d("dt,thead"),ra=d("a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,element,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,menu,menuitem,meta,meter,multicol,nav,nobr,noembed,noframes,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,pre,progress,q,rp,rt,rtc,ruby,s,samp,script,section,select,shadow,small,source,spacer,span,strike,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,xmp"),sa=new RegExp("^(?:class|id|style|title|lang|dir|on(?:focus|blur|change|click|dblclick|mouse(?:down|up|over|move|out)|key(?:press|down|up)))$");a.minify=function(a,b){return O(a,b)}}("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 deprecated <'+a+"> element"):b(a)?this.log.push('Found presentational <'+a+"> 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 <br> sequence. Try replacing it with styling.")},h.prototype.testAttribute=function(a,b,c){d(b)?this.log.push('Found event attribute ('+b+") on <"+a+"> element."):f(a,b)?this.log.push('Found deprecated '+b+" attribute on <"+a+"> element."):e(b)?this.log.push('Found style attribute on <'+a+"> element."):g(b,c)&&this.log.push('Found inaccessible attribute (on <'+a+"> element).")},h.prototype.testChars=function(a){this._lastElement="",/( \s*){2,}/.test(a)&&this.log.push("Found repeating &nbsp; 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="
  1. "+this.log.join("
  2. ")+"
";else{var b=" - "+this.log.join("\n - ").replace(/(<([^>]+)>)/gi,"").replace(/</g,"<").replace(/>/g,">");console.log(b)}},a.HTMLLint=h}("undefined"==typeof exports?this:exports); \ No newline at end of file +!function(a){"use strict";function b(a){var b,c=new RegExp("[\\w:\\.-]+(?:\\s*(?:"+d(a)+")\\s*(?:\"[^\"]*\"+?|'[^']*'+?|[^>\\s\"']+?))?");if(a.customAttrSurround){for(var e=[],f=a.customAttrSurround.length-1;f>=0;f--)e[f]="(?:"+a.customAttrSurround[f][0].source+"\\s*"+c.source+"\\s*"+a.customAttrSurround[f][1].source+")";e.unshift("(?:"+c.source+")"),b=new RegExp("((?:\\s*(?:"+e.join("|")+"))*)")}else b=new RegExp("((?:\\s*"+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+")\\s*"+b.source+"\\s*("+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\s]+)/.source],j=/^<([\w:-]+)/,k=/\s*(\/?)>/,l=/^<\/([\w:-]+)[^>]*>/,m=/\/>$/,n=/^]+>/i,o=!1;"x".replace(/x(.)?/g,function(a,b){o=""===b});var p=e("area,base,basefont,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),q=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"),r=e("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),s=e("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),t=e("script,style"),u={},v=a.HTMLParser=function(a,d){function e(a,b,c,e){for(var h=!1;!d.html5&&g&&q[g];)f("",g);r[b]&&g===b&&f("",b),e=p[b]||"html"===b&&"head"===g||!!e;var i=[];c.replace(w,function(){var a,b,c,e,f,g,h,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&&(h=arguments[0].charAt(a.length+g.length),h="'"===h||'"'===h?h:"");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=s[a]?a:c),i.push({name:a,value:b,customAssign:g||"=",customOpen:e||"",customClose:f||"",quote:h||""})}),e?h=a.match(m):(k.push({tag:b,attrs:i}),g=b),d.start&&d.start(b,i,e,h)}function f(a,b){var c;if(b){var e=b.toLowerCase();for(c=k.length-1;c>=0&&k[c].tag.toLowerCase()!==e;c--);}else c=0;if(c>=0){for(var f=k.length-1;f>=c;f--)d.end&&d.end(k[f].tag,k[f].attrs);k.length=c,g=c&&k[c-1].tag}}for(var g,h,i,j,k=[],v=b(d),w=c(d);a;){if(h=a,g&&t[g]){var x=g.toLowerCase(),y=u[x]||(u[x]=new RegExp("([\\s\\S]*?)]*>","i"));a=a.replace(y,function(a,b){return"script"!==x&&"style"!==x&&"noscript"!==x&&(b=b.replace(//g,"$1").replace(//g,"$1")),d.chars&&d.chars(b),""}),f("",x)}else{var z=a.indexOf("<");if(0===z){if(/^");if(A>=0){d.comment&&d.comment(a.substring(4,A)),a=a.substring(A+3),i="";continue}}if(/^");if(B>=0){d.comment&&d.comment(a.substring(2,B+1),!0),a=a.substring(B+2),i="";continue}}var C=a.match(n);if(C){d.doctype&&d.doctype(C[0]),a=a.substring(C[0].length),i="";continue}var D=a.match(l);if(D){a=a.substring(D[0].length),D[0].replace(l,f),i="/"+D[1].toLowerCase();continue}var E=a.match(v);if(E){a=a.substring(E[0].length),E[0].replace(v,e),i=E[1].toLowerCase();continue}}var F;z>=0?(F=a.substring(0,z),a=a.substring(z)):(F=a,a="");var G=a.match(v);G?j=G[1]:(G=a.match(l),j=G?"/"+G[1]:""),d.chars&&d.chars(F,i,j),i=""}if(a===h)throw"Parse Error: "+a}d.partialMarkup||f()};a.HTMLtoXML=function(a){var b="";return new v(a,{start:function(a,c,d){b+="<"+a;for(var e=0;e"},end:function(a){b+=""},chars:function(a){b+=a},comment:function(a){b+=""},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 v(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){var b={};return a.forEach(function(a){b[a]=1}),function(a){return 1===b[a]}}function d(a){return c(a.split(/,/))}function e(a,c,d,e,f){var g="",h="";return c.preserveLineBreaks&&(a=a.replace(/^[\t ]*[\n\r][\t\n\r ]*/,function(){return g="\n",""}).replace(/[\t\n\r ]*[\n\r][\t ]*$/,function(){return h="\n",""})),d&&(a=a.replace(/^\s+/,!g&&c.conservativeCollapse?" ":"")),e&&(a=a.replace(/\s+$/,!h&&c.conservativeCollapse?" ":"")),f&&(a=b(a)),g+a+h}function f(a,b,c,d){var f=b&&!V(b);f&&!d.collapseInlineTagWhitespace&&(f="/"===b.charAt(0)?!T(b.slice(1)):!U(b));var g=c&&!V(c);return g&&!d.collapseInlineTagWhitespace&&(g="/"===c.charAt(0)?!U(c.slice(1)):!T(c)),e(a,d,f,g,b&&c)}function g(a){return/^\[if\s[^\]]+\]|\[endif\]$/.test(a)}function h(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 i(a,b){var c=b.customEventAttributes;if(c){for(var d=c.length;d--;)if(c[d].test(a))return!0;return!1}return/^on[a-z]{3,}$/.test(a)}function j(a){return/^[^\x20\t\n\f\r"'`=<>]+$/.test(a)}function k(a,b){for(var c=a.length;c--;)if(a[c].name.toLowerCase()===b)return!0;return!1}function l(a,b,c,d){return c=c?S(c.toLowerCase()):"","script"===a&&"language"===b&&"javascript"===c||"form"===a&&"method"===b&&"get"===c||"input"===a&&"type"===b&&"text"===c||"script"===a&&"charset"===b&&!k(d,"src")||"a"===a&&"name"===b&&k(d,"id")||"area"===a&&"shape"===b&&"rect"===c}function m(a,b,c){return"script"===a&&"type"===b&&"text/javascript"===S(c.toLowerCase())}function n(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){var f=S(b[c].value).split(/;/,2)[0].toLowerCase();return""===f||W(f)}}return!0}function o(a,b,c){return("style"===a||"link"===a)&&"type"===b&&"text/css"===S(c.toLowerCase())}function p(a,b){return X(a)||"draggable"===a&&!Y(b)}function q(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 r(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 s(a,b){if("link"!==a)return!1;for(var c=0,d=b.length;d>c;c++)if("rel"===b[c].name&&"canonical"===b[c].value)return!0}function t(a,c,d,e,f){if(d&&i(c,e)){if(d=S(d).replace(/^javascript:\s*/i,"").replace(/\s*;$/,""),e.minifyJS){var g=L(Z+d+$,e.minifyJS);return g.slice(Z.length,-$.length)}return d}return"class"===c?b(S(d)):q(c,a)?(d=S(d),e.minifyURLs&&!s(a,f)?K(d,e.minifyURLs):d):r(c,a)?S(d):"style"===c?(d=S(d),d&&(d=d.replace(/\s*;\s*$/,"")),e.minifyCSS?M(d,e.minifyCSS,!0):d):(u(a,f)&&"content"===c?d=d.replace(/\s+/g,"").replace(/[0-9]+\.[0-9]+/g,function(a){return(+a).toString()}):d&&e.customAttrCollapse&&e.customAttrCollapse.test(c)&&(d=d.replace(/\n+|\r+|\s{2,}/g,"")),d)}function u(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 v(a){return"*{"+a+"}"}function w(a){var b=a.match(/^\*\{([\s\S]*)\}$/m);return b&&b[1]?b[1]:a}function x(a,b){return a.replace(/^(\[if\s[^\]]+\]>)([\s\S]*?)(\s*\*\/|\/\/\s*\]\]>)\s*$/,"")}function z(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 O(a,b);return a}function A(a,b){return a.replace(_[b],"").replace(aa[b],"")}function B(a,b){switch(a){case"html":case"head":return!0;case"body":return!da(b);case"colgroup":return"col"===b;case"tbody":return"tr"===b}return!1}function C(a,b){switch(b){case"colgroup":return"colgroup"===a;case"tbody":return la(a)}return!1}function D(a,b){switch(a){case"html":case"head":case"body":case"colgroup":case"caption":return!0;case"li":case"optgroup":case"tr":return b===a;case"dt":case"dd":return ea(b);case"p":return fa(b);case"rb":case"rt":case"rp":return ha(b);case"rtc":return ia(b);case"option":return ja(b);case"thead":case"tbody":return ka(b);case"tfoot":return"tbody"===b;case"td":case"th":return ma(b)}return!1}function E(a,b,c){var d=!c||/^\s*$/.test(c);return d?"input"===a&&"value"===b||sa.test(b):!1}function F(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 G(a){return!/^(?:script|style|pre|textarea)$/.test(a)}function H(a){return!/^(?:pre|textarea)$/.test(a)}function I(a,b,c,d,e,f,g){var h,i,k=f.caseSensitive?a.name:a.name.toLowerCase(),n=a.value,q=a.quote;if(f.removeRedundantAttributes&&l(c,k,n,b)||f.removeScriptTypeAttributes&&m(c,k,n)||f.removeStyleLinkTypeAttributes&&o(c,k,n))return"";if(n=t(c,k,n,f,b),f.removeEmptyAttributes&&E(c,k,n))return"";if(void 0!==n&&!f.removeAttributeQuotes||!j(n)){if(!f.preventAttributesEscaping){if(void 0!==f.quoteCharacter)q="'"===f.quoteCharacter?"'":'"';else{var r=(n.match(/'/g)||[]).length,s=(n.match(/"/g)||[]).length;q=s>r?"'":'"'}n='"'===q?n.replace(/"/g,"""):n.replace(/'/g,"'")}i=q+n+q,g||f.removeTagWhitespace||(i+=" ")}else i=!g||d||/\/$/.test(n)?n+" ":n;return void 0===n||f.collapseBooleanAttributes&&p(k.toLowerCase(),n.toLowerCase())?(h=k,g||(h+=" ")):h=k+a.customAssign+i,a.customOpen+h+a.customClose}function J(a){for(var b=["canCollapseWhitespace","canTrimWhitespace"],c=0,d=b.length;d>c;c++)a[b[c]]||(a[b[c]]=function(){return!1})}function K(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){Q(e)}return b}function L(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){Q(j)}return b}function M(b,c,d){"object"!=typeof c&&(c={}),"undefined"==typeof c.advanced&&(c.advanced=!1);try{var e=a.CleanCSS;"undefined"==typeof e&&"function"==typeof require&&(e=require("clean-css"));var f=new e(c);return d?w(f.minify(v(b)).styles):f.minify(b).styles}catch(g){Q(g)}return b}function N(a){var b;do b=Math.random().toString(36).slice(2);while(~a.indexOf(b));return b}function O(a,c,d){function i(a,b){return G(a)||c.canCollapseWhitespace(a,b)}function j(a,b){return H(a)||c.canTrimWhitespace(a,b)}function k(){for(var a=t.length-1;a>0&&!/^<[^\/!]/.test(t[a]);)a--;t.length=Math.max(0,a)}function l(){for(var a=t.length-1;a>0&&!/^<\//.test(t[a]);)a--;t.length=Math.max(0,a)}function m(a){var b;t.length>1&&""===t[t.length-1]&&/\s+$/.test(t[t.length-2])?b=t.length-2:t.length>0&&/\s+$/.test(t[t.length-1])&&(b=t.length-1),b>0&&(t[b]=t[b].replace(/\s+$/,function(b){return f(b,"comment",a,c)}))}c=c||{};var o=[];J(c),a=c.collapseWhitespace?S(a):a;var p,q,r,s,t=[],u="",v="",w=[],E=[],K=[],O="",T="",V=c.lint,W=Date.now(),X=[],Y=[];a=a.replace(/([\s\S]*?)/g,function(b,c){r||(r="");var d=r+X.length;return X.push(c),d});var Z=(c.ignoreCustomFragments||[/<%[\s\S]*?%>/,/<\?[\s\S]*?\?>/]).map(function(a){return a.source});if(Z.length){var $=new RegExp("\\s*(?:"+Z.join("|")+")+\\s*","g");a=a.replace($,function(b){s||(s=N(a));var c=s+Y.length;return Y.push(b)," "+c+" "})}new R(a,{partialMarkup:d,html5:"undefined"!=typeof c.html5?c.html5:!0,start:function(a,b,d,e){var f=a.toLowerCase();if("svg"===f){o.push(c);var g={};for(var h in c)g[h]=c[h];g.keepClosingSlash=!0,g.caseSensitive=!0,c=g}a=c.caseSensitive?a:f,v=a,p=a,U(a)||(u=""),q=!1,w=b;var n=c.removeOptionalTags;if(n){var r=ra(a);r&&B(O,a)&&k(),O="",r&&D(T,a)&&(l(),n=!C(T,a)),T=""}c.collapseWhitespace&&(E.length||m(a),j(a,b)||E.push(a),i(a,b)||K.push(a));var s="<"+a,x=e&&c.keepClosingSlash;t.push(s),V&&V.testElement(a);for(var y,z=[],A=!0,F=b.length;--F>=0;)V&&V.testAttribute(a,b[F].name.toLowerCase(),b[F].value),y=I(b[F],b,a,x,F,c,A),y&&(A=!1,z.unshift(y));z.length>0?(t.push(" "),t.push.apply(t,z)):n&&ba(a)&&(O=a),t.push(t.pop()+(x?"/":"")+">")},end:function(a,b){var d=a.toLowerCase();"svg"===d&&(c=o.pop()),a=c.caseSensitive?a:d,c.collapseWhitespace&&(E.length?a===E[E.length-1]&&E.pop():m("/"+a),K.length&&a===K[K.length-1]&&K.pop());var e=!1;a===v&&(v="",e=!q),c.removeOptionalTags&&(e&&na(O)&&k(),O="",!ra(a)||!T||qa(T)||"p"===T&&ga(a)||l(),T=ca(a)?a:""),c.removeEmptyElements&&e&&F(a,b)?(k(),O="",T=""):(t.push(""),p="/"+a,U(a)||(u=""))},chars:function(a,d,g){if(d=""===d?"comment":d,g=""===g?"comment":g,c.collapseWhitespace){if(!E.length){if("comment"===d){var h=""===t[t.length-1];if(h&&(d=p),t.length>1&&(h||/ $/.test(u))){var i=t.length-2;t[i]=t[i].replace(/\s+$/,function(b){return a=b+a,""})}}if(d&&U("/"===d.charAt(0)?d.slice(1):d)&&(a=e(a,c,/(?:^|\s)$/.test(u))),a=d||g?f(a,d,g,c):S(a),!a&&/\s$/.test(u)&&d&&"/"===d.charAt(0))for(var m=t.length-2,o=d.slice(1);m>=0&&j(o);m--){var r=t[m],s=r.match(/^<\/([\w:-]+)>$/);if(s)o=s[1];else if(/>$/.test(r)||(t[m]=f(r,null,g,c)))break}}K.length||(a=d&&g||"html"===g?a:b(a))}"script"!==v&&"style"!==v||(c.removeCommentsFromCDATA&&(a=A(a,v)),c.removeCDATASectionsFromCDATA&&(a=y(a)),c.processScripts&&(a=z(a,c,w))),c.minifyJS&&n(v,w)&&(a=L(a,c.minifyJS),";"===a.charAt(a.length-1)&&(a=a.slice(0,-1))),"style"===v&&c.minifyCSS&&(a=M(a,c.minifyCSS)),c.removeOptionalTags&&a&&(("html"===O||"body"===O&&!/^\s/.test(a))&&k(),O="",(oa(T)||pa(T)&&!/^\s/.test(a))&&l(),T=""),p=/^\s*$/.test(a)?d:"comment",u+=a,a&&(q=!0),V&&V.testChars(a),t.push(a)},comment:function(a,b){var d=b?"":"-->";a=g(a)?d+x(a,c)+e:c.removeComments?h(a,c)?"":"":d+a+e,c.removeOptionalTags&&a&&(O="",T=""),t.push(a)},doctype:function(a){t.push(c.useShortDoctype?"":b(a))},customAttrAssign:c.customAttrAssign,customAttrSurround:c.customAttrSurround}),c.removeOptionalTags&&(na(O)&&k(),T&&!qa(T)&&l());var _=P(t,c);return s&&(_=_.replace(new RegExp("(\\s*)"+s+"([0-9]+)(\\s*)","g"),function(a,b,d,f){var g=Y[+d];return c.collapseWhitespace?(" "!==b&&(g=b+g)," "!==f&&(g+=f),e(g,{preserveLineBreaks:c.preserveLineBreaks,conservativeCollapse:!0},/^\s/.test(g),/\s$/.test(g))):g})),r&&(_=_.replace(new RegExp(r+"([0-9]+)","g"),function(a,b){return X[+b]})),Q("minified in: "+(Date.now()-W)+"ms"),_}function P(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\s*$/,style:/\s*-->\s*$/},ba=d("html,head,body,colgroup,tbody"),ca=d("html,head,body,li,dt,dd,p,rb,rt,rtc,rp,optgroup,option,colgroup,caption,thead,tbody,tfoot,tr,td,th"),da=d("meta,link,script,style,template,noscript"),ea=d("dt,dd"),fa=d("address,article,aside,blockquote,details,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,main,menu,nav,ol,p,pre,section,table,ul"),ga=d("a,audio,del,ins,map,noscript,video"),ha=d("rb,rt,rtc,rp"),ia=d("rb,rtc,rp"),ja=d("option,optgroup"),ka=d("tbody,tfoot"),la=d("thead,tbody,tfoot"),ma=d("td,th"),na=d("html,head,body"),oa=d("html,body"),pa=d("head,colgroup,caption"),qa=d("dt,thead"),ra=d("a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,element,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,menu,menuitem,meta,meter,multicol,nav,nobr,noembed,noframes,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,pre,progress,q,rp,rt,rtc,ruby,s,samp,script,section,select,shadow,small,source,spacer,span,strike,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,xmp"),sa=new RegExp("^(?:class|id|style|title|lang|dir|on(?:focus|blur|change|click|dblclick|mouse(?:down|up|over|move|out)|key(?:press|down|up)))$");a.minify=function(a,b){return O(a,b)}}("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 deprecated <'+a+"> element"):b(a)?this.log.push('Found presentational <'+a+"> 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 <br> sequence. Try replacing it with styling.")},h.prototype.testAttribute=function(a,b,c){d(b)?this.log.push('Found event attribute ('+b+") on <"+a+"> element."):f(a,b)?this.log.push('Found deprecated '+b+" attribute on <"+a+"> element."):e(b)?this.log.push('Found style attribute on <'+a+"> element."):g(b,c)&&this.log.push('Found inaccessible attribute (on <'+a+"> element).")},h.prototype.testChars=function(a){this._lastElement="",/( \s*){2,}/.test(a)&&this.log.push("Found repeating &nbsp; 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="
  1. "+this.log.join("
  2. ")+"
";else{var b=" - "+this.log.join("\n - ").replace(/(<([^>]+)>)/gi,"").replace(/</g,"<").replace(/>/g,">");console.log(b)}},a.HTMLLint=h}("undefined"==typeof exports?this:exports); \ No newline at end of file diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 7369a7a5..927ca954 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -784,6 +784,21 @@ buffer.length = Math.max(0, index); } + function squashTrailingWhitespace(nextTag) { + var charsIndex; + if (buffer.length > 1 && buffer[buffer.length - 1] === '' && /\s+$/.test(buffer[buffer.length - 2])) { + charsIndex = buffer.length - 2; + } + else if (buffer.length > 0 && /\s+$/.test(buffer[buffer.length - 1])) { + charsIndex = buffer.length - 1; + } + if (charsIndex > 0) { + buffer[charsIndex] = buffer[charsIndex].replace(/\s+$/, function(text) { + return collapseWhitespaceSmart(text, 'comment', nextTag, options); + }); + } + } + new HTMLParser(value, { partialMarkup: partialMarkup, html5: typeof options.html5 !== 'undefined' ? options.html5 : true, @@ -836,6 +851,9 @@ // set whitespace flags for nested tags (eg. within a
)
         if (options.collapseWhitespace) {
+          if (!stackNoTrimWhitespace.length) {
+            squashTrailingWhitespace(tag);
+          }
           if (!_canTrimWhitespace(tag, attrs)) {
             stackNoTrimWhitespace.push(tag);
           }
@@ -891,18 +909,7 @@
             }
           }
           else {
-            var charsIndex;
-            if (buffer.length > 1 && buffer[buffer.length - 1] === '' && /\s+$/.test(buffer[buffer.length - 2])) {
-              charsIndex = buffer.length - 2;
-            }
-            else if (buffer.length > 0 && /\s+$/.test(buffer[buffer.length - 1])) {
-              charsIndex = buffer.length - 1;
-            }
-            if (charsIndex > 0) {
-              buffer[charsIndex] = buffer[charsIndex].replace(/\s+$/, function(text) {
-                return collapseWhitespaceSmart(text, 'comment', '/' + tag, options);
-              });
-            }
+            squashTrailingWhitespace('/' + tag);
           }
           if (stackNoCollapseWhitespace.length &&
             tag === stackNoCollapseWhitespace[stackNoCollapseWhitespace.length - 1]) {
diff --git a/tests/minifier.js b/tests/minifier.js
index 4e5688b4..b0f2d833 100644
--- a/tests/minifier.js
+++ b/tests/minifier.js
@@ -834,24 +834,30 @@
     output = '
after
'; equal(minify(input, { removeEmptyElements: true }), output); output = '
after
'; - equal(minify(input, { collapseWhitespace:true, removeEmptyElements: true }), output); + equal(minify(input, { collapseWhitespace: true, removeEmptyElements: true }), output); input = '
before
'; output = '
before
'; equal(minify(input, { removeEmptyElements: true }), output); output = '
before
'; - equal(minify(input, { collapseWhitespace:true, removeEmptyElements: true }), output); + equal(minify(input, { collapseWhitespace: true, removeEmptyElements: true }), output); input = '
both
'; output = '
both
'; equal(minify(input, { removeEmptyElements: true }), output); output = '
both
'; - equal(minify(input, { collapseWhitespace:true, removeEmptyElements: true }), output); + equal(minify(input, { collapseWhitespace: true, removeEmptyElements: true }), output); + + input = '
unary
'; + output = '
unary
'; + equal(minify(input, { removeEmptyElements: true }), output); + output = '
unary
'; + equal(minify(input, { collapseWhitespace: true, removeEmptyElements: true }), output); input = '
Empty
'; equal(minify(input, { removeEmptyElements: true }), input); output = '
Empty
'; - equal(minify(input, { collapseWhitespace:true, removeEmptyElements: true }), output); + equal(minify(input, { collapseWhitespace: true, removeEmptyElements: true }), output); }); test('collapsing boolean attributes', function() { From 6f37d92e802ea76d17a9489228a05b3228f3cb2b Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Wed, 2 Mar 2016 16:11:54 +0800 Subject: [PATCH 2/4] collapseWhitespace across comments even when removeComments is turned off --- dist/htmlminifier.js | 2 +- dist/htmlminifier.min.js | 2 +- src/htmlminifier.js | 2 +- tests/minifier.js | 8 +++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dist/htmlminifier.js b/dist/htmlminifier.js index fc0e175b..63ab8729 100644 --- a/dist/htmlminifier.js +++ b/dist/htmlminifier.js @@ -1326,7 +1326,7 @@ function squashTrailingWhitespace(nextTag) { var charsIndex; - if (buffer.length > 1 && buffer[buffer.length - 1] === '' && /\s+$/.test(buffer[buffer.length - 2])) { + if (buffer.length > 1 && /^(?: 0 && /\s+$/.test(buffer[buffer.length - 1])) { diff --git a/dist/htmlminifier.min.js b/dist/htmlminifier.min.js index 78485fa7..7805f0d6 100644 --- a/dist/htmlminifier.min.js +++ b/dist/htmlminifier.min.js @@ -3,4 +3,4 @@ * Copyright 2010-2016 Juriy "kangax" Zaytsev * Licensed under the MIT license */ -!function(a){"use strict";function b(a){var b,c=new RegExp("[\\w:\\.-]+(?:\\s*(?:"+d(a)+")\\s*(?:\"[^\"]*\"+?|'[^']*'+?|[^>\\s\"']+?))?");if(a.customAttrSurround){for(var e=[],f=a.customAttrSurround.length-1;f>=0;f--)e[f]="(?:"+a.customAttrSurround[f][0].source+"\\s*"+c.source+"\\s*"+a.customAttrSurround[f][1].source+")";e.unshift("(?:"+c.source+")"),b=new RegExp("((?:\\s*(?:"+e.join("|")+"))*)")}else b=new RegExp("((?:\\s*"+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+")\\s*"+b.source+"\\s*("+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\s]+)/.source],j=/^<([\w:-]+)/,k=/\s*(\/?)>/,l=/^<\/([\w:-]+)[^>]*>/,m=/\/>$/,n=/^]+>/i,o=!1;"x".replace(/x(.)?/g,function(a,b){o=""===b});var p=e("area,base,basefont,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),q=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"),r=e("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),s=e("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),t=e("script,style"),u={},v=a.HTMLParser=function(a,d){function e(a,b,c,e){for(var h=!1;!d.html5&&g&&q[g];)f("",g);r[b]&&g===b&&f("",b),e=p[b]||"html"===b&&"head"===g||!!e;var i=[];c.replace(w,function(){var a,b,c,e,f,g,h,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&&(h=arguments[0].charAt(a.length+g.length),h="'"===h||'"'===h?h:"");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=s[a]?a:c),i.push({name:a,value:b,customAssign:g||"=",customOpen:e||"",customClose:f||"",quote:h||""})}),e?h=a.match(m):(k.push({tag:b,attrs:i}),g=b),d.start&&d.start(b,i,e,h)}function f(a,b){var c;if(b){var e=b.toLowerCase();for(c=k.length-1;c>=0&&k[c].tag.toLowerCase()!==e;c--);}else c=0;if(c>=0){for(var f=k.length-1;f>=c;f--)d.end&&d.end(k[f].tag,k[f].attrs);k.length=c,g=c&&k[c-1].tag}}for(var g,h,i,j,k=[],v=b(d),w=c(d);a;){if(h=a,g&&t[g]){var x=g.toLowerCase(),y=u[x]||(u[x]=new RegExp("([\\s\\S]*?)]*>","i"));a=a.replace(y,function(a,b){return"script"!==x&&"style"!==x&&"noscript"!==x&&(b=b.replace(//g,"$1").replace(//g,"$1")),d.chars&&d.chars(b),""}),f("",x)}else{var z=a.indexOf("<");if(0===z){if(/^");if(A>=0){d.comment&&d.comment(a.substring(4,A)),a=a.substring(A+3),i="";continue}}if(/^");if(B>=0){d.comment&&d.comment(a.substring(2,B+1),!0),a=a.substring(B+2),i="";continue}}var C=a.match(n);if(C){d.doctype&&d.doctype(C[0]),a=a.substring(C[0].length),i="";continue}var D=a.match(l);if(D){a=a.substring(D[0].length),D[0].replace(l,f),i="/"+D[1].toLowerCase();continue}var E=a.match(v);if(E){a=a.substring(E[0].length),E[0].replace(v,e),i=E[1].toLowerCase();continue}}var F;z>=0?(F=a.substring(0,z),a=a.substring(z)):(F=a,a="");var G=a.match(v);G?j=G[1]:(G=a.match(l),j=G?"/"+G[1]:""),d.chars&&d.chars(F,i,j),i=""}if(a===h)throw"Parse Error: "+a}d.partialMarkup||f()};a.HTMLtoXML=function(a){var b="";return new v(a,{start:function(a,c,d){b+="<"+a;for(var e=0;e"},end:function(a){b+=""},chars:function(a){b+=a},comment:function(a){b+=""},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 v(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){var b={};return a.forEach(function(a){b[a]=1}),function(a){return 1===b[a]}}function d(a){return c(a.split(/,/))}function e(a,c,d,e,f){var g="",h="";return c.preserveLineBreaks&&(a=a.replace(/^[\t ]*[\n\r][\t\n\r ]*/,function(){return g="\n",""}).replace(/[\t\n\r ]*[\n\r][\t ]*$/,function(){return h="\n",""})),d&&(a=a.replace(/^\s+/,!g&&c.conservativeCollapse?" ":"")),e&&(a=a.replace(/\s+$/,!h&&c.conservativeCollapse?" ":"")),f&&(a=b(a)),g+a+h}function f(a,b,c,d){var f=b&&!V(b);f&&!d.collapseInlineTagWhitespace&&(f="/"===b.charAt(0)?!T(b.slice(1)):!U(b));var g=c&&!V(c);return g&&!d.collapseInlineTagWhitespace&&(g="/"===c.charAt(0)?!U(c.slice(1)):!T(c)),e(a,d,f,g,b&&c)}function g(a){return/^\[if\s[^\]]+\]|\[endif\]$/.test(a)}function h(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 i(a,b){var c=b.customEventAttributes;if(c){for(var d=c.length;d--;)if(c[d].test(a))return!0;return!1}return/^on[a-z]{3,}$/.test(a)}function j(a){return/^[^\x20\t\n\f\r"'`=<>]+$/.test(a)}function k(a,b){for(var c=a.length;c--;)if(a[c].name.toLowerCase()===b)return!0;return!1}function l(a,b,c,d){return c=c?S(c.toLowerCase()):"","script"===a&&"language"===b&&"javascript"===c||"form"===a&&"method"===b&&"get"===c||"input"===a&&"type"===b&&"text"===c||"script"===a&&"charset"===b&&!k(d,"src")||"a"===a&&"name"===b&&k(d,"id")||"area"===a&&"shape"===b&&"rect"===c}function m(a,b,c){return"script"===a&&"type"===b&&"text/javascript"===S(c.toLowerCase())}function n(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){var f=S(b[c].value).split(/;/,2)[0].toLowerCase();return""===f||W(f)}}return!0}function o(a,b,c){return("style"===a||"link"===a)&&"type"===b&&"text/css"===S(c.toLowerCase())}function p(a,b){return X(a)||"draggable"===a&&!Y(b)}function q(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 r(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 s(a,b){if("link"!==a)return!1;for(var c=0,d=b.length;d>c;c++)if("rel"===b[c].name&&"canonical"===b[c].value)return!0}function t(a,c,d,e,f){if(d&&i(c,e)){if(d=S(d).replace(/^javascript:\s*/i,"").replace(/\s*;$/,""),e.minifyJS){var g=L(Z+d+$,e.minifyJS);return g.slice(Z.length,-$.length)}return d}return"class"===c?b(S(d)):q(c,a)?(d=S(d),e.minifyURLs&&!s(a,f)?K(d,e.minifyURLs):d):r(c,a)?S(d):"style"===c?(d=S(d),d&&(d=d.replace(/\s*;\s*$/,"")),e.minifyCSS?M(d,e.minifyCSS,!0):d):(u(a,f)&&"content"===c?d=d.replace(/\s+/g,"").replace(/[0-9]+\.[0-9]+/g,function(a){return(+a).toString()}):d&&e.customAttrCollapse&&e.customAttrCollapse.test(c)&&(d=d.replace(/\n+|\r+|\s{2,}/g,"")),d)}function u(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 v(a){return"*{"+a+"}"}function w(a){var b=a.match(/^\*\{([\s\S]*)\}$/m);return b&&b[1]?b[1]:a}function x(a,b){return a.replace(/^(\[if\s[^\]]+\]>)([\s\S]*?)(\s*\*\/|\/\/\s*\]\]>)\s*$/,"")}function z(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 O(a,b);return a}function A(a,b){return a.replace(_[b],"").replace(aa[b],"")}function B(a,b){switch(a){case"html":case"head":return!0;case"body":return!da(b);case"colgroup":return"col"===b;case"tbody":return"tr"===b}return!1}function C(a,b){switch(b){case"colgroup":return"colgroup"===a;case"tbody":return la(a)}return!1}function D(a,b){switch(a){case"html":case"head":case"body":case"colgroup":case"caption":return!0;case"li":case"optgroup":case"tr":return b===a;case"dt":case"dd":return ea(b);case"p":return fa(b);case"rb":case"rt":case"rp":return ha(b);case"rtc":return ia(b);case"option":return ja(b);case"thead":case"tbody":return ka(b);case"tfoot":return"tbody"===b;case"td":case"th":return ma(b)}return!1}function E(a,b,c){var d=!c||/^\s*$/.test(c);return d?"input"===a&&"value"===b||sa.test(b):!1}function F(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 G(a){return!/^(?:script|style|pre|textarea)$/.test(a)}function H(a){return!/^(?:pre|textarea)$/.test(a)}function I(a,b,c,d,e,f,g){var h,i,k=f.caseSensitive?a.name:a.name.toLowerCase(),n=a.value,q=a.quote;if(f.removeRedundantAttributes&&l(c,k,n,b)||f.removeScriptTypeAttributes&&m(c,k,n)||f.removeStyleLinkTypeAttributes&&o(c,k,n))return"";if(n=t(c,k,n,f,b),f.removeEmptyAttributes&&E(c,k,n))return"";if(void 0!==n&&!f.removeAttributeQuotes||!j(n)){if(!f.preventAttributesEscaping){if(void 0!==f.quoteCharacter)q="'"===f.quoteCharacter?"'":'"';else{var r=(n.match(/'/g)||[]).length,s=(n.match(/"/g)||[]).length;q=s>r?"'":'"'}n='"'===q?n.replace(/"/g,"""):n.replace(/'/g,"'")}i=q+n+q,g||f.removeTagWhitespace||(i+=" ")}else i=!g||d||/\/$/.test(n)?n+" ":n;return void 0===n||f.collapseBooleanAttributes&&p(k.toLowerCase(),n.toLowerCase())?(h=k,g||(h+=" ")):h=k+a.customAssign+i,a.customOpen+h+a.customClose}function J(a){for(var b=["canCollapseWhitespace","canTrimWhitespace"],c=0,d=b.length;d>c;c++)a[b[c]]||(a[b[c]]=function(){return!1})}function K(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){Q(e)}return b}function L(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){Q(j)}return b}function M(b,c,d){"object"!=typeof c&&(c={}),"undefined"==typeof c.advanced&&(c.advanced=!1);try{var e=a.CleanCSS;"undefined"==typeof e&&"function"==typeof require&&(e=require("clean-css"));var f=new e(c);return d?w(f.minify(v(b)).styles):f.minify(b).styles}catch(g){Q(g)}return b}function N(a){var b;do b=Math.random().toString(36).slice(2);while(~a.indexOf(b));return b}function O(a,c,d){function i(a,b){return G(a)||c.canCollapseWhitespace(a,b)}function j(a,b){return H(a)||c.canTrimWhitespace(a,b)}function k(){for(var a=t.length-1;a>0&&!/^<[^\/!]/.test(t[a]);)a--;t.length=Math.max(0,a)}function l(){for(var a=t.length-1;a>0&&!/^<\//.test(t[a]);)a--;t.length=Math.max(0,a)}function m(a){var b;t.length>1&&""===t[t.length-1]&&/\s+$/.test(t[t.length-2])?b=t.length-2:t.length>0&&/\s+$/.test(t[t.length-1])&&(b=t.length-1),b>0&&(t[b]=t[b].replace(/\s+$/,function(b){return f(b,"comment",a,c)}))}c=c||{};var o=[];J(c),a=c.collapseWhitespace?S(a):a;var p,q,r,s,t=[],u="",v="",w=[],E=[],K=[],O="",T="",V=c.lint,W=Date.now(),X=[],Y=[];a=a.replace(/([\s\S]*?)/g,function(b,c){r||(r="");var d=r+X.length;return X.push(c),d});var Z=(c.ignoreCustomFragments||[/<%[\s\S]*?%>/,/<\?[\s\S]*?\?>/]).map(function(a){return a.source});if(Z.length){var $=new RegExp("\\s*(?:"+Z.join("|")+")+\\s*","g");a=a.replace($,function(b){s||(s=N(a));var c=s+Y.length;return Y.push(b)," "+c+" "})}new R(a,{partialMarkup:d,html5:"undefined"!=typeof c.html5?c.html5:!0,start:function(a,b,d,e){var f=a.toLowerCase();if("svg"===f){o.push(c);var g={};for(var h in c)g[h]=c[h];g.keepClosingSlash=!0,g.caseSensitive=!0,c=g}a=c.caseSensitive?a:f,v=a,p=a,U(a)||(u=""),q=!1,w=b;var n=c.removeOptionalTags;if(n){var r=ra(a);r&&B(O,a)&&k(),O="",r&&D(T,a)&&(l(),n=!C(T,a)),T=""}c.collapseWhitespace&&(E.length||m(a),j(a,b)||E.push(a),i(a,b)||K.push(a));var s="<"+a,x=e&&c.keepClosingSlash;t.push(s),V&&V.testElement(a);for(var y,z=[],A=!0,F=b.length;--F>=0;)V&&V.testAttribute(a,b[F].name.toLowerCase(),b[F].value),y=I(b[F],b,a,x,F,c,A),y&&(A=!1,z.unshift(y));z.length>0?(t.push(" "),t.push.apply(t,z)):n&&ba(a)&&(O=a),t.push(t.pop()+(x?"/":"")+">")},end:function(a,b){var d=a.toLowerCase();"svg"===d&&(c=o.pop()),a=c.caseSensitive?a:d,c.collapseWhitespace&&(E.length?a===E[E.length-1]&&E.pop():m("/"+a),K.length&&a===K[K.length-1]&&K.pop());var e=!1;a===v&&(v="",e=!q),c.removeOptionalTags&&(e&&na(O)&&k(),O="",!ra(a)||!T||qa(T)||"p"===T&&ga(a)||l(),T=ca(a)?a:""),c.removeEmptyElements&&e&&F(a,b)?(k(),O="",T=""):(t.push(""),p="/"+a,U(a)||(u=""))},chars:function(a,d,g){if(d=""===d?"comment":d,g=""===g?"comment":g,c.collapseWhitespace){if(!E.length){if("comment"===d){var h=""===t[t.length-1];if(h&&(d=p),t.length>1&&(h||/ $/.test(u))){var i=t.length-2;t[i]=t[i].replace(/\s+$/,function(b){return a=b+a,""})}}if(d&&U("/"===d.charAt(0)?d.slice(1):d)&&(a=e(a,c,/(?:^|\s)$/.test(u))),a=d||g?f(a,d,g,c):S(a),!a&&/\s$/.test(u)&&d&&"/"===d.charAt(0))for(var m=t.length-2,o=d.slice(1);m>=0&&j(o);m--){var r=t[m],s=r.match(/^<\/([\w:-]+)>$/);if(s)o=s[1];else if(/>$/.test(r)||(t[m]=f(r,null,g,c)))break}}K.length||(a=d&&g||"html"===g?a:b(a))}"script"!==v&&"style"!==v||(c.removeCommentsFromCDATA&&(a=A(a,v)),c.removeCDATASectionsFromCDATA&&(a=y(a)),c.processScripts&&(a=z(a,c,w))),c.minifyJS&&n(v,w)&&(a=L(a,c.minifyJS),";"===a.charAt(a.length-1)&&(a=a.slice(0,-1))),"style"===v&&c.minifyCSS&&(a=M(a,c.minifyCSS)),c.removeOptionalTags&&a&&(("html"===O||"body"===O&&!/^\s/.test(a))&&k(),O="",(oa(T)||pa(T)&&!/^\s/.test(a))&&l(),T=""),p=/^\s*$/.test(a)?d:"comment",u+=a,a&&(q=!0),V&&V.testChars(a),t.push(a)},comment:function(a,b){var d=b?"":"-->";a=g(a)?d+x(a,c)+e:c.removeComments?h(a,c)?"":"":d+a+e,c.removeOptionalTags&&a&&(O="",T=""),t.push(a)},doctype:function(a){t.push(c.useShortDoctype?"":b(a))},customAttrAssign:c.customAttrAssign,customAttrSurround:c.customAttrSurround}),c.removeOptionalTags&&(na(O)&&k(),T&&!qa(T)&&l());var _=P(t,c);return s&&(_=_.replace(new RegExp("(\\s*)"+s+"([0-9]+)(\\s*)","g"),function(a,b,d,f){var g=Y[+d];return c.collapseWhitespace?(" "!==b&&(g=b+g)," "!==f&&(g+=f),e(g,{preserveLineBreaks:c.preserveLineBreaks,conservativeCollapse:!0},/^\s/.test(g),/\s$/.test(g))):g})),r&&(_=_.replace(new RegExp(r+"([0-9]+)","g"),function(a,b){return X[+b]})),Q("minified in: "+(Date.now()-W)+"ms"),_}function P(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\s*$/,style:/\s*-->\s*$/},ba=d("html,head,body,colgroup,tbody"),ca=d("html,head,body,li,dt,dd,p,rb,rt,rtc,rp,optgroup,option,colgroup,caption,thead,tbody,tfoot,tr,td,th"),da=d("meta,link,script,style,template,noscript"),ea=d("dt,dd"),fa=d("address,article,aside,blockquote,details,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,main,menu,nav,ol,p,pre,section,table,ul"),ga=d("a,audio,del,ins,map,noscript,video"),ha=d("rb,rt,rtc,rp"),ia=d("rb,rtc,rp"),ja=d("option,optgroup"),ka=d("tbody,tfoot"),la=d("thead,tbody,tfoot"),ma=d("td,th"),na=d("html,head,body"),oa=d("html,body"),pa=d("head,colgroup,caption"),qa=d("dt,thead"),ra=d("a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,element,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,menu,menuitem,meta,meter,multicol,nav,nobr,noembed,noframes,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,pre,progress,q,rp,rt,rtc,ruby,s,samp,script,section,select,shadow,small,source,spacer,span,strike,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,xmp"),sa=new RegExp("^(?:class|id|style|title|lang|dir|on(?:focus|blur|change|click|dblclick|mouse(?:down|up|over|move|out)|key(?:press|down|up)))$");a.minify=function(a,b){return O(a,b)}}("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 deprecated <'+a+"> element"):b(a)?this.log.push('Found presentational <'+a+"> 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 <br> sequence. Try replacing it with styling.")},h.prototype.testAttribute=function(a,b,c){d(b)?this.log.push('Found event attribute ('+b+") on <"+a+"> element."):f(a,b)?this.log.push('Found deprecated '+b+" attribute on <"+a+"> element."):e(b)?this.log.push('Found style attribute on <'+a+"> element."):g(b,c)&&this.log.push('Found inaccessible attribute (on <'+a+"> element).")},h.prototype.testChars=function(a){this._lastElement="",/( \s*){2,}/.test(a)&&this.log.push("Found repeating &nbsp; 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="
  1. "+this.log.join("
  2. ")+"
";else{var b=" - "+this.log.join("\n - ").replace(/(<([^>]+)>)/gi,"").replace(/</g,"<").replace(/>/g,">");console.log(b)}},a.HTMLLint=h}("undefined"==typeof exports?this:exports); \ No newline at end of file +!function(a){"use strict";function b(a){var b,c=new RegExp("[\\w:\\.-]+(?:\\s*(?:"+d(a)+")\\s*(?:\"[^\"]*\"+?|'[^']*'+?|[^>\\s\"']+?))?");if(a.customAttrSurround){for(var e=[],f=a.customAttrSurround.length-1;f>=0;f--)e[f]="(?:"+a.customAttrSurround[f][0].source+"\\s*"+c.source+"\\s*"+a.customAttrSurround[f][1].source+")";e.unshift("(?:"+c.source+")"),b=new RegExp("((?:\\s*(?:"+e.join("|")+"))*)")}else b=new RegExp("((?:\\s*"+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+")\\s*"+b.source+"\\s*("+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\s]+)/.source],j=/^<([\w:-]+)/,k=/\s*(\/?)>/,l=/^<\/([\w:-]+)[^>]*>/,m=/\/>$/,n=/^]+>/i,o=!1;"x".replace(/x(.)?/g,function(a,b){o=""===b});var p=e("area,base,basefont,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),q=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"),r=e("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),s=e("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),t=e("script,style"),u={},v=a.HTMLParser=function(a,d){function e(a,b,c,e){for(var h=!1;!d.html5&&g&&q[g];)f("",g);r[b]&&g===b&&f("",b),e=p[b]||"html"===b&&"head"===g||!!e;var i=[];c.replace(w,function(){var a,b,c,e,f,g,h,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&&(h=arguments[0].charAt(a.length+g.length),h="'"===h||'"'===h?h:"");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=s[a]?a:c),i.push({name:a,value:b,customAssign:g||"=",customOpen:e||"",customClose:f||"",quote:h||""})}),e?h=a.match(m):(k.push({tag:b,attrs:i}),g=b),d.start&&d.start(b,i,e,h)}function f(a,b){var c;if(b){var e=b.toLowerCase();for(c=k.length-1;c>=0&&k[c].tag.toLowerCase()!==e;c--);}else c=0;if(c>=0){for(var f=k.length-1;f>=c;f--)d.end&&d.end(k[f].tag,k[f].attrs);k.length=c,g=c&&k[c-1].tag}}for(var g,h,i,j,k=[],v=b(d),w=c(d);a;){if(h=a,g&&t[g]){var x=g.toLowerCase(),y=u[x]||(u[x]=new RegExp("([\\s\\S]*?)]*>","i"));a=a.replace(y,function(a,b){return"script"!==x&&"style"!==x&&"noscript"!==x&&(b=b.replace(//g,"$1").replace(//g,"$1")),d.chars&&d.chars(b),""}),f("",x)}else{var z=a.indexOf("<");if(0===z){if(/^");if(A>=0){d.comment&&d.comment(a.substring(4,A)),a=a.substring(A+3),i="";continue}}if(/^");if(B>=0){d.comment&&d.comment(a.substring(2,B+1),!0),a=a.substring(B+2),i="";continue}}var C=a.match(n);if(C){d.doctype&&d.doctype(C[0]),a=a.substring(C[0].length),i="";continue}var D=a.match(l);if(D){a=a.substring(D[0].length),D[0].replace(l,f),i="/"+D[1].toLowerCase();continue}var E=a.match(v);if(E){a=a.substring(E[0].length),E[0].replace(v,e),i=E[1].toLowerCase();continue}}var F;z>=0?(F=a.substring(0,z),a=a.substring(z)):(F=a,a="");var G=a.match(v);G?j=G[1]:(G=a.match(l),j=G?"/"+G[1]:""),d.chars&&d.chars(F,i,j),i=""}if(a===h)throw"Parse Error: "+a}d.partialMarkup||f()};a.HTMLtoXML=function(a){var b="";return new v(a,{start:function(a,c,d){b+="<"+a;for(var e=0;e"},end:function(a){b+=""},chars:function(a){b+=a},comment:function(a){b+=""},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 v(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){var b={};return a.forEach(function(a){b[a]=1}),function(a){return 1===b[a]}}function d(a){return c(a.split(/,/))}function e(a,c,d,e,f){var g="",h="";return c.preserveLineBreaks&&(a=a.replace(/^[\t ]*[\n\r][\t\n\r ]*/,function(){return g="\n",""}).replace(/[\t\n\r ]*[\n\r][\t ]*$/,function(){return h="\n",""})),d&&(a=a.replace(/^\s+/,!g&&c.conservativeCollapse?" ":"")),e&&(a=a.replace(/\s+$/,!h&&c.conservativeCollapse?" ":"")),f&&(a=b(a)),g+a+h}function f(a,b,c,d){var f=b&&!V(b);f&&!d.collapseInlineTagWhitespace&&(f="/"===b.charAt(0)?!T(b.slice(1)):!U(b));var g=c&&!V(c);return g&&!d.collapseInlineTagWhitespace&&(g="/"===c.charAt(0)?!U(c.slice(1)):!T(c)),e(a,d,f,g,b&&c)}function g(a){return/^\[if\s[^\]]+\]|\[endif\]$/.test(a)}function h(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 i(a,b){var c=b.customEventAttributes;if(c){for(var d=c.length;d--;)if(c[d].test(a))return!0;return!1}return/^on[a-z]{3,}$/.test(a)}function j(a){return/^[^\x20\t\n\f\r"'`=<>]+$/.test(a)}function k(a,b){for(var c=a.length;c--;)if(a[c].name.toLowerCase()===b)return!0;return!1}function l(a,b,c,d){return c=c?S(c.toLowerCase()):"","script"===a&&"language"===b&&"javascript"===c||"form"===a&&"method"===b&&"get"===c||"input"===a&&"type"===b&&"text"===c||"script"===a&&"charset"===b&&!k(d,"src")||"a"===a&&"name"===b&&k(d,"id")||"area"===a&&"shape"===b&&"rect"===c}function m(a,b,c){return"script"===a&&"type"===b&&"text/javascript"===S(c.toLowerCase())}function n(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){var f=S(b[c].value).split(/;/,2)[0].toLowerCase();return""===f||W(f)}}return!0}function o(a,b,c){return("style"===a||"link"===a)&&"type"===b&&"text/css"===S(c.toLowerCase())}function p(a,b){return X(a)||"draggable"===a&&!Y(b)}function q(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 r(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 s(a,b){if("link"!==a)return!1;for(var c=0,d=b.length;d>c;c++)if("rel"===b[c].name&&"canonical"===b[c].value)return!0}function t(a,c,d,e,f){if(d&&i(c,e)){if(d=S(d).replace(/^javascript:\s*/i,"").replace(/\s*;$/,""),e.minifyJS){var g=L(Z+d+$,e.minifyJS);return g.slice(Z.length,-$.length)}return d}return"class"===c?b(S(d)):q(c,a)?(d=S(d),e.minifyURLs&&!s(a,f)?K(d,e.minifyURLs):d):r(c,a)?S(d):"style"===c?(d=S(d),d&&(d=d.replace(/\s*;\s*$/,"")),e.minifyCSS?M(d,e.minifyCSS,!0):d):(u(a,f)&&"content"===c?d=d.replace(/\s+/g,"").replace(/[0-9]+\.[0-9]+/g,function(a){return(+a).toString()}):d&&e.customAttrCollapse&&e.customAttrCollapse.test(c)&&(d=d.replace(/\n+|\r+|\s{2,}/g,"")),d)}function u(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 v(a){return"*{"+a+"}"}function w(a){var b=a.match(/^\*\{([\s\S]*)\}$/m);return b&&b[1]?b[1]:a}function x(a,b){return a.replace(/^(\[if\s[^\]]+\]>)([\s\S]*?)(\s*\*\/|\/\/\s*\]\]>)\s*$/,"")}function z(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 O(a,b);return a}function A(a,b){return a.replace(_[b],"").replace(aa[b],"")}function B(a,b){switch(a){case"html":case"head":return!0;case"body":return!da(b);case"colgroup":return"col"===b;case"tbody":return"tr"===b}return!1}function C(a,b){switch(b){case"colgroup":return"colgroup"===a;case"tbody":return la(a)}return!1}function D(a,b){switch(a){case"html":case"head":case"body":case"colgroup":case"caption":return!0;case"li":case"optgroup":case"tr":return b===a;case"dt":case"dd":return ea(b);case"p":return fa(b);case"rb":case"rt":case"rp":return ha(b);case"rtc":return ia(b);case"option":return ja(b);case"thead":case"tbody":return ka(b);case"tfoot":return"tbody"===b;case"td":case"th":return ma(b)}return!1}function E(a,b,c){var d=!c||/^\s*$/.test(c);return d?"input"===a&&"value"===b||sa.test(b):!1}function F(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 G(a){return!/^(?:script|style|pre|textarea)$/.test(a)}function H(a){return!/^(?:pre|textarea)$/.test(a)}function I(a,b,c,d,e,f,g){var h,i,k=f.caseSensitive?a.name:a.name.toLowerCase(),n=a.value,q=a.quote;if(f.removeRedundantAttributes&&l(c,k,n,b)||f.removeScriptTypeAttributes&&m(c,k,n)||f.removeStyleLinkTypeAttributes&&o(c,k,n))return"";if(n=t(c,k,n,f,b),f.removeEmptyAttributes&&E(c,k,n))return"";if(void 0!==n&&!f.removeAttributeQuotes||!j(n)){if(!f.preventAttributesEscaping){if(void 0!==f.quoteCharacter)q="'"===f.quoteCharacter?"'":'"';else{var r=(n.match(/'/g)||[]).length,s=(n.match(/"/g)||[]).length;q=s>r?"'":'"'}n='"'===q?n.replace(/"/g,"""):n.replace(/'/g,"'")}i=q+n+q,g||f.removeTagWhitespace||(i+=" ")}else i=!g||d||/\/$/.test(n)?n+" ":n;return void 0===n||f.collapseBooleanAttributes&&p(k.toLowerCase(),n.toLowerCase())?(h=k,g||(h+=" ")):h=k+a.customAssign+i,a.customOpen+h+a.customClose}function J(a){for(var b=["canCollapseWhitespace","canTrimWhitespace"],c=0,d=b.length;d>c;c++)a[b[c]]||(a[b[c]]=function(){return!1})}function K(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){Q(e)}return b}function L(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){Q(j)}return b}function M(b,c,d){"object"!=typeof c&&(c={}),"undefined"==typeof c.advanced&&(c.advanced=!1);try{var e=a.CleanCSS;"undefined"==typeof e&&"function"==typeof require&&(e=require("clean-css"));var f=new e(c);return d?w(f.minify(v(b)).styles):f.minify(b).styles}catch(g){Q(g)}return b}function N(a){var b;do b=Math.random().toString(36).slice(2);while(~a.indexOf(b));return b}function O(a,c,d){function i(a,b){return G(a)||c.canCollapseWhitespace(a,b)}function j(a,b){return H(a)||c.canTrimWhitespace(a,b)}function k(){for(var a=t.length-1;a>0&&!/^<[^\/!]/.test(t[a]);)a--;t.length=Math.max(0,a)}function l(){for(var a=t.length-1;a>0&&!/^<\//.test(t[a]);)a--;t.length=Math.max(0,a)}function m(a){var b;t.length>1&&/^(?:0&&/\s+$/.test(t[t.length-1])&&(b=t.length-1),b>0&&(t[b]=t[b].replace(/\s+$/,function(b){return f(b,"comment",a,c)}))}c=c||{};var o=[];J(c),a=c.collapseWhitespace?S(a):a;var p,q,r,s,t=[],u="",v="",w=[],E=[],K=[],O="",T="",V=c.lint,W=Date.now(),X=[],Y=[];a=a.replace(/([\s\S]*?)/g,function(b,c){r||(r="");var d=r+X.length;return X.push(c),d});var Z=(c.ignoreCustomFragments||[/<%[\s\S]*?%>/,/<\?[\s\S]*?\?>/]).map(function(a){return a.source});if(Z.length){var $=new RegExp("\\s*(?:"+Z.join("|")+")+\\s*","g");a=a.replace($,function(b){s||(s=N(a));var c=s+Y.length;return Y.push(b)," "+c+" "})}new R(a,{partialMarkup:d,html5:"undefined"!=typeof c.html5?c.html5:!0,start:function(a,b,d,e){var f=a.toLowerCase();if("svg"===f){o.push(c);var g={};for(var h in c)g[h]=c[h];g.keepClosingSlash=!0,g.caseSensitive=!0,c=g}a=c.caseSensitive?a:f,v=a,p=a,U(a)||(u=""),q=!1,w=b;var n=c.removeOptionalTags;if(n){var r=ra(a);r&&B(O,a)&&k(),O="",r&&D(T,a)&&(l(),n=!C(T,a)),T=""}c.collapseWhitespace&&(E.length||m(a),j(a,b)||E.push(a),i(a,b)||K.push(a));var s="<"+a,x=e&&c.keepClosingSlash;t.push(s),V&&V.testElement(a);for(var y,z=[],A=!0,F=b.length;--F>=0;)V&&V.testAttribute(a,b[F].name.toLowerCase(),b[F].value),y=I(b[F],b,a,x,F,c,A),y&&(A=!1,z.unshift(y));z.length>0?(t.push(" "),t.push.apply(t,z)):n&&ba(a)&&(O=a),t.push(t.pop()+(x?"/":"")+">")},end:function(a,b){var d=a.toLowerCase();"svg"===d&&(c=o.pop()),a=c.caseSensitive?a:d,c.collapseWhitespace&&(E.length?a===E[E.length-1]&&E.pop():m("/"+a),K.length&&a===K[K.length-1]&&K.pop());var e=!1;a===v&&(v="",e=!q),c.removeOptionalTags&&(e&&na(O)&&k(),O="",!ra(a)||!T||qa(T)||"p"===T&&ga(a)||l(),T=ca(a)?a:""),c.removeEmptyElements&&e&&F(a,b)?(k(),O="",T=""):(t.push(""),p="/"+a,U(a)||(u=""))},chars:function(a,d,g){if(d=""===d?"comment":d,g=""===g?"comment":g,c.collapseWhitespace){if(!E.length){if("comment"===d){var h=""===t[t.length-1];if(h&&(d=p),t.length>1&&(h||/ $/.test(u))){var i=t.length-2;t[i]=t[i].replace(/\s+$/,function(b){return a=b+a,""})}}if(d&&U("/"===d.charAt(0)?d.slice(1):d)&&(a=e(a,c,/(?:^|\s)$/.test(u))),a=d||g?f(a,d,g,c):S(a),!a&&/\s$/.test(u)&&d&&"/"===d.charAt(0))for(var m=t.length-2,o=d.slice(1);m>=0&&j(o);m--){var r=t[m],s=r.match(/^<\/([\w:-]+)>$/);if(s)o=s[1];else if(/>$/.test(r)||(t[m]=f(r,null,g,c)))break}}K.length||(a=d&&g||"html"===g?a:b(a))}"script"!==v&&"style"!==v||(c.removeCommentsFromCDATA&&(a=A(a,v)),c.removeCDATASectionsFromCDATA&&(a=y(a)),c.processScripts&&(a=z(a,c,w))),c.minifyJS&&n(v,w)&&(a=L(a,c.minifyJS),";"===a.charAt(a.length-1)&&(a=a.slice(0,-1))),"style"===v&&c.minifyCSS&&(a=M(a,c.minifyCSS)),c.removeOptionalTags&&a&&(("html"===O||"body"===O&&!/^\s/.test(a))&&k(),O="",(oa(T)||pa(T)&&!/^\s/.test(a))&&l(),T=""),p=/^\s*$/.test(a)?d:"comment",u+=a,a&&(q=!0),V&&V.testChars(a),t.push(a)},comment:function(a,b){var d=b?"":"-->";a=g(a)?d+x(a,c)+e:c.removeComments?h(a,c)?"":"":d+a+e,c.removeOptionalTags&&a&&(O="",T=""),t.push(a)},doctype:function(a){t.push(c.useShortDoctype?"":b(a))},customAttrAssign:c.customAttrAssign,customAttrSurround:c.customAttrSurround}),c.removeOptionalTags&&(na(O)&&k(),T&&!qa(T)&&l());var _=P(t,c);return s&&(_=_.replace(new RegExp("(\\s*)"+s+"([0-9]+)(\\s*)","g"),function(a,b,d,f){var g=Y[+d];return c.collapseWhitespace?(" "!==b&&(g=b+g)," "!==f&&(g+=f),e(g,{preserveLineBreaks:c.preserveLineBreaks,conservativeCollapse:!0},/^\s/.test(g),/\s$/.test(g))):g})),r&&(_=_.replace(new RegExp(r+"([0-9]+)","g"),function(a,b){return X[+b]})),Q("minified in: "+(Date.now()-W)+"ms"),_}function P(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\s*$/,style:/\s*-->\s*$/},ba=d("html,head,body,colgroup,tbody"),ca=d("html,head,body,li,dt,dd,p,rb,rt,rtc,rp,optgroup,option,colgroup,caption,thead,tbody,tfoot,tr,td,th"),da=d("meta,link,script,style,template,noscript"),ea=d("dt,dd"),fa=d("address,article,aside,blockquote,details,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,main,menu,nav,ol,p,pre,section,table,ul"),ga=d("a,audio,del,ins,map,noscript,video"),ha=d("rb,rt,rtc,rp"),ia=d("rb,rtc,rp"),ja=d("option,optgroup"),ka=d("tbody,tfoot"),la=d("thead,tbody,tfoot"),ma=d("td,th"),na=d("html,head,body"),oa=d("html,body"),pa=d("head,colgroup,caption"),qa=d("dt,thead"),ra=d("a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,element,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,menu,menuitem,meta,meter,multicol,nav,nobr,noembed,noframes,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,pre,progress,q,rp,rt,rtc,ruby,s,samp,script,section,select,shadow,small,source,spacer,span,strike,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,xmp"),sa=new RegExp("^(?:class|id|style|title|lang|dir|on(?:focus|blur|change|click|dblclick|mouse(?:down|up|over|move|out)|key(?:press|down|up)))$");a.minify=function(a,b){return O(a,b)}}("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 deprecated <'+a+"> element"):b(a)?this.log.push('Found presentational <'+a+"> 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 <br> sequence. Try replacing it with styling.")},h.prototype.testAttribute=function(a,b,c){d(b)?this.log.push('Found event attribute ('+b+") on <"+a+"> element."):f(a,b)?this.log.push('Found deprecated '+b+" attribute on <"+a+"> element."):e(b)?this.log.push('Found style attribute on <'+a+"> element."):g(b,c)&&this.log.push('Found inaccessible attribute (on <'+a+"> element).")},h.prototype.testChars=function(a){this._lastElement="",/( \s*){2,}/.test(a)&&this.log.push("Found repeating &nbsp; 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="
  1. "+this.log.join("
  2. ")+"
";else{var b=" - "+this.log.join("\n - ").replace(/(<([^>]+)>)/gi,"").replace(/</g,"<").replace(/>/g,">");console.log(b)}},a.HTMLLint=h}("undefined"==typeof exports?this:exports); \ No newline at end of file diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 927ca954..b94e6aee 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -786,7 +786,7 @@ function squashTrailingWhitespace(nextTag) { var charsIndex; - if (buffer.length > 1 && buffer[buffer.length - 1] === '' && /\s+$/.test(buffer[buffer.length - 2])) { + if (buffer.length > 1 && /^(?: 0 && /\s+$/.test(buffer[buffer.length - 1])) { diff --git a/tests/minifier.js b/tests/minifier.js index b0f2d833..33763b22 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -176,6 +176,12 @@ input = ''; output = ''; equal(minify(input, { collapseWhitespace: true }), output); + input = ' '; + output = ''; + equal(minify(input, { collapseWhitespace: true }), output); + input = ' '; + output = ''; + equal(minify(input, { collapseWhitespace: true }), output); }); test('doctype normalization', function() { @@ -298,7 +304,7 @@ '' + '' + '' + - ' ' + + '' + 'Document'; equal(minify(input, { removeComments: true, From 3e7a13ee8708876469f9ec4411f016b0f26801ab Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Wed, 2 Mar 2016 16:35:43 +0800 Subject: [PATCH 3/4] optimise regex --- dist/htmlminifier.js | 4 ++-- dist/htmlminifier.min.js | 2 +- src/htmlminifier.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/htmlminifier.js b/dist/htmlminifier.js index 63ab8729..6a5879a6 100644 --- a/dist/htmlminifier.js +++ b/dist/htmlminifier.js @@ -1326,10 +1326,10 @@ function squashTrailingWhitespace(nextTag) { var charsIndex; - if (buffer.length > 1 && /^(?: 1 && /^(?: 0 && /\s+$/.test(buffer[buffer.length - 1])) { + else if (buffer.length > 0 && /\s$/.test(buffer[buffer.length - 1])) { charsIndex = buffer.length - 1; } if (charsIndex > 0) { diff --git a/dist/htmlminifier.min.js b/dist/htmlminifier.min.js index 7805f0d6..40d49ac1 100644 --- a/dist/htmlminifier.min.js +++ b/dist/htmlminifier.min.js @@ -3,4 +3,4 @@ * Copyright 2010-2016 Juriy "kangax" Zaytsev * Licensed under the MIT license */ -!function(a){"use strict";function b(a){var b,c=new RegExp("[\\w:\\.-]+(?:\\s*(?:"+d(a)+")\\s*(?:\"[^\"]*\"+?|'[^']*'+?|[^>\\s\"']+?))?");if(a.customAttrSurround){for(var e=[],f=a.customAttrSurround.length-1;f>=0;f--)e[f]="(?:"+a.customAttrSurround[f][0].source+"\\s*"+c.source+"\\s*"+a.customAttrSurround[f][1].source+")";e.unshift("(?:"+c.source+")"),b=new RegExp("((?:\\s*(?:"+e.join("|")+"))*)")}else b=new RegExp("((?:\\s*"+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+")\\s*"+b.source+"\\s*("+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\s]+)/.source],j=/^<([\w:-]+)/,k=/\s*(\/?)>/,l=/^<\/([\w:-]+)[^>]*>/,m=/\/>$/,n=/^]+>/i,o=!1;"x".replace(/x(.)?/g,function(a,b){o=""===b});var p=e("area,base,basefont,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),q=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"),r=e("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),s=e("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),t=e("script,style"),u={},v=a.HTMLParser=function(a,d){function e(a,b,c,e){for(var h=!1;!d.html5&&g&&q[g];)f("",g);r[b]&&g===b&&f("",b),e=p[b]||"html"===b&&"head"===g||!!e;var i=[];c.replace(w,function(){var a,b,c,e,f,g,h,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&&(h=arguments[0].charAt(a.length+g.length),h="'"===h||'"'===h?h:"");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=s[a]?a:c),i.push({name:a,value:b,customAssign:g||"=",customOpen:e||"",customClose:f||"",quote:h||""})}),e?h=a.match(m):(k.push({tag:b,attrs:i}),g=b),d.start&&d.start(b,i,e,h)}function f(a,b){var c;if(b){var e=b.toLowerCase();for(c=k.length-1;c>=0&&k[c].tag.toLowerCase()!==e;c--);}else c=0;if(c>=0){for(var f=k.length-1;f>=c;f--)d.end&&d.end(k[f].tag,k[f].attrs);k.length=c,g=c&&k[c-1].tag}}for(var g,h,i,j,k=[],v=b(d),w=c(d);a;){if(h=a,g&&t[g]){var x=g.toLowerCase(),y=u[x]||(u[x]=new RegExp("([\\s\\S]*?)]*>","i"));a=a.replace(y,function(a,b){return"script"!==x&&"style"!==x&&"noscript"!==x&&(b=b.replace(//g,"$1").replace(//g,"$1")),d.chars&&d.chars(b),""}),f("",x)}else{var z=a.indexOf("<");if(0===z){if(/^");if(A>=0){d.comment&&d.comment(a.substring(4,A)),a=a.substring(A+3),i="";continue}}if(/^");if(B>=0){d.comment&&d.comment(a.substring(2,B+1),!0),a=a.substring(B+2),i="";continue}}var C=a.match(n);if(C){d.doctype&&d.doctype(C[0]),a=a.substring(C[0].length),i="";continue}var D=a.match(l);if(D){a=a.substring(D[0].length),D[0].replace(l,f),i="/"+D[1].toLowerCase();continue}var E=a.match(v);if(E){a=a.substring(E[0].length),E[0].replace(v,e),i=E[1].toLowerCase();continue}}var F;z>=0?(F=a.substring(0,z),a=a.substring(z)):(F=a,a="");var G=a.match(v);G?j=G[1]:(G=a.match(l),j=G?"/"+G[1]:""),d.chars&&d.chars(F,i,j),i=""}if(a===h)throw"Parse Error: "+a}d.partialMarkup||f()};a.HTMLtoXML=function(a){var b="";return new v(a,{start:function(a,c,d){b+="<"+a;for(var e=0;e"},end:function(a){b+=""},chars:function(a){b+=a},comment:function(a){b+=""},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 v(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){var b={};return a.forEach(function(a){b[a]=1}),function(a){return 1===b[a]}}function d(a){return c(a.split(/,/))}function e(a,c,d,e,f){var g="",h="";return c.preserveLineBreaks&&(a=a.replace(/^[\t ]*[\n\r][\t\n\r ]*/,function(){return g="\n",""}).replace(/[\t\n\r ]*[\n\r][\t ]*$/,function(){return h="\n",""})),d&&(a=a.replace(/^\s+/,!g&&c.conservativeCollapse?" ":"")),e&&(a=a.replace(/\s+$/,!h&&c.conservativeCollapse?" ":"")),f&&(a=b(a)),g+a+h}function f(a,b,c,d){var f=b&&!V(b);f&&!d.collapseInlineTagWhitespace&&(f="/"===b.charAt(0)?!T(b.slice(1)):!U(b));var g=c&&!V(c);return g&&!d.collapseInlineTagWhitespace&&(g="/"===c.charAt(0)?!U(c.slice(1)):!T(c)),e(a,d,f,g,b&&c)}function g(a){return/^\[if\s[^\]]+\]|\[endif\]$/.test(a)}function h(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 i(a,b){var c=b.customEventAttributes;if(c){for(var d=c.length;d--;)if(c[d].test(a))return!0;return!1}return/^on[a-z]{3,}$/.test(a)}function j(a){return/^[^\x20\t\n\f\r"'`=<>]+$/.test(a)}function k(a,b){for(var c=a.length;c--;)if(a[c].name.toLowerCase()===b)return!0;return!1}function l(a,b,c,d){return c=c?S(c.toLowerCase()):"","script"===a&&"language"===b&&"javascript"===c||"form"===a&&"method"===b&&"get"===c||"input"===a&&"type"===b&&"text"===c||"script"===a&&"charset"===b&&!k(d,"src")||"a"===a&&"name"===b&&k(d,"id")||"area"===a&&"shape"===b&&"rect"===c}function m(a,b,c){return"script"===a&&"type"===b&&"text/javascript"===S(c.toLowerCase())}function n(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){var f=S(b[c].value).split(/;/,2)[0].toLowerCase();return""===f||W(f)}}return!0}function o(a,b,c){return("style"===a||"link"===a)&&"type"===b&&"text/css"===S(c.toLowerCase())}function p(a,b){return X(a)||"draggable"===a&&!Y(b)}function q(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 r(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 s(a,b){if("link"!==a)return!1;for(var c=0,d=b.length;d>c;c++)if("rel"===b[c].name&&"canonical"===b[c].value)return!0}function t(a,c,d,e,f){if(d&&i(c,e)){if(d=S(d).replace(/^javascript:\s*/i,"").replace(/\s*;$/,""),e.minifyJS){var g=L(Z+d+$,e.minifyJS);return g.slice(Z.length,-$.length)}return d}return"class"===c?b(S(d)):q(c,a)?(d=S(d),e.minifyURLs&&!s(a,f)?K(d,e.minifyURLs):d):r(c,a)?S(d):"style"===c?(d=S(d),d&&(d=d.replace(/\s*;\s*$/,"")),e.minifyCSS?M(d,e.minifyCSS,!0):d):(u(a,f)&&"content"===c?d=d.replace(/\s+/g,"").replace(/[0-9]+\.[0-9]+/g,function(a){return(+a).toString()}):d&&e.customAttrCollapse&&e.customAttrCollapse.test(c)&&(d=d.replace(/\n+|\r+|\s{2,}/g,"")),d)}function u(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 v(a){return"*{"+a+"}"}function w(a){var b=a.match(/^\*\{([\s\S]*)\}$/m);return b&&b[1]?b[1]:a}function x(a,b){return a.replace(/^(\[if\s[^\]]+\]>)([\s\S]*?)(\s*\*\/|\/\/\s*\]\]>)\s*$/,"")}function z(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 O(a,b);return a}function A(a,b){return a.replace(_[b],"").replace(aa[b],"")}function B(a,b){switch(a){case"html":case"head":return!0;case"body":return!da(b);case"colgroup":return"col"===b;case"tbody":return"tr"===b}return!1}function C(a,b){switch(b){case"colgroup":return"colgroup"===a;case"tbody":return la(a)}return!1}function D(a,b){switch(a){case"html":case"head":case"body":case"colgroup":case"caption":return!0;case"li":case"optgroup":case"tr":return b===a;case"dt":case"dd":return ea(b);case"p":return fa(b);case"rb":case"rt":case"rp":return ha(b);case"rtc":return ia(b);case"option":return ja(b);case"thead":case"tbody":return ka(b);case"tfoot":return"tbody"===b;case"td":case"th":return ma(b)}return!1}function E(a,b,c){var d=!c||/^\s*$/.test(c);return d?"input"===a&&"value"===b||sa.test(b):!1}function F(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 G(a){return!/^(?:script|style|pre|textarea)$/.test(a)}function H(a){return!/^(?:pre|textarea)$/.test(a)}function I(a,b,c,d,e,f,g){var h,i,k=f.caseSensitive?a.name:a.name.toLowerCase(),n=a.value,q=a.quote;if(f.removeRedundantAttributes&&l(c,k,n,b)||f.removeScriptTypeAttributes&&m(c,k,n)||f.removeStyleLinkTypeAttributes&&o(c,k,n))return"";if(n=t(c,k,n,f,b),f.removeEmptyAttributes&&E(c,k,n))return"";if(void 0!==n&&!f.removeAttributeQuotes||!j(n)){if(!f.preventAttributesEscaping){if(void 0!==f.quoteCharacter)q="'"===f.quoteCharacter?"'":'"';else{var r=(n.match(/'/g)||[]).length,s=(n.match(/"/g)||[]).length;q=s>r?"'":'"'}n='"'===q?n.replace(/"/g,"""):n.replace(/'/g,"'")}i=q+n+q,g||f.removeTagWhitespace||(i+=" ")}else i=!g||d||/\/$/.test(n)?n+" ":n;return void 0===n||f.collapseBooleanAttributes&&p(k.toLowerCase(),n.toLowerCase())?(h=k,g||(h+=" ")):h=k+a.customAssign+i,a.customOpen+h+a.customClose}function J(a){for(var b=["canCollapseWhitespace","canTrimWhitespace"],c=0,d=b.length;d>c;c++)a[b[c]]||(a[b[c]]=function(){return!1})}function K(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){Q(e)}return b}function L(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){Q(j)}return b}function M(b,c,d){"object"!=typeof c&&(c={}),"undefined"==typeof c.advanced&&(c.advanced=!1);try{var e=a.CleanCSS;"undefined"==typeof e&&"function"==typeof require&&(e=require("clean-css"));var f=new e(c);return d?w(f.minify(v(b)).styles):f.minify(b).styles}catch(g){Q(g)}return b}function N(a){var b;do b=Math.random().toString(36).slice(2);while(~a.indexOf(b));return b}function O(a,c,d){function i(a,b){return G(a)||c.canCollapseWhitespace(a,b)}function j(a,b){return H(a)||c.canTrimWhitespace(a,b)}function k(){for(var a=t.length-1;a>0&&!/^<[^\/!]/.test(t[a]);)a--;t.length=Math.max(0,a)}function l(){for(var a=t.length-1;a>0&&!/^<\//.test(t[a]);)a--;t.length=Math.max(0,a)}function m(a){var b;t.length>1&&/^(?:0&&/\s+$/.test(t[t.length-1])&&(b=t.length-1),b>0&&(t[b]=t[b].replace(/\s+$/,function(b){return f(b,"comment",a,c)}))}c=c||{};var o=[];J(c),a=c.collapseWhitespace?S(a):a;var p,q,r,s,t=[],u="",v="",w=[],E=[],K=[],O="",T="",V=c.lint,W=Date.now(),X=[],Y=[];a=a.replace(/([\s\S]*?)/g,function(b,c){r||(r="");var d=r+X.length;return X.push(c),d});var Z=(c.ignoreCustomFragments||[/<%[\s\S]*?%>/,/<\?[\s\S]*?\?>/]).map(function(a){return a.source});if(Z.length){var $=new RegExp("\\s*(?:"+Z.join("|")+")+\\s*","g");a=a.replace($,function(b){s||(s=N(a));var c=s+Y.length;return Y.push(b)," "+c+" "})}new R(a,{partialMarkup:d,html5:"undefined"!=typeof c.html5?c.html5:!0,start:function(a,b,d,e){var f=a.toLowerCase();if("svg"===f){o.push(c);var g={};for(var h in c)g[h]=c[h];g.keepClosingSlash=!0,g.caseSensitive=!0,c=g}a=c.caseSensitive?a:f,v=a,p=a,U(a)||(u=""),q=!1,w=b;var n=c.removeOptionalTags;if(n){var r=ra(a);r&&B(O,a)&&k(),O="",r&&D(T,a)&&(l(),n=!C(T,a)),T=""}c.collapseWhitespace&&(E.length||m(a),j(a,b)||E.push(a),i(a,b)||K.push(a));var s="<"+a,x=e&&c.keepClosingSlash;t.push(s),V&&V.testElement(a);for(var y,z=[],A=!0,F=b.length;--F>=0;)V&&V.testAttribute(a,b[F].name.toLowerCase(),b[F].value),y=I(b[F],b,a,x,F,c,A),y&&(A=!1,z.unshift(y));z.length>0?(t.push(" "),t.push.apply(t,z)):n&&ba(a)&&(O=a),t.push(t.pop()+(x?"/":"")+">")},end:function(a,b){var d=a.toLowerCase();"svg"===d&&(c=o.pop()),a=c.caseSensitive?a:d,c.collapseWhitespace&&(E.length?a===E[E.length-1]&&E.pop():m("/"+a),K.length&&a===K[K.length-1]&&K.pop());var e=!1;a===v&&(v="",e=!q),c.removeOptionalTags&&(e&&na(O)&&k(),O="",!ra(a)||!T||qa(T)||"p"===T&&ga(a)||l(),T=ca(a)?a:""),c.removeEmptyElements&&e&&F(a,b)?(k(),O="",T=""):(t.push(""),p="/"+a,U(a)||(u=""))},chars:function(a,d,g){if(d=""===d?"comment":d,g=""===g?"comment":g,c.collapseWhitespace){if(!E.length){if("comment"===d){var h=""===t[t.length-1];if(h&&(d=p),t.length>1&&(h||/ $/.test(u))){var i=t.length-2;t[i]=t[i].replace(/\s+$/,function(b){return a=b+a,""})}}if(d&&U("/"===d.charAt(0)?d.slice(1):d)&&(a=e(a,c,/(?:^|\s)$/.test(u))),a=d||g?f(a,d,g,c):S(a),!a&&/\s$/.test(u)&&d&&"/"===d.charAt(0))for(var m=t.length-2,o=d.slice(1);m>=0&&j(o);m--){var r=t[m],s=r.match(/^<\/([\w:-]+)>$/);if(s)o=s[1];else if(/>$/.test(r)||(t[m]=f(r,null,g,c)))break}}K.length||(a=d&&g||"html"===g?a:b(a))}"script"!==v&&"style"!==v||(c.removeCommentsFromCDATA&&(a=A(a,v)),c.removeCDATASectionsFromCDATA&&(a=y(a)),c.processScripts&&(a=z(a,c,w))),c.minifyJS&&n(v,w)&&(a=L(a,c.minifyJS),";"===a.charAt(a.length-1)&&(a=a.slice(0,-1))),"style"===v&&c.minifyCSS&&(a=M(a,c.minifyCSS)),c.removeOptionalTags&&a&&(("html"===O||"body"===O&&!/^\s/.test(a))&&k(),O="",(oa(T)||pa(T)&&!/^\s/.test(a))&&l(),T=""),p=/^\s*$/.test(a)?d:"comment",u+=a,a&&(q=!0),V&&V.testChars(a),t.push(a)},comment:function(a,b){var d=b?"":"-->";a=g(a)?d+x(a,c)+e:c.removeComments?h(a,c)?"":"":d+a+e,c.removeOptionalTags&&a&&(O="",T=""),t.push(a)},doctype:function(a){t.push(c.useShortDoctype?"":b(a))},customAttrAssign:c.customAttrAssign,customAttrSurround:c.customAttrSurround}),c.removeOptionalTags&&(na(O)&&k(),T&&!qa(T)&&l());var _=P(t,c);return s&&(_=_.replace(new RegExp("(\\s*)"+s+"([0-9]+)(\\s*)","g"),function(a,b,d,f){var g=Y[+d];return c.collapseWhitespace?(" "!==b&&(g=b+g)," "!==f&&(g+=f),e(g,{preserveLineBreaks:c.preserveLineBreaks,conservativeCollapse:!0},/^\s/.test(g),/\s$/.test(g))):g})),r&&(_=_.replace(new RegExp(r+"([0-9]+)","g"),function(a,b){return X[+b]})),Q("minified in: "+(Date.now()-W)+"ms"),_}function P(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\s*$/,style:/\s*-->\s*$/},ba=d("html,head,body,colgroup,tbody"),ca=d("html,head,body,li,dt,dd,p,rb,rt,rtc,rp,optgroup,option,colgroup,caption,thead,tbody,tfoot,tr,td,th"),da=d("meta,link,script,style,template,noscript"),ea=d("dt,dd"),fa=d("address,article,aside,blockquote,details,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,main,menu,nav,ol,p,pre,section,table,ul"),ga=d("a,audio,del,ins,map,noscript,video"),ha=d("rb,rt,rtc,rp"),ia=d("rb,rtc,rp"),ja=d("option,optgroup"),ka=d("tbody,tfoot"),la=d("thead,tbody,tfoot"),ma=d("td,th"),na=d("html,head,body"),oa=d("html,body"),pa=d("head,colgroup,caption"),qa=d("dt,thead"),ra=d("a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,element,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,menu,menuitem,meta,meter,multicol,nav,nobr,noembed,noframes,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,pre,progress,q,rp,rt,rtc,ruby,s,samp,script,section,select,shadow,small,source,spacer,span,strike,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,xmp"),sa=new RegExp("^(?:class|id|style|title|lang|dir|on(?:focus|blur|change|click|dblclick|mouse(?:down|up|over|move|out)|key(?:press|down|up)))$");a.minify=function(a,b){return O(a,b)}}("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 deprecated <'+a+"> element"):b(a)?this.log.push('Found presentational <'+a+"> 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 <br> sequence. Try replacing it with styling.")},h.prototype.testAttribute=function(a,b,c){d(b)?this.log.push('Found event attribute ('+b+") on <"+a+"> element."):f(a,b)?this.log.push('Found deprecated '+b+" attribute on <"+a+"> element."):e(b)?this.log.push('Found style attribute on <'+a+"> element."):g(b,c)&&this.log.push('Found inaccessible attribute (on <'+a+"> element).")},h.prototype.testChars=function(a){this._lastElement="",/( \s*){2,}/.test(a)&&this.log.push("Found repeating &nbsp; 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="
  1. "+this.log.join("
  2. ")+"
";else{var b=" - "+this.log.join("\n - ").replace(/(<([^>]+)>)/gi,"").replace(/</g,"<").replace(/>/g,">");console.log(b)}},a.HTMLLint=h}("undefined"==typeof exports?this:exports); \ No newline at end of file +!function(a){"use strict";function b(a){var b,c=new RegExp("[\\w:\\.-]+(?:\\s*(?:"+d(a)+")\\s*(?:\"[^\"]*\"+?|'[^']*'+?|[^>\\s\"']+?))?");if(a.customAttrSurround){for(var e=[],f=a.customAttrSurround.length-1;f>=0;f--)e[f]="(?:"+a.customAttrSurround[f][0].source+"\\s*"+c.source+"\\s*"+a.customAttrSurround[f][1].source+")";e.unshift("(?:"+c.source+")"),b=new RegExp("((?:\\s*(?:"+e.join("|")+"))*)")}else b=new RegExp("((?:\\s*"+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+")\\s*"+b.source+"\\s*("+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\s]+)/.source],j=/^<([\w:-]+)/,k=/\s*(\/?)>/,l=/^<\/([\w:-]+)[^>]*>/,m=/\/>$/,n=/^]+>/i,o=!1;"x".replace(/x(.)?/g,function(a,b){o=""===b});var p=e("area,base,basefont,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),q=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"),r=e("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),s=e("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),t=e("script,style"),u={},v=a.HTMLParser=function(a,d){function e(a,b,c,e){for(var h=!1;!d.html5&&g&&q[g];)f("",g);r[b]&&g===b&&f("",b),e=p[b]||"html"===b&&"head"===g||!!e;var i=[];c.replace(w,function(){var a,b,c,e,f,g,h,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&&(h=arguments[0].charAt(a.length+g.length),h="'"===h||'"'===h?h:"");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=s[a]?a:c),i.push({name:a,value:b,customAssign:g||"=",customOpen:e||"",customClose:f||"",quote:h||""})}),e?h=a.match(m):(k.push({tag:b,attrs:i}),g=b),d.start&&d.start(b,i,e,h)}function f(a,b){var c;if(b){var e=b.toLowerCase();for(c=k.length-1;c>=0&&k[c].tag.toLowerCase()!==e;c--);}else c=0;if(c>=0){for(var f=k.length-1;f>=c;f--)d.end&&d.end(k[f].tag,k[f].attrs);k.length=c,g=c&&k[c-1].tag}}for(var g,h,i,j,k=[],v=b(d),w=c(d);a;){if(h=a,g&&t[g]){var x=g.toLowerCase(),y=u[x]||(u[x]=new RegExp("([\\s\\S]*?)]*>","i"));a=a.replace(y,function(a,b){return"script"!==x&&"style"!==x&&"noscript"!==x&&(b=b.replace(//g,"$1").replace(//g,"$1")),d.chars&&d.chars(b),""}),f("",x)}else{var z=a.indexOf("<");if(0===z){if(/^");if(A>=0){d.comment&&d.comment(a.substring(4,A)),a=a.substring(A+3),i="";continue}}if(/^");if(B>=0){d.comment&&d.comment(a.substring(2,B+1),!0),a=a.substring(B+2),i="";continue}}var C=a.match(n);if(C){d.doctype&&d.doctype(C[0]),a=a.substring(C[0].length),i="";continue}var D=a.match(l);if(D){a=a.substring(D[0].length),D[0].replace(l,f),i="/"+D[1].toLowerCase();continue}var E=a.match(v);if(E){a=a.substring(E[0].length),E[0].replace(v,e),i=E[1].toLowerCase();continue}}var F;z>=0?(F=a.substring(0,z),a=a.substring(z)):(F=a,a="");var G=a.match(v);G?j=G[1]:(G=a.match(l),j=G?"/"+G[1]:""),d.chars&&d.chars(F,i,j),i=""}if(a===h)throw"Parse Error: "+a}d.partialMarkup||f()};a.HTMLtoXML=function(a){var b="";return new v(a,{start:function(a,c,d){b+="<"+a;for(var e=0;e"},end:function(a){b+=""},chars:function(a){b+=a},comment:function(a){b+=""},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 v(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){var b={};return a.forEach(function(a){b[a]=1}),function(a){return 1===b[a]}}function d(a){return c(a.split(/,/))}function e(a,c,d,e,f){var g="",h="";return c.preserveLineBreaks&&(a=a.replace(/^[\t ]*[\n\r][\t\n\r ]*/,function(){return g="\n",""}).replace(/[\t\n\r ]*[\n\r][\t ]*$/,function(){return h="\n",""})),d&&(a=a.replace(/^\s+/,!g&&c.conservativeCollapse?" ":"")),e&&(a=a.replace(/\s+$/,!h&&c.conservativeCollapse?" ":"")),f&&(a=b(a)),g+a+h}function f(a,b,c,d){var f=b&&!V(b);f&&!d.collapseInlineTagWhitespace&&(f="/"===b.charAt(0)?!T(b.slice(1)):!U(b));var g=c&&!V(c);return g&&!d.collapseInlineTagWhitespace&&(g="/"===c.charAt(0)?!U(c.slice(1)):!T(c)),e(a,d,f,g,b&&c)}function g(a){return/^\[if\s[^\]]+\]|\[endif\]$/.test(a)}function h(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 i(a,b){var c=b.customEventAttributes;if(c){for(var d=c.length;d--;)if(c[d].test(a))return!0;return!1}return/^on[a-z]{3,}$/.test(a)}function j(a){return/^[^\x20\t\n\f\r"'`=<>]+$/.test(a)}function k(a,b){for(var c=a.length;c--;)if(a[c].name.toLowerCase()===b)return!0;return!1}function l(a,b,c,d){return c=c?S(c.toLowerCase()):"","script"===a&&"language"===b&&"javascript"===c||"form"===a&&"method"===b&&"get"===c||"input"===a&&"type"===b&&"text"===c||"script"===a&&"charset"===b&&!k(d,"src")||"a"===a&&"name"===b&&k(d,"id")||"area"===a&&"shape"===b&&"rect"===c}function m(a,b,c){return"script"===a&&"type"===b&&"text/javascript"===S(c.toLowerCase())}function n(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){var f=S(b[c].value).split(/;/,2)[0].toLowerCase();return""===f||W(f)}}return!0}function o(a,b,c){return("style"===a||"link"===a)&&"type"===b&&"text/css"===S(c.toLowerCase())}function p(a,b){return X(a)||"draggable"===a&&!Y(b)}function q(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 r(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 s(a,b){if("link"!==a)return!1;for(var c=0,d=b.length;d>c;c++)if("rel"===b[c].name&&"canonical"===b[c].value)return!0}function t(a,c,d,e,f){if(d&&i(c,e)){if(d=S(d).replace(/^javascript:\s*/i,"").replace(/\s*;$/,""),e.minifyJS){var g=L(Z+d+$,e.minifyJS);return g.slice(Z.length,-$.length)}return d}return"class"===c?b(S(d)):q(c,a)?(d=S(d),e.minifyURLs&&!s(a,f)?K(d,e.minifyURLs):d):r(c,a)?S(d):"style"===c?(d=S(d),d&&(d=d.replace(/\s*;\s*$/,"")),e.minifyCSS?M(d,e.minifyCSS,!0):d):(u(a,f)&&"content"===c?d=d.replace(/\s+/g,"").replace(/[0-9]+\.[0-9]+/g,function(a){return(+a).toString()}):d&&e.customAttrCollapse&&e.customAttrCollapse.test(c)&&(d=d.replace(/\n+|\r+|\s{2,}/g,"")),d)}function u(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 v(a){return"*{"+a+"}"}function w(a){var b=a.match(/^\*\{([\s\S]*)\}$/m);return b&&b[1]?b[1]:a}function x(a,b){return a.replace(/^(\[if\s[^\]]+\]>)([\s\S]*?)(\s*\*\/|\/\/\s*\]\]>)\s*$/,"")}function z(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 O(a,b);return a}function A(a,b){return a.replace(_[b],"").replace(aa[b],"")}function B(a,b){switch(a){case"html":case"head":return!0;case"body":return!da(b);case"colgroup":return"col"===b;case"tbody":return"tr"===b}return!1}function C(a,b){switch(b){case"colgroup":return"colgroup"===a;case"tbody":return la(a)}return!1}function D(a,b){switch(a){case"html":case"head":case"body":case"colgroup":case"caption":return!0;case"li":case"optgroup":case"tr":return b===a;case"dt":case"dd":return ea(b);case"p":return fa(b);case"rb":case"rt":case"rp":return ha(b);case"rtc":return ia(b);case"option":return ja(b);case"thead":case"tbody":return ka(b);case"tfoot":return"tbody"===b;case"td":case"th":return ma(b)}return!1}function E(a,b,c){var d=!c||/^\s*$/.test(c);return d?"input"===a&&"value"===b||sa.test(b):!1}function F(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 G(a){return!/^(?:script|style|pre|textarea)$/.test(a)}function H(a){return!/^(?:pre|textarea)$/.test(a)}function I(a,b,c,d,e,f,g){var h,i,k=f.caseSensitive?a.name:a.name.toLowerCase(),n=a.value,q=a.quote;if(f.removeRedundantAttributes&&l(c,k,n,b)||f.removeScriptTypeAttributes&&m(c,k,n)||f.removeStyleLinkTypeAttributes&&o(c,k,n))return"";if(n=t(c,k,n,f,b),f.removeEmptyAttributes&&E(c,k,n))return"";if(void 0!==n&&!f.removeAttributeQuotes||!j(n)){if(!f.preventAttributesEscaping){if(void 0!==f.quoteCharacter)q="'"===f.quoteCharacter?"'":'"';else{var r=(n.match(/'/g)||[]).length,s=(n.match(/"/g)||[]).length;q=s>r?"'":'"'}n='"'===q?n.replace(/"/g,"""):n.replace(/'/g,"'")}i=q+n+q,g||f.removeTagWhitespace||(i+=" ")}else i=!g||d||/\/$/.test(n)?n+" ":n;return void 0===n||f.collapseBooleanAttributes&&p(k.toLowerCase(),n.toLowerCase())?(h=k,g||(h+=" ")):h=k+a.customAssign+i,a.customOpen+h+a.customClose}function J(a){for(var b=["canCollapseWhitespace","canTrimWhitespace"],c=0,d=b.length;d>c;c++)a[b[c]]||(a[b[c]]=function(){return!1})}function K(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){Q(e)}return b}function L(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){Q(j)}return b}function M(b,c,d){"object"!=typeof c&&(c={}),"undefined"==typeof c.advanced&&(c.advanced=!1);try{var e=a.CleanCSS;"undefined"==typeof e&&"function"==typeof require&&(e=require("clean-css"));var f=new e(c);return d?w(f.minify(v(b)).styles):f.minify(b).styles}catch(g){Q(g)}return b}function N(a){var b;do b=Math.random().toString(36).slice(2);while(~a.indexOf(b));return b}function O(a,c,d){function i(a,b){return G(a)||c.canCollapseWhitespace(a,b)}function j(a,b){return H(a)||c.canTrimWhitespace(a,b)}function k(){for(var a=t.length-1;a>0&&!/^<[^\/!]/.test(t[a]);)a--;t.length=Math.max(0,a)}function l(){for(var a=t.length-1;a>0&&!/^<\//.test(t[a]);)a--;t.length=Math.max(0,a)}function m(a){var b;t.length>1&&/^(?:0&&/\s$/.test(t[t.length-1])&&(b=t.length-1),b>0&&(t[b]=t[b].replace(/\s+$/,function(b){return f(b,"comment",a,c)}))}c=c||{};var o=[];J(c),a=c.collapseWhitespace?S(a):a;var p,q,r,s,t=[],u="",v="",w=[],E=[],K=[],O="",T="",V=c.lint,W=Date.now(),X=[],Y=[];a=a.replace(/([\s\S]*?)/g,function(b,c){r||(r="");var d=r+X.length;return X.push(c),d});var Z=(c.ignoreCustomFragments||[/<%[\s\S]*?%>/,/<\?[\s\S]*?\?>/]).map(function(a){return a.source});if(Z.length){var $=new RegExp("\\s*(?:"+Z.join("|")+")+\\s*","g");a=a.replace($,function(b){s||(s=N(a));var c=s+Y.length;return Y.push(b)," "+c+" "})}new R(a,{partialMarkup:d,html5:"undefined"!=typeof c.html5?c.html5:!0,start:function(a,b,d,e){var f=a.toLowerCase();if("svg"===f){o.push(c);var g={};for(var h in c)g[h]=c[h];g.keepClosingSlash=!0,g.caseSensitive=!0,c=g}a=c.caseSensitive?a:f,v=a,p=a,U(a)||(u=""),q=!1,w=b;var n=c.removeOptionalTags;if(n){var r=ra(a);r&&B(O,a)&&k(),O="",r&&D(T,a)&&(l(),n=!C(T,a)),T=""}c.collapseWhitespace&&(E.length||m(a),j(a,b)||E.push(a),i(a,b)||K.push(a));var s="<"+a,x=e&&c.keepClosingSlash;t.push(s),V&&V.testElement(a);for(var y,z=[],A=!0,F=b.length;--F>=0;)V&&V.testAttribute(a,b[F].name.toLowerCase(),b[F].value),y=I(b[F],b,a,x,F,c,A),y&&(A=!1,z.unshift(y));z.length>0?(t.push(" "),t.push.apply(t,z)):n&&ba(a)&&(O=a),t.push(t.pop()+(x?"/":"")+">")},end:function(a,b){var d=a.toLowerCase();"svg"===d&&(c=o.pop()),a=c.caseSensitive?a:d,c.collapseWhitespace&&(E.length?a===E[E.length-1]&&E.pop():m("/"+a),K.length&&a===K[K.length-1]&&K.pop());var e=!1;a===v&&(v="",e=!q),c.removeOptionalTags&&(e&&na(O)&&k(),O="",!ra(a)||!T||qa(T)||"p"===T&&ga(a)||l(),T=ca(a)?a:""),c.removeEmptyElements&&e&&F(a,b)?(k(),O="",T=""):(t.push(""),p="/"+a,U(a)||(u=""))},chars:function(a,d,g){if(d=""===d?"comment":d,g=""===g?"comment":g,c.collapseWhitespace){if(!E.length){if("comment"===d){var h=""===t[t.length-1];if(h&&(d=p),t.length>1&&(h||/ $/.test(u))){var i=t.length-2;t[i]=t[i].replace(/\s+$/,function(b){return a=b+a,""})}}if(d&&U("/"===d.charAt(0)?d.slice(1):d)&&(a=e(a,c,/(?:^|\s)$/.test(u))),a=d||g?f(a,d,g,c):S(a),!a&&/\s$/.test(u)&&d&&"/"===d.charAt(0))for(var m=t.length-2,o=d.slice(1);m>=0&&j(o);m--){var r=t[m],s=r.match(/^<\/([\w:-]+)>$/);if(s)o=s[1];else if(/>$/.test(r)||(t[m]=f(r,null,g,c)))break}}K.length||(a=d&&g||"html"===g?a:b(a))}"script"!==v&&"style"!==v||(c.removeCommentsFromCDATA&&(a=A(a,v)),c.removeCDATASectionsFromCDATA&&(a=y(a)),c.processScripts&&(a=z(a,c,w))),c.minifyJS&&n(v,w)&&(a=L(a,c.minifyJS),";"===a.charAt(a.length-1)&&(a=a.slice(0,-1))),"style"===v&&c.minifyCSS&&(a=M(a,c.minifyCSS)),c.removeOptionalTags&&a&&(("html"===O||"body"===O&&!/^\s/.test(a))&&k(),O="",(oa(T)||pa(T)&&!/^\s/.test(a))&&l(),T=""),p=/^\s*$/.test(a)?d:"comment",u+=a,a&&(q=!0),V&&V.testChars(a),t.push(a)},comment:function(a,b){var d=b?"":"-->";a=g(a)?d+x(a,c)+e:c.removeComments?h(a,c)?"":"":d+a+e,c.removeOptionalTags&&a&&(O="",T=""),t.push(a)},doctype:function(a){t.push(c.useShortDoctype?"":b(a))},customAttrAssign:c.customAttrAssign,customAttrSurround:c.customAttrSurround}),c.removeOptionalTags&&(na(O)&&k(),T&&!qa(T)&&l());var _=P(t,c);return s&&(_=_.replace(new RegExp("(\\s*)"+s+"([0-9]+)(\\s*)","g"),function(a,b,d,f){var g=Y[+d];return c.collapseWhitespace?(" "!==b&&(g=b+g)," "!==f&&(g+=f),e(g,{preserveLineBreaks:c.preserveLineBreaks,conservativeCollapse:!0},/^\s/.test(g),/\s$/.test(g))):g})),r&&(_=_.replace(new RegExp(r+"([0-9]+)","g"),function(a,b){return X[+b]})),Q("minified in: "+(Date.now()-W)+"ms"),_}function P(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\s*$/,style:/\s*-->\s*$/},ba=d("html,head,body,colgroup,tbody"),ca=d("html,head,body,li,dt,dd,p,rb,rt,rtc,rp,optgroup,option,colgroup,caption,thead,tbody,tfoot,tr,td,th"),da=d("meta,link,script,style,template,noscript"),ea=d("dt,dd"),fa=d("address,article,aside,blockquote,details,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,main,menu,nav,ol,p,pre,section,table,ul"),ga=d("a,audio,del,ins,map,noscript,video"),ha=d("rb,rt,rtc,rp"),ia=d("rb,rtc,rp"),ja=d("option,optgroup"),ka=d("tbody,tfoot"),la=d("thead,tbody,tfoot"),ma=d("td,th"),na=d("html,head,body"),oa=d("html,body"),pa=d("head,colgroup,caption"),qa=d("dt,thead"),ra=d("a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,element,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,menu,menuitem,meta,meter,multicol,nav,nobr,noembed,noframes,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,pre,progress,q,rp,rt,rtc,ruby,s,samp,script,section,select,shadow,small,source,spacer,span,strike,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,xmp"),sa=new RegExp("^(?:class|id|style|title|lang|dir|on(?:focus|blur|change|click|dblclick|mouse(?:down|up|over|move|out)|key(?:press|down|up)))$");a.minify=function(a,b){return O(a,b)}}("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 deprecated <'+a+"> element"):b(a)?this.log.push('Found presentational <'+a+"> 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 <br> sequence. Try replacing it with styling.")},h.prototype.testAttribute=function(a,b,c){d(b)?this.log.push('Found event attribute ('+b+") on <"+a+"> element."):f(a,b)?this.log.push('Found deprecated '+b+" attribute on <"+a+"> element."):e(b)?this.log.push('Found style attribute on <'+a+"> element."):g(b,c)&&this.log.push('Found inaccessible attribute (on <'+a+"> element).")},h.prototype.testChars=function(a){this._lastElement="",/( \s*){2,}/.test(a)&&this.log.push("Found repeating &nbsp; 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="
  1. "+this.log.join("
  2. ")+"
";else{var b=" - "+this.log.join("\n - ").replace(/(<([^>]+)>)/gi,"").replace(/</g,"<").replace(/>/g,">");console.log(b)}},a.HTMLLint=h}("undefined"==typeof exports?this:exports); \ No newline at end of file diff --git a/src/htmlminifier.js b/src/htmlminifier.js index b94e6aee..9eabd4e5 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -786,10 +786,10 @@ function squashTrailingWhitespace(nextTag) { var charsIndex; - if (buffer.length > 1 && /^(?: 1 && /^(?: 0 && /\s+$/.test(buffer[buffer.length - 1])) { + else if (buffer.length > 0 && /\s$/.test(buffer[buffer.length - 1])) { charsIndex = buffer.length - 1; } if (charsIndex > 0) { From c0f4b84867851e647fabe35ad16909a476b40e91 Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Thu, 3 Mar 2016 01:49:49 +0800 Subject: [PATCH 4/4] clarify squashTrailingWhitespace() --- dist/htmlminifier.js | 6 +++++- src/htmlminifier.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dist/htmlminifier.js b/dist/htmlminifier.js index 6a5879a6..377e3d35 100644 --- a/dist/htmlminifier.js +++ b/dist/htmlminifier.js @@ -1324,9 +1324,13 @@ buffer.length = Math.max(0, index); } + // look for trailing whitespaces from previously processed text + // which may not be trimmed due to a following comment or an empty + // element which has now been removed function squashTrailingWhitespace(nextTag) { var charsIndex; - if (buffer.length > 1 && /^(?: 1 && /^(?: 0 && /\s$/.test(buffer[buffer.length - 1])) { diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 9eabd4e5..3298cd2d 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -784,9 +784,13 @@ buffer.length = Math.max(0, index); } + // look for trailing whitespaces from previously processed text + // which may not be trimmed due to a following comment or an empty + // element which has now been removed function squashTrailingWhitespace(nextTag) { var charsIndex; - if (buffer.length > 1 && /^(?: 1 && /^(?: 0 && /\s$/.test(buffer[buffer.length - 1])) {