minimize
Advanced tools
Comparing version 0.7.3 to 0.7.4
@@ -13,2 +13,3 @@ 'use strict'; | ||
var conditional = /\[if.+IE[\s\d]*\]>.+<\!\[endif\]/g | ||
, ssi = /^\W*\#.*/g | ||
, retain = /data|itemscope/ | ||
@@ -26,2 +27,3 @@ , cdataStart = /\/*<!\[CDATA\[/g | ||
conditionals: false, // remove(false) or retain(true) ie conditional comments | ||
ssi: false, // remove(false) or retain(true) server side includes | ||
spare: false, // remove(false) or retain(true) redundant attributes | ||
@@ -229,2 +231,5 @@ quotes: false // remove(false) or retain(true) quotes if not required | ||
} | ||
if(this.config.ssi && ssi.test(element.data)) { | ||
return '<!--' + element.data + '-->'; | ||
} | ||
@@ -231,0 +236,0 @@ return !this.config.comments ? '' : '<!--' + element.data + '-->'; |
{ | ||
"name": "minimize", | ||
"version": "0.7.3", | ||
"version": "0.7.4", | ||
"description": "Minimize HTML", | ||
"main": "./lib/minimize", | ||
"scripts": { | ||
"test": "NODE_ENV=test ./node_modules/.bin/mocha $(shell find test -name '*.test.js')", | ||
"test": "NODE_ENV=test ./node_modules/.bin/mocha $(find test -name '*.test.js')", | ||
"coverage": "NODE_ENV=test ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js || true && rm -rf ./coverage" | ||
@@ -9,0 +9,0 @@ }, |
@@ -41,2 +41,3 @@ # HTML minifier [![Build Status][status]](https://travis-ci.org/Moveo/minimize) [![NPM version][npmimgurl]](http://npmjs.org/package/minimize) [![Coverage Status][coverage]](http://coveralls.io/r/Moveo/minimize?branch=master) | ||
comments: true, // DO NOT remove comments | ||
ssi: true, // DO NOT remove Server Side Includes (i.e. <!--#include virtual="../quote.txt" -->) | ||
conditionals: true, // DO NOT remove conditional internet explorer comments | ||
@@ -43,0 +44,0 @@ spare: true, // DO NOT remove redundant attributes |
{ | ||
"content": "<div class=\"slide nodejs\">\n <h3>100% Node.js</h3>\n <p>\n We are Node.js experts and the first hosting platform to build\n our full stack in node. We understand your node application\n better than anyone.\n </p>\n </div>\n\n ", | ||
"comment": "<!-- some HTML comment -->\n <div class=\"slide nodejs\">\n <h3>100% Node.js</h3>\n <p>\n We are Node.js experts and the first hosting platform to build\n our full stack in node. We understand your node application\n better than anyone.\n </p>\n </div>\n\n ", | ||
"comment": "<!-- some HTML comment --><!--#include virtual=\"/header.html\" -->\n <div class=\"slide nodejs\">\n <h3>100% Node.js</h3>\n <p>\n We are Node.js experts and the first hosting platform to build\n our full stack in node. We understand your node application\n better than anyone.\n </p>\n </div>\n\n ", | ||
"ie": "<!--[if IE 6]>Special instructions for IE 6 here<![endif]-->\n <div class=\"slide nodejs\">\n <h3>100% Node.js</h3>\n </div>", | ||
@@ -5,0 +5,0 @@ "interpunction": "<h3>Become a partner</h3>\n <p>\n Interested in being part of the solution?\n <a href=\"/company/contact\">Contact Nodejitsu to discuss</a>.\n </p>", |
@@ -80,3 +80,3 @@ 'use strict'; | ||
commentable.parse(html.comment, function (error, result) { | ||
expect(result).to.equal('<!-- some HTML comment --><div class=\"slide nodejs\"><h3>100% Node.js</h3><p>We are Node.js experts and the first hosting platform to build our full stack in node. We understand your node application better than anyone.</p></div>'); | ||
expect(result).to.equal('<!-- some HTML comment --><!--#include virtual=\"/header.html\" --><div class=\"slide nodejs\"><h3>100% Node.js</h3><p>We are Node.js experts and the first hosting platform to build our full stack in node. We understand your node application better than anyone.</p></div>'); | ||
done(); | ||
@@ -86,2 +86,10 @@ }); | ||
it('should be configurable to retain server side includes', function (done) { | ||
var commentable = new Minimize({ ssi: true }); | ||
commentable.parse(html.comment, function (error, result) { | ||
expect(result).to.equal('<!--#include virtual=\"/header.html\" --><div class=\"slide nodejs\"><h3>100% Node.js</h3><p>We are Node.js experts and the first hosting platform to build our full stack in node. We understand your node application better than anyone.</p></div>'); | ||
done(); | ||
}); | ||
}); | ||
it('should be configurable to retain conditional internet explorer comments', function (done) { | ||
@@ -88,0 +96,0 @@ var commentable = new Minimize({ conditionals: true }); |
51901
1102
192