excerpts
Excerpting text of given words or characters from HTML.
Installation
$ npm install excerpts
Usage
Given HTML:
<p>Lorem <i>ipsum</i> dolor <em>sit</em> amet.</p>
Words
Excerpting words with words
option:
var excerpts = require('excerpts');
var text = excerpts(html, { words: 3 });
Characters
Excerpting characters with characters
option:
var excerpts = require('excerpts');
var text = excerpts(html, { characters: 10 });
The words
option takes precedence over the characters
option. With missing option, 50 words would be extracted by default.
Appendix
The appendix can be customized with the append
option:
var excerpts = require('excerpts');
var text = excerpts(html, { words: 3, append: " >>" });
The appendix won't appear when full text are extracted.
Tests
$ npm install
$ npm test
License
MIT