Skip to content

Commit

Permalink
feat(text) clean space in html using htmlclean #78
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore committed Jan 4, 2015
1 parent 5c9681c commit 7887395
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"css": "~1.4.0",
"css2str": "~0.1.1",
"handlebars": "1.0.11",
"htmlclean": "~2.2.3",
"relative": "~1.2.0",
"uglify-js": "~2.2.5"
},
Expand Down
8 changes: 2 additions & 6 deletions tasks/lib/text.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var htmlclean = require('htmlclean');
var commonParser = require('./common');

exports.init = function(grunt) {
Expand All @@ -8,11 +9,6 @@ exports.init = function(grunt) {
};

function getCode(data) {
data = data.split(/\r\n|\r|\n/)
.map(function(line) {
return line.replace(/\\/g, '\\\\');
})
.join('\n')
.replace(/\"/g, '\\\"');
data = htmlclean(data).replace(/(\"|\'|\\)/g, '\\$1');
return '"' + data + '"';
}
2 changes: 1 addition & 1 deletion test/cases/project/a-2cee5097.html.js.expect
Original file line number Diff line number Diff line change
@@ -1 +1 @@
define("family/name/a-2cee5097.html", [], "<div>\n <ul>\n <li> a </li>\n <ul>\n </div>\n");
define("family/name/a-2cee5097.html", [], "<div><ul><li> a</li><ul></div>");
2 changes: 1 addition & 1 deletion test/cases/text/foo-debug.html.js.expect
Original file line number Diff line number Diff line change
@@ -1 +1 @@
define("foo-debug.html", [], "<div>foo / bar \\ baz</div>\n");
define("foo-debug.html", [], "<div><p>\\n The <strong>'clean' <span><em>\\ \"HTML is here.\" /</em></span></strong></p></div>");
6 changes: 5 additions & 1 deletion test/cases/text/foo.html
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<div>foo / bar \ baz</div>
<div>
<p>\n
The <strong> 'clean' <span> <em> \ "HTML is here." / </em> </span> </strong> </p>

</div>
2 changes: 1 addition & 1 deletion test/cases/text/foo.html.js.expect
Original file line number Diff line number Diff line change
@@ -1 +1 @@
define("foo.html", [], "<div>foo / bar \\ baz</div>\n");
define("foo.html", [], "<div><p>\\n The <strong>'clean' <span><em>\\ \"HTML is here.\" /</em></span></strong></p></div>");

0 comments on commit 7887395

Please sign in to comment.