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 = ;var inspect = ;var syllable = ; ;
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
).