The goal is to build this out more with some plans I have in mind. At present, this NPM module exports a function that takes a text input parameter textInput
.
It takes paramater textInput
and splits it into paragraphs $.text.textParagraphs[]
and lines within paragraphs as $.text.textParagraphs[i].paragraphLines[i].lineText
. They are strings and each "text level" has a corresponding data object that tracks metadata about that text string. Each object within the $.text.textParagraphs[0]
array, for example, has a .paragraphData
object that provides such properties as paragraphLineCount
; each line within each paragraph has a lineData
object with corresponding properties like lineWordCount
It reformats this data into a JSON object that includes metadata along with the original text.
It is written in ESM format.
import { paragraphsLines } from 'paragraphs-lines';
// "After great pain, a formal feeling comes – (372)"
// by Emily Dickinson
const textInput = `
After great pain, a formal feeling comes – (372)
After great pain, a formal feeling comes –
The Nerves sit ceremonious, like Tombs –
The stiff Heart questions ‘was it He, that bore,’
And ‘Yesterday, or Centuries before’?
The Feet, mechanical, go round –
A Wooden way
Of Ground, or Air, or Ought –
Regardless grown,
A Quartz contentment, like a stone –
This is the Hour of Lead –
Remembered, if outlived,
As Freezing persons, recollect the Snow –
First – Chill – then Stupor – then the letting go –
`;
const result = paragraphsLines(textInput);
console.log(JSON.stringify(result, null, 2));
returns a JSON object w/ the text and data.
MIT