textlint-util-to-string is a utility library within the textlint ecosystem designed to convert Text Abstract Syntax Tree (TxtAST) 'Paragraph' nodes into plain text strings. Its primary distinguishing feature is the integrated SourceMap functionality, which allows developers to accurately map positions in the generated plain text back to their corresponding original positions within the AST. This is crucial for tools like textlint and textstat that require precise error reporting and manipulation based on the original source. The current stable version is 3.3.4, and the package demonstrates an active release cadence with frequent patch and minor updates addressing bug fixes and introducing new features, such as the `replacer` option for text transformation during string conversion. This library serves as a foundational component for building advanced text processing and linting tools.
npm install textlint-util-to-stringVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate `StringSource` with a `TxtParagraphNode`, convert it to plain text, use the `replacer` option to mask specific node types, and retrieve original AST positions from the generated string using source map functionality.
Change your import statements from `import StringSource from 'textlint-util-to-string'` to `import { StringSource } from 'textlint-util-to-string'`.Refer to the API documentation carefully for `position` (line, column) vs. `index` (offset) definitions and their respective 0-based/1-based indexing conventions. Use the specific `original*From*` methods matching your input and desired output.
Update your import statement to `import { StringSource } from 'textlint-util-to-string'` for ESM or `const { StringSource } = require('textlint-util-to-string')` for CommonJS.Modify your import statement to `import { StringSource } from 'textlint-util-to-string'` to use the named export, and ensure your build tooling correctly handles ESM imports.