textr

0.3.0 · abandoned · verified Sun Apr 19

textr is a tiny and extendable framework designed for composing text transformation functions. Its core idea revolves around enabling developers to build modular typography tools by chaining small, single-responsibility text processing modules. The package encourages creating specific transformers for tasks like smart quotes, ellipses, or em-dashes, rather than a monolithic typographic engine. The current stable version is 0.3.0, released in 2015. Given its age and lack of updates, it's considered an abandoned project, meaning no new features or maintenance fixes are expected. Its key differentiator was its pluggable architecture for highly customized text processing workflows, allowing users to combine various `typographic-*` packages available on npm.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize `textr` with options, register multiple typographic plugins, and process a string through the transformation pipeline.

const textr = require('textr');
const ellipses = require('typographic-ellipses');
const spaces = require('typographic-single-spaces');
const quotes = require('typographic-quotes');

// Create a new text transformer instance, optionally with default options
const tf = textr({ locale: 'ru' })
  .use(ellipses) // Add a plugin for ellipses
  .use(spaces)   // Add a plugin for single spaces
  .use(quotes)   // Add a plugin for smart quotes
  .use(String.prototype.trim); // Use a native String prototype method

// Process text using the configured transformer
const input = 'Hello  "world"...\n  This is some text with   bad  spacing and unsmart quotes. '; 
const output = tf(input);

console.log(output); // Expected: Hello «world»… This is some text with bad spacing and unsmart quotes.

view raw JSON →