From: Tunghsiao Liu Date: Wed, 6 Nov 2013 17:27:30 +0000 (+0800) Subject: Add space around time tag X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=ac2243772d13240a80f7126618e5ef347958edeb;p=html-minifier.git Add space around time tag --- diff --git a/dist/all.js b/dist/all.js index 1ca5b9a..844e217 100644 --- a/dist/all.js +++ b/dist/all.js @@ -408,7 +408,7 @@ function collapseWhitespaceSmart(str, prevTag, nextTag) { // array of tags that will maintain a single space outside of them - var tags = ['a', 'abbr', 'acronym', 'b', 'big', 'button', 'code', 'del', 'dfn', 'em', 'font', 'i', 'ins', 'kbd', 'mark', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'tt', 'u', 'var']; + var tags = ['a', 'abbr', 'acronym', 'b', 'big', 'button', 'code', 'del', 'dfn', 'em', 'font', 'i', 'ins', 'kbd', 'mark', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'time', 'tt', 'u', 'var']; if (prevTag && prevTag !== 'img' && (prevTag.substr(0,1) !== '/' || ( prevTag.substr(0,1) === '/' && tags.indexOf(prevTag.substr(1)) === -1))) { @@ -422,7 +422,7 @@ if (prevTag && nextTag) { // strip non space whitespace then compress spaces to one - return str.replace(/[\t\n\r]+/g, '').replace(/[ ]+/g, ' '); + return str.replace(/[\t\n\r]+/g, ' ').replace(/[ ]+/g, ' '); } return str; diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 666001f..7c9804b 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -42,7 +42,7 @@ function collapseWhitespaceSmart(str, prevTag, nextTag) { // array of tags that will maintain a single space outside of them - var tags = ['a', 'abbr', 'acronym', 'b', 'big', 'button', 'code', 'del', 'dfn', 'em', 'font', 'i', 'ins', 'kbd', 'mark', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'tt', 'u', 'var']; + var tags = ['a', 'abbr', 'acronym', 'b', 'big', 'button', 'code', 'del', 'dfn', 'em', 'font', 'i', 'ins', 'kbd', 'mark', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'time', 'tt', 'u', 'var']; if (prevTag && prevTag !== 'img' && (prevTag.substr(0,1) !== '/' || ( prevTag.substr(0,1) === '/' && tags.indexOf(prevTag.substr(1)) === -1))) { diff --git a/tests/minifier.js b/tests/minifier.js index 92cc1d5..1c8cf55 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -77,7 +77,7 @@ test('space normalization around text', function(){ equal(minify('

blah

\n\n\n '), '

blah

'); // tags from collapseWhitespaceSmart() - ['a', 'b', 'big', 'button', 'code', 'em', 'font', 'i', 'kbd', 'mark', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'tt', 'u'].forEach(function(el){ + ['a', 'b', 'big', 'button', 'code', 'em', 'font', 'i', 'kbd', 'mark', 'q', 's', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'time', 'tt', 'u'].forEach(function(el){ equal(minify('

foo <'+el+'>baz bar

', {collapseWhitespace: true}), '

foo <'+el+'>baz bar

'); equal(minify('

foo<'+el+'>bazbar

', {collapseWhitespace: true}), '

foo<'+el+'>bazbar

'); equal(minify('

foo <'+el+'>bazbar

', {collapseWhitespace: true}), '

foo <'+el+'>bazbar

'); @@ -695,21 +695,21 @@ // https://github.com/kangax/html-minifier/issues/10 test('Ignored tags: enabled by default', function() { - + input = 'This is the start. <% ... %>\r\n<%= ... %>\r\n\r\n\r\nNo comment, but middle.\r\n\r\n\r\n\r\nHello, this is the end!'; output = 'This is the start.<% ... %><%= ... %>No comment, but middle.Hello, this is the end!'; equal(minify(input, {}), input); equal(minify(input, { removeComments: true, collapseWhitespace: true }), output); output = 'This is the start.No comment, but middle.Hello, this is the end!'; equal(minify(input, { removeComments: true, collapseWhitespace: true, removeIgnored: true }), output); - + input = '<% if foo? %>\r\n
\r\n ...\r\n
\r\n<% end %>'; output = '<% if foo? %>
...
<% end %>'; equal(minify(input, {}), input); equal(minify(input, { collapseWhitespace: true }), output); output = '
...
'; equal(minify(input, { collapseWhitespace: true, removeIgnored: true }), output); - + }); })(typeof exports === 'undefined' ? window : exports);