Fix frequent microtypography errors in multiple languages. Write neat texts without bothering about typography rules. Typopo works for English, German, Slovak, Czech and Rusyn language.
npm install typopo
> Fix frequent microtypography errors in multiple languages. Write neat texts without bothering about typography rules. Typopo works for English, German, Slovak, Czech and Rusyn language.
!GitHub package.json version
!GitHub
!Tests
Typopo fixes punctuation:
- double quotes (and accidentally typed punctuation related to the use of double quotes)
- direct speech introduction (colon/comma before opening double quotes)
- double primes
- single quotes (with an assumption they are used as secondary and in pairs)
- single primes
- apostrophes
- hyphens & dashes
- between words with a proper spacing per locale
- between ordinal and cardinal numbers (e.g. 1–3 eggs)
- within date (e.g. 2020–08–04)
- between percentage range (e.g. 20–30 %)
- period & ellipsis
Typopo fixes whitespace characters:
- removes extra white spaces
- at the beginning and the end of sentences (leading and trailing spaces)
- between words and paragraphs
- before or after punctuation (where applicable)
- around an ellipsis and an aposiopesis (where applicable)
- between a number sign (#) and a number
- before ordinal indicators (e.g. 1 st → 1st)
- removes empty lines
- fixes non-breaking spaces
- removes a nbsp between multi-letter words
- replaces a space with a nbsp
- after one-word prepositions
- around “×”,
- after “&”, “§”, “¶”, “©”, “℗”, “№”
- after cardinal numbers
- after ordinal numbers
- after ordinal Roman numerals
- before single capital letters that are part of the phrase (e.g. Project X)
- after name initials (e.g. Philip K. Dick)
- after common single-word and multiple-word abbreviations
- before % (percent), ‰ (per mille), ‱ (per myriad)
Typopo fixes words:
- accidental uPPERCASE
- the spelling of e.g., i.e., a.m. and p.m.
- ISSN and ISBN formatting
Typopo fixes symbols:
- multiplication sign (2 x 3 → 2 × 3)
- copyright ((c)2020 → © 2020)
- sound recording copyright ((p)2020 → ℗ 2020)
- registered trademark (Brand(r) → Brand®)
- service mark (Brand(sm) → Brand℠)
- trademark (Brand(tm) → Brand™)
- plus-minus sign (+-, -+ → ±)
- square and cube exponents (e.g. 100 µm² → 100 µm², 50 km³ → 50 km³)
You can use Typopo as an online app, VS Code extension, or NPM package.
The online app is useful especially when you’re a book designer or a DTP operator. Before you typeset raw texts in a DTP app of your choice, run it through Typopo and fix microtypography with a single click.
#### ES Module (Recommended)
For modern Node.js and bundler environments:
``bash`
npm install typopo`javascript`
import { fixTypos } from 'typopo';
#### CommonJS
For legacy Node.js environments or when require() is needed:
`javascript`
const { fixTypos } = require('typopo');
#### Browser/UMD
For direct browser usage without a bundler:
`html`
#### TypeScript Support
Typopo includes TypeScript type definitions for enhanced type safety and autocomplete:
`typescript
import { fixTypos, TypopoLocale, TypopoConfiguration } from 'typopo';
// TypeScript provides autocomplete for locales
const locale: TypopoLocale = 'en-us'; // 'en-us' | 'de-de' | 'sk' | 'cs' | 'rue'
// Type-safe configuration
const config: TypopoConfiguration = {
removeLines: true
};
// Full type checking
const result: string = fixTypos('Your text here', locale, config);
`
The library is written in JavaScript, but ships with type definitions for TypeScript users.
Check out the API section for usage details.
javascript
fixTypos(string, locale, [configuration])
`Locale options (supported languages):
- "en-us" (English, default)
- "rue" (Rusyn)
- "sk" (Slovak)
- "cs" (Czech)
- "de-de" (German)
Optional configuration as a JavaScript object:
`javascript
configuration = {
// If true, removes empty lines between paragraphs
removeLines : true,
}
``Your support will let me continue improving Typopo ecosystem—the app, NPM package and VS Code Extension.
If you prefer to email, drop me a line at