Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gnowoel/excerpts
Excerpting words or characters of text from an HTML snippet.
https://github.com/gnowoel/excerpts
excerpt html-snippet
Last synced: 2 months ago
JSON representation
Excerpting words or characters of text from an HTML snippet.
- Host: GitHub
- URL: https://github.com/gnowoel/excerpts
- Owner: gnowoel
- Created: 2016-02-07T08:08:22.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-14T08:19:11.000Z (about 7 years ago)
- Last Synced: 2024-12-04T23:02:55.283Z (3 months ago)
- Topics: excerpt, html-snippet
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# excerpts [](https://travis-ci.org/gnowoel/excerpts)
Excerpting words or characters of text from an HTML snippet.
## Installation
```
$ npm install excerpts
```## Usage
Given HTML snippet:
``` html
Lorem ipsum dolor sit amet.
```### Words
Excerpting words with the `words` option:
```javascript
var excerpts = require('excerpts');
var text = excerpts(html, { words: 3 });
//=> Lorem ipsum dolor...
```### Characters
Excerpting characters with the `characters` option:
```javascript
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:
```javascript
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