• Stars
    star
    183
  • Rank 210,154 (Top 5 %)
  • Language
    JavaScript
  • Created over 9 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Modular typographic framework

textr

NPM version Build Status Coveralls Status Dependency Status DevDependency Status

Textr is simple framework to compose text transformation functions

Textr is good instrument to create modular tools to make your typography better. It can compose any functions that get text, transform it and return result of processing. For example, check out few: typographic-quotes, typographic-math-symbols, typographic-em-dashes and typographic-ellipses.

Plugins are available on npm, labelled with textr keyword. Also you can easily create new one. Don’t be scared.

Idea behind textr

Typography for everybody! At the same time it’s impossible to create one ideal typographic engine. It doesn’t work this way. What we can do with it? We can easily create and maintain small, simple, full-tested and single responsible modules. After this we can compose bunch of these well done modules for every specific situation we need, and everybody will be happy with it’s own ideal text transformer.

Install

npm install --save textr

Usage

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

// Create new text transformer by compose yours
tf = textr({ locale: 'ru'})
  .use(ellipses)
  .use(spaces)
  .use(quotes)
  .use(String.prototype.trim)
;

// then just send some text to the transformer
tf('Hello  "world"...\n'); // Hello «world»…

API

textr(defaults)

Create new textr transform function (tf). You can pass default options when create new transform stack.

tf.use(...fn)

Register transform function as tf middleware.

tf.exec(text, options)

Process given text by the middlewares.

tf(text)

Identical to tf.exec(text). This alias makes tf just regular transform function, that you can register as middleware for textr as well.

var typorgapher = textr().use(typography, tools, here)
var autocorrector = textr().use(autocorrection, things)
var smiles = textr().use(text, to, smiles, goodies)

var tf = textr()
  .use(typographer)
  .use(autocorrector)
  .use(smiles)
;

tf(text); // oh, that's awesome!11

Plugins API

Each plugin will be called with 2 arguments: text and options setted on textr().

function plugin(text, options) {
  console.log(options); // { locale: 'ru' }
  return text;
}

To support String.prototype methods as transformation functions, this value is equal to the text.

There are plugins for PostHTML

Few words for plugin creators

👍🎉 First off, you are awesome and thanks for taking the time to contribute! 🎉👍

Testability

As far as we want to go beyond monolythic typographic engines, then we (as ecosystem) need to have small atomic 100% covered with tests plugins. That’s why please have index.js and test.js in the repository and .travis.yml to validate pull-requests. Badges about npm version, passing tests and tests coverage are optionable, but preferred.

Give a chance to npm scripts as cross-platform tool for automatization.

README

Everyone will read README, and only ones—sources. Please include in your readme file following sections: package name, description, installation instructions, usage section with spec from tests and license note. License note is important for enterprise users. We want to create ecosystem, so it’s reasonable to have a link to textr in README’s plugins, good place for it is in the top, maybe in the short description.

'locale' option consistence

tl;dr: Use ISO 639 and rely on locale codes like these: en-uk, en-us, zh-Hans, ru, da, sv—regular values for lang attribute.

Typography is locale dependent by it’s nature, that’s why locale option is most usable option and this is a good reason to be consistent about. We looked around and found that ISO 639 standard is very well fits us, the fact that it was chosen by w3c for defining lang attribute assure us to use this unification.

License

MIT © Shuvalov Anton, Vladimir Starkov

More Repositories

1

largescaleJS_ru

Russian translation of Addy Osmani book.
Stylus
626
star
2

code-screenshots

Скриншоты редакторов кода разных разработчиков
227
star
3

superagent-mocker

Pretty simple in-browser mocks for CRUD and REST API
JavaScript
132
star
4

.dotfiles

configs and utils
Lua
80
star
5

obsidian-blog

Static site/blog generator for obsidian.md
Python
38
star
6

node-clusterize-cli

The simplest CLI interface for clusterize and demonize your apps
JavaScript
27
star
7

vim-trash-polka

Dark & Light Theme for Vim and ITerm2 inspired by @arcticicestudio/Nord.
Vim Script
14
star
8

go-search-me

Open your browser from terminal to search things
Go
10
star
9

superagent-django-csrf

Patch to add `csrftoken` from cookies as `X-CSRFToken` header to every superagent's request
JavaScript
8
star
10

to-ms

Tiny chained ms creation util for NodeJS and browsers
JavaScript
7
star
11

obsidian-blog-theme

CSS
5
star
12

dela

CLI to list markdown todos
Python
4
star
13

shuvalov.info

My blog
HTML
4
star
14

client-rest-framework

REST API framework to construct domain API repositories
TypeScript
3
star
15

repo-manager

Opinionated wrapper around git clone, that keeps all your repos in structure
TypeScript
3
star
16

parcel-plugin-peer-dependencies

Parcel plugin to exclude peer dependencies. Should be useful with yarn workspaces.
JavaScript
3
star
17

mnml-tpl

Hello :username, :repository is tiny string template engine
JavaScript
3
star
18

ansible_docker_compose

3
star
19

docker-compose-kafka

2
star
20

docker_compose_node_exporter

2
star
21

docker_compose_traefik

2
star
22

sofle

C
2
star
23

next-done

It's just countdowns your callbacks.
JavaScript
2
star
24

zapusk

Job runner for developers and desktop users supports configured jobs, shell-command execution, scheduling and notifications
Python
2
star
25

zettelkasten-sublime

Sublime Text 3 Plugin that creates timestamped notes in the given folder
Python
1
star
26

your-moms-twitbot

Ugly and nervous bot for twitter
JavaScript
1
star
27

node-smsc

Poorly SMSC API implementation
JavaScript
1
star
28

unsplash_dl

Unsplash collection downloader
Python
1
star
29

local-traefik

1
star