Skip to content

Commit

Permalink
[docs] fix JS and update style
Browse files Browse the repository at this point in the history
  • Loading branch information
Swaagie committed Jan 11, 2016
1 parent 87134ba commit 6597068
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
13 changes: 6 additions & 7 deletions README.md
Expand Up @@ -26,10 +26,6 @@ templaters should be parsed and minified.**
- build on the foundations of [htmlparser2][fb55]
- pluggable interface that allows to hook into each element

## Upcoming in release 2.0

- minification of inline javascript with uglify or similar

## Usage

To get the minified content make sure to provide a callback. Optional an options
Expand Down Expand Up @@ -64,9 +60,12 @@ be useful if the HTML contains SVG or if you need to specific options to the par
```javascript
var Minimize = require('minimize')
, html = require('htmlparser2')
, minimize = new Minimize(new html.Parser(
new html.FeedHandler((this.emits('read'))
), { /* options */ });
, minimize = new Minimize(
new html.Parser(
new html.FeedHandler(minimize.emits('read')),
{ /* options */ }
)
);

minimize.parse(content, function (error, data) {
console.log(data);
Expand Down
3 changes: 2 additions & 1 deletion lib/minimize.js
Expand Up @@ -35,7 +35,8 @@ function Minimize(parser, options) {
// Prepare the parser.
//
this.htmlparser = parser || new html.Parser(
new html.DomHandler(this.emits('read')), options.dom
new html.DomHandler(this.emits('read')),
options.dom
);

//
Expand Down
2 changes: 2 additions & 0 deletions test/minimize-test.js
Expand Up @@ -62,6 +62,8 @@ describe('Minimize', function () {
expect(minimize.htmlparser).to.have.property('custom', 'instance');
});

it('can emit the parsed content to `minimize.read`');

it('should start traversing the DOM as soon as HTML parser is ready', function (done) {
var emit = sinon.spy(minimize, 'emit');

Expand Down

0 comments on commit 6597068

Please sign in to comment.