Rehype-Wordspan
Span wrapping all words of a header element with rudimentary parts of speech classification.
Installation
npm:
npm install rehype-wordspan
Usage
Dependencies:
var rehype = require('rehype');
var wordSpan = require('rehype-wordspan');
Given:
var file = rehype().use(wordSpan).process('<h1>In the Heart of the Jungle</h1>');
Returns:
<h1><span class="word">In</span><span class="space"> </span><span class="word a">the</span><span class="space"> </span><span class="word">Heart</span><span class="space"> </span><span class="word p">of</span><span class="space"> </span><span class="word a">the</span><span class="space"> </span><span class="word">Jungle</span></h1>
API
rehype.use(wordSpan[, options])
At the moment there are no accepted options, but soon I will add the ability to specify which kind of html tag to catch and which classes to be applied.
All words receive a word
class and all spaces receive a space
class.
For now, cc
is added to conjunctions. a
is added to aticles. p
is added to the 20 most common preopositions (the ones you are likely not using for artistic effect.) For example, Running to the car
will wrap "to" as a preposition. But, Underneath the old Pickup
will not wrap "Underneath."
Don't agree? That's what the issues are for. :)
License
MIT © Jesse Martin