Skip to content

Excerpting words or characters of text from an HTML snippet.

Notifications You must be signed in to change notification settings

gnowoel/excerpts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

excerpts Build Status

Excerpting words or characters of text from an HTML snippet.

Installation

$ npm install excerpts

Usage

Given HTML snippet:

<p>Lorem <i>ipsum</i> dolor <em>sit</em> amet.</p>

Words

Excerpting words with the words option:

var excerpts = require('excerpts');
var text = excerpts(html, { words: 3 });
//=> Lorem ipsum dolor...

Characters

Excerpting characters with the characters option:

var excerpts = require('excerpts');
var text = excerpts(html, { characters: 10 });
//=> Lorem ipsum dol...

The words option takes precedence over the characters option. By default, 50 words will be extracted when options are missing.

Appendix

The appendix can be customized with the append option:

var excerpts = require('excerpts');
var text = excerpts(html, { words: 3, append: ' >>' });
//=> Lorem ipsum dolor >>

The appendix won't appear when full text has been extracted.

Tests

$ npm install
$ npm test

License

MIT

About

Excerpting words or characters of text from an HTML snippet.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published