1.0.0 • Published 9 years ago

retext-syllable v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

retext-syllable Build Status Coverage Status

Count syllables with retext.

Installation

npm:

npm install retext-syllable

retext-syllable is also available for bower, component, and duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.

Usage

var retext = require('retext');
var inspect = require('unist-util-inspect');
var syllable = require('retext-syllable');

retext().use(syllable).use(function () {
    return function (cst) {
        console.log(inspect(cst));
    };
}).process('A yellow fresh banana.');

Yields:

RootNode[1] [data={"syllableCount":7}]
└─ ParagraphNode[1] [data={"syllableCount":7}]
   └─ SentenceNode[8] [data={"syllableCount":7}]
      ├─ WordNode[1] [data={"syllableCount":1}]
      │  └─ TextNode: 'A'
      ├─ WhiteSpaceNode: ' '
      ├─ WordNode[1] [data={"syllableCount":2}]
      │  └─ TextNode: 'yellow'
      ├─ WhiteSpaceNode: ' '
      ├─ WordNode[1] [data={"syllableCount":1}]
      │  └─ TextNode: 'fresh'
      ├─ WhiteSpaceNode: ' '
      ├─ WordNode[1] [data={"syllableCount":3}]
      │  └─ TextNode: 'banana'
      └─ PunctuationNode: '.'

API

None, retext-syllable automatically detects the syllables of each WordNode (using wooorm/syllable), and stores the count in node.data.syllableCount.

All parents (such as sentences, paragraphs, root) also receive a syllableCount property (parent.data.syllableCount).

License

MIT © Titus Wormer

1.0.0

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago