From 794fd07300c4280921034faa2f9f3a91e081c4bd Mon Sep 17 00:00:00 2001 From: kangax Date: Sun, 12 May 2013 13:17:50 -0400 Subject: [PATCH] Version 0.5.1 --- dist/all.js | 14 +++++++------- package.json | 2 +- src/htmlminifier.js | 14 +++++++------- tests/minifier.js | 3 +++ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/dist/all.js b/dist/all.js index a463710..311287f 100644 --- a/dist/all.js +++ b/dist/all.js @@ -337,7 +337,7 @@ } })(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 @@ -377,26 +377,26 @@ 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; } diff --git a/package.json b/package.json index a7acf2e..bef4b49 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "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": [{ diff --git a/src/htmlminifier.js b/src/htmlminifier.js index ff4fe7d..d86268e 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -1,5 +1,5 @@ /*! - * HTMLMinifier v0.5.0 + * HTMLMinifier v0.5.1 * http://kangax.github.com/html-minifier/ * * Copyright (c) 2010-2013 Juriy "kangax" Zaytsev @@ -39,26 +39,26 @@ 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; } diff --git a/tests/minifier.js b/tests/minifier.js index bdb992f..ca843f2 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -43,6 +43,9 @@ // https://github.com/kangax/html-minifier/issues/21 equal(minify('
hey
'), '
hey
'); + + // https://github.com/kangax/html-minifier/issues/17 + equal(minify(':) link'), ':) link'); }); test('`minifiy` exists', function() { -- 2.34.1