![Test Coverage](https://api.codeclimate.com/v1/badges/d1b611efce3f2c6eeb98/test_coverage)
excerpt-html
parses a given html text for a good excerpt.
Install
$ npm i excerpt-html --save
API usage
var htmlCode = '<p>Hello world</p>';
var excerptHtml = require('excerpt-html');
var excerpt = excerptHtml(htmlCode);
It will either use the first found paragraph or everything up to a
<!-- more -->
Options
You can specify a few options that modify the way the excerpt is parsed:
excerptHtml(htmlCode, {
moreRegExp: /\s*<!--\s*more\s*-->/i,
stripTags: true,
pruneLength: 140,
pruneString: '…',
pruneSeparator: ' ',
})
Note: pruneLength
and prunestring
only work when stripTags
is set to true
(default).
History
To make this project we detached the code of metalsmith-better-excerpts from metalsmith
.