{"id":18572397,"url":"https://github.com/a/textr","last_synced_at":"2025-07-11T05:02:48.252Z","repository":{"id":30147763,"uuid":"33697944","full_name":"A/textr","owner":"A","description":"Modular typographic framework","archived":false,"fork":false,"pushed_at":"2024-04-05T13:41:25.000Z","size":125,"stargazers_count":182,"open_issues_count":3,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-03T07:05:11.687Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://a.github.io/textr","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/A.png","metadata":{"files":{"readme":"readme.md","changelog":"history.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-04-09T23:30:24.000Z","updated_at":"2025-05-10T02:03:50.000Z","dependencies_parsed_at":"2024-06-18T14:06:35.864Z","dependency_job_id":null,"html_url":"https://github.com/A/textr","commit_stats":{"total_commits":103,"total_committers":7,"mean_commits":"14.714285714285714","dds":0.3786407766990292,"last_synced_commit":"3cfdeb543d96da0ce04b08f49f9b78cc2efb63cb"},"previous_names":["shuvalov-anton/textr"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/A/textr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A%2Ftextr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A%2Ftextr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A%2Ftextr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A%2Ftextr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/A","download_url":"https://codeload.github.com/A/textr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A%2Ftextr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264734285,"owners_count":23655633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T23:06:05.455Z","updated_at":"2025-07-11T05:02:48.231Z","avatar_url":"https://github.com/A.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# textr\n\n[![NPM version][npm-image]][npm-url]\n[![Build Status][travis-image]][travis-url]\n[![Coveralls Status][coveralls-image]][coveralls-url]\n[![Dependency Status][depstat-image]][depstat-url]\n[![DevDependency Status][depstat-dev-image]][depstat-dev-url]\n\n\u003e Textr is simple framework to compose text transformation functions\n\nTextr is good instrument to create modular tools to [make your typography better][bad-habits].\nIt can compose any functions that get text, transform it and return result of\nprocessing. For example, check out few: [typographic-quotes][typographic-quotes],\n[typographic-math-symbols][typographic-math-symbols],\n[typographic-em-dashes][typographic-em-dashes] and [typographic-ellipses][typographic-ellipses].\n\nPlugins are available on npm, labelled with [textr][textr-npm]\nkeyword. Also you can easily create new one. Don’t be scared.\n\n## Idea behind textr\n\nTypography for everybody! At the same time it’s impossible to create one ideal\ntypographic engine. It doesn’t work this way. What we can do with it? We can\neasily create and maintain small, simple, full-tested and single responsible\nmodules. After this we can compose bunch of these well done modules for every\nspecific situation we need, and everybody will be happy with it’s\nown ideal text transformer.\n\n## Install\n\n```\nnpm install --save textr\n```\n\n\n## Usage\n\n```js\nvar textr    = require('textr');\nvar ellipses = require('typographic-ellipses');\nvar spaces   = require('typographic-single-spaces');\nvar quotes  = require('typographic-quotes');\n\n// Create new text transformer by compose yours\ntf = textr({ locale: 'ru'})\n  .use(ellipses)\n  .use(spaces)\n  .use(quotes)\n  .use(String.prototype.trim)\n;\n\n// then just send some text to the transformer\ntf('Hello  \"world\"...\\n'); // Hello «world»…\n```\n\n## API\n\n### textr(defaults)\n\nCreate new textr transform function (`tf`). You can pass default options when\ncreate new transform stack.\n\n\n### tf.use(...fn)\n\nRegister transform function as `tf` middleware.\n\n### tf.exec(text, options)\n\nProcess given text by the middlewares.\n\n### tf(text)\n\nIdentical to `tf.exec(text)`. This alias makes `tf` just regular transform\nfunction, that you can register as middleware for `textr` as well.\n\n```js\nvar typorgapher = textr().use(typography, tools, here)\nvar autocorrector = textr().use(autocorrection, things)\nvar smiles = textr().use(text, to, smiles, goodies)\n\nvar tf = textr()\n  .use(typographer)\n  .use(autocorrector)\n  .use(smiles)\n;\n\ntf(text); // oh, that's awesome!11\n\n```\n\n\n## Plugins API\n\nEach plugin will be called with 2 arguments: `text` and `options`\nsetted on `textr()`.\n\n```\nfunction plugin(text, options) {\n  console.log(options); // { locale: 'ru' }\n  return text;\n}\n```\n\nTo support `String.prototype` methods as transformation functions, `this` value\nis equal to the `text`.\n\nThere are plugins for [PostHTML](https://www.npmjs.com/package/posthtml-textr)\n\n## Few words for plugin creators\n\n:+1::tada: First off, you are awesome and thanks for taking the time\nto contribute! :tada::+1:\n\n### Testability\n\nAs far as we want to go beyond monolythic typographic engines, then\nwe (as ecosystem) need to have small atomic 100% covered with tests plugins.\nThat’s why please have `index.js` and `test.js` in the repository\nand `.travis.yml` to validate pull-requests. Badges about npm version,\npassing tests and tests coverage are optionable, but preferred.\n\nGive a chance to [npm scripts][npmscripts] as cross-platform tool\nfor automatization.\n\n### README\n\nEveryone will read README, and only ones—sources. Please include in your readme\nfile following sections: package name, description, installation instructions,\nusage section with spec from tests and license note. License note is important\nfor enterprise users. We want to create ecosystem, so it’s reasonable to have\na link to textr in README’s plugins, good place for it is in the top,\nmaybe in the short description.\n\n[npmscripts]: https://docs.npmjs.com/misc/scripts\n\n### 'locale' option consistence\n\ntl;dr: Use [ISO 639][ISO] and rely on locale codes like these: `en-uk`,\n`en-us`, `zh-Hans`, `ru`, `da`, `sv`—regular values for `lang` attribute.\n\nTypography is locale dependent by it’s nature, that’s why `locale` option\nis most usable option and this is a good reason to be consistent about. We looked\naround and found that [ISO 639 standard][ISO] is very well fits us, the fact that\nit was chosen by w3c for defining lang attribute assure us to use this\nunification.\n\n[ISO]: http://www.wikiwand.com/en/List_of_ISO_639-1_codes\n\n## License\n\n[textr-npm]: https://www.npmjs.com/browse/keyword/textr\n\nMIT © [Shuvalov Anton](http://shuvalov.info), [Vladimir Starkov](https://iamstarkov.com)\n\n[bad-habits]: http://practicaltypography.com/typewriter-habits.html\n\n[npm-url]: https://npmjs.org/package/textr\n[npm-image]: https://img.shields.io/npm/v/textr.svg\n\n[travis-url]: https://travis-ci.org/A/textr\n[travis-image]: https://img.shields.io/travis/A/textr.svg\n\n[coveralls-url]: https://coveralls.io/r/A/textr\n[coveralls-image]: https://img.shields.io/coveralls/A/textr.svg\n\n[depstat-url]: https://david-dm.org/A/textr\n[depstat-image]: https://david-dm.org/A/textr.svg\n\n[depstat-dev-url]: https://david-dm.org/A/textr\n[depstat-dev-image]: https://david-dm.org/A/textr/dev-status.svg\n\n[typographic-quotes]: https://github.com/matmuchrapna/typographic-quotes\n[typographic-math-symbols]: https://github.com/matmuchrapna/typographic-math-symbols\n[typographic-em-dashes]: https://github.com/matmuchrapna/typographic-em-dashes\n[typographic-ellipses]: https://github.com/matmuchrapna/typographic-ellipses\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa%2Ftextr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa%2Ftextr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa%2Ftextr/lists"}