gulp-head-picker
Advanced tools
Comparing version 0.0.1 to 0.0.2
12
index.js
@@ -11,5 +11,5 @@ var es = require('event-stream'); | ||
// Default options | ||
options = _.extend({ | ||
property: 'toc', | ||
}, options || {}); | ||
options = options || {}; | ||
options.property = options.property || 'toc'; | ||
options.hpOptions = options.hpOptions || {}; | ||
@@ -21,3 +21,3 @@ return es.map(function (file, cb) { | ||
try { | ||
res = hp(String(file.contents)); | ||
res = hp(String(file.contents), options.hpOptions); | ||
} catch (e) { | ||
@@ -27,4 +27,4 @@ return cb(new gutil.PluginError(PLUGIN_NAME, e)); | ||
file[options.property] = res.toc; | ||
file.contents = new Buffer(res.html); | ||
delete res.html; | ||
file.contents = new Buffer(res.contents); | ||
delete res.contents; | ||
} else if (file.isNull()) { | ||
@@ -31,0 +31,0 @@ return cb(null, file); |
{ | ||
"name": "gulp-head-picker", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "gulp plugin to extract heading elements from HTML string.", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
"event-stream": "^3.1.7", | ||
"head-picker": "0.0.1", | ||
"head-picker": "0.0.2", | ||
"lodash": "^2.4.1" | ||
@@ -24,4 +24,5 @@ }, | ||
"gulp-util": "^3.0.1", | ||
"head-picker": "0.0.2", | ||
"mocha": "^2.0.1" | ||
} | ||
} |
@@ -23,2 +23,3 @@ "use strict"; | ||
file.originalContents = file.contents; | ||
console.log(options); | ||
cb(null, file); | ||
@@ -47,2 +48,8 @@ })) | ||
it('should get contents in xhtml format', test(inputDir + 'test.html', {hpOptions:{format: 'xml'}}, function (file, cb) { | ||
var str = '<!DOCTYPE html>\n<html>\n<head>\n <meta charset="utf-8"/>\n <meta http-equiv="X-UA-Compatible" content="IE=edge"/>\n <title>title</title>\n</head>\n<body>\n <h1 id="toc_index_0">Heading1</h1>\n <h2 id="toc_index_1">Heading2</h2>\n <h3 id="toc_index_2">Heading3</h3>\n <h4 id="toc_index_3">Heading4</h4>\n <h5 id="toc_index_4">Heading5</h5>\n <h6 id="toc_index_5">Heading6</h6>\n <hr/>\n</body>\n</html>'; | ||
expect(file.contents.toString()).to.equal(str); | ||
cb(); | ||
})); | ||
it ('should raise a plugin error for stream file', function (done) { | ||
@@ -72,2 +79,3 @@ var streamFile = new gutil.File({ contents: new stream.Stream() }); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7089
97
6
+ Addedhead-picker@0.0.2(transitive)
- Removedhead-picker@0.0.1(transitive)
Updatedhead-picker@0.0.2