}
})(typeof exports === 'undefined' ? this : exports);
/*!
- * HTMLMinifier v0.5.0
+ * HTMLMinifier v0.5.1
* http://kangax.github.com/html-minifier/
*
* Copyright (c) 2010-2013 Juriy "kangax" Zaytsev
function collapseWhitespace(str) {
return str.replace(/\s+/g, ' ');
}
-
+
function collapseWhitespaceSmart(str, prevTag, nextTag) {
// array of tags that will maintain a single space outside of them
var tags = ['a', 'b', 'big', 'button', 'em', 'font','i', 'img', 'mark', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'tt', 'u'];
-
+
if (prevTag && (prevTag.substr(0,1) !== '/'
|| ( prevTag.substr(0,1) === '/' && tags.indexOf(prevTag.substr(1)) === -1))) {
str = str.replace(/^\s+/, '');
}
-
+
if (nextTag && (nextTag.substr(0,1) === '/'
|| ( nextTag.substr(0,1) !== '/' && tags.indexOf(nextTag) === -1))) {
str = str.replace(/\s+$/, '');
- }
-
+ }
+
if (prevTag && nextTag) {
// strip non space whitespace then compress spaces to one
return str.replace(/[\t\n\r]+/g, '').replace(/[ ]+/g, ' ');
}
-
+
return str;
}
{
"name": "html-minifier",
"description": "HTML minifier with lint-like capabilities.",
- "version": "0.5.0",
+ "version": "0.5.1",
"keywords": ["html", "minifier", "lint"],
"url" : "http://github.com/kangax/html-minifier",
"maintainers": [{
/*!
- * HTMLMinifier v0.5.0
+ * HTMLMinifier v0.5.1
* http://kangax.github.com/html-minifier/
*
* Copyright (c) 2010-2013 Juriy "kangax" Zaytsev
function collapseWhitespace(str) {
return str.replace(/\s+/g, ' ');
}
-
+
function collapseWhitespaceSmart(str, prevTag, nextTag) {
// array of tags that will maintain a single space outside of them
var tags = ['a', 'b', 'big', 'button', 'em', 'font','i', 'img', 'mark', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'tt', 'u'];
-
+
if (prevTag && (prevTag.substr(0,1) !== '/'
|| ( prevTag.substr(0,1) === '/' && tags.indexOf(prevTag.substr(1)) === -1))) {
str = str.replace(/^\s+/, '');
}
-
+
if (nextTag && (nextTag.substr(0,1) === '/'
|| ( nextTag.substr(0,1) !== '/' && tags.indexOf(nextTag) === -1))) {
str = str.replace(/\s+$/, '');
- }
-
+ }
+
if (prevTag && nextTag) {
// strip non space whitespace then compress spaces to one
return str.replace(/[\t\n\r]+/g, '').replace(/[ ]+/g, ' ');
}
-
+
return str;
}
// https://github.com/kangax/html-minifier/issues/21
equal(minify('<a href="test.html"><div>hey</div></a>'), '<a href="test.html"><div>hey</div></a>');
+
+ // https://github.com/kangax/html-minifier/issues/17
+ equal(minify(':) <a href="http://example.com">link</a>'), ':) <a href="http://example.com">link</a>');
});
test('`minifiy` exists', function() {