Socket
Socket
Sign inDemoInstall

typopo

Package Overview
Dependencies
0
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

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.


Version published
Weekly downloads
1.1K
decreased by-15.44%
Maintainers
1
Install size
0.959 MB
Created
Weekly downloads
 

Changelog

Source

2.5.0 // 2021-06-08

I’ve done something in this version what I wanted to do for a while. I wanted to refactor modules that fix double quotes and single quotes. These modules were old and difficult to improve. And as I went along refactoring, I’ve also fixed few other issues, so in the end, quite a few things made it into this version.

Since this version (2.5.0), Typopo is tested against 2540 assertion tests (+675 tests since version 2.4.1). The number of tests is not a guarantee there won’t be any bugs, but it indicates a growing desire to cover more and more edge cases.

Here’s a rundown of what’s been new and improved in this version.

✨ New features

New configuration option to keep Markdown code blocks in your Markdown files:

  • keepMarkdownCodeBlocks: true when you want to keep Markdown code blocks in your Markdown files
  • keepMarkdownCodeBlocks: false want to fix grave accents (`) in generic texts to single quotes

⚡️ Improvements

  • Limit identification of “and” contractions to common phrases, and add a non-breaking space around them. Common phrases:
    • dead ’n’ buried
    • drill ’n’ bass
    • drum ’n’ bass
    • rock ’n’ roll
    • pick ’n’ mix
    • fish ’n’ chips
    • salt ’n’ shake
    • mac ’n’ cheese
    • pork ’n’ beans
    • drag ’n’ drop
    • rake ’n’ scrape
    • hook ’n’ kill
  • Identify and fix single-quoted ‘words’ outside double quotes
  • Swap single quotes and terminal punctuation when single quotes are used only for a portion of a sentence, e.g.:
    • …only a ‘quoted part.’ → …only a ‘quoted part’.
  • Keep a space between a number and a number sign (#) at the beginning of the paragraph (e.g. when you’re starting a Markdown headline with a number)
  • Limit adding a non-breaking space after cardinal and ordinal numbers with three and more digits.

🐛 Fixes

  • Fix edge cases around double quotes and double primes:
    • Here are 30 "bucks" → Here are 30 “bucks” (before, a left quote was falsely identified as a double prime)
    • "Conference 2020" and "something in quotes". → “Conference 2020” and “something in quotes”. (before, a right quote after “2020” was falsely identified as a double prime)
    • "2020" → “2020” (before, dumb quotes around numbers were not identified as a double quote pair)
    • He was ok. “He was ok ”. → He was ok. “He was ok.”, (before, when a right double quote was swapped with a terminal punctuation, the extra space wasn’t removed)
    • It’s 12" x 12". → It’s 12″ × 12″. (before, the second prime was falsely identified as a right double quote)
    • 12'' → 12″ (two dumb single quotes are fixed to a double prime around numbers)
    • When you ask the “How often…” question (before, the ellipsis was falsely swapped with a right double quote in this type of Sentence)
    • It’s a“nice” saying. → It’s a “nice” saying. (now, the added space is a nbsp, when added before a single-word prepositions)
  • When Typopo is configured as removeWhitespacesBeforeMarkdownList : false, Markdown lists are now kept nested, even when they start with +

🔨 Maintenance

  • Refactor a module to fix double quotes
  • Refactor a module to fix single quotes
  • Update NPM packages to their latest versions

Readme

Source

Typopo logotype

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

Contents

Features

Typopo fixes microtypography hickups in five languages:

  • English
  • German
  • Czech
  • Slovak
  • Rusyn

Typopo fixes punctuation:

  • double quotes (and accidentally-typed punctuation related to the use of 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 a 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
      • ordinal Roman numerals
      • after name initials (i.e. Philip K. Dick)
      • after common single-word and multiple-word abbreviations
      • before % (percent), ‰ (per mille), ‱ (permyriad)

Typopo fixes words:

  • accidental uPPERCASE
  • 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)
  • section sign (§)
  • copyright ((c)2020 → © 2020)
  • sound recording copyright ((p)2020 → ℗ 2020)
  • registered trademark (Brand(r) → Brand®)
  • trademark (Brand(tm) → Brand™)
  • plus-minus sign (+-, -+ → ±)
  • square and cube exponents (e.g. 100 µm² → 100 µm², 50 km³ → 50 km³)

Use

You can use Typopo as an online app, VS Code extension, NPM package or JavaScript library.

Online app

URL → https://typopo.org/

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.

Typopo—online app

VS Code extension

Typopo—VS Code extension

NPM package

Install Typopo as an NPM package in your web project:

npm install typopo

Import the package:

import { fixTypos } from 'typopo';

Check out an API on how to use the package.

JavaScript library

Download dist/typopo.min.js and include it in your web project or CMS. Check out an API on how to use the library.

API

Fix typos in given text (string) and locale; with an optional configuration:

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:

configuration = {
  // If true, removes empty lines between paragraphs
  removeLines : true, 
  
  // if true, removes empty lines before a nested Markdown list; 
  // set as false when you use Typopo to fix typography of your Markdown files
  // see examples: https://github.com/surfinzap/typopo/releases/tag/2%2F4%2F0
  removeWhitespacesBeforeMarkdownList : true, 

	// if true, markdown code blocks (i.e. `code`, ``code``, ```code```) will be ignored from being identified as incorrectly used single quote or double quote pairs
	// set as false when you want to fix typos in generic texts (non-Markdown files)
	// set as true when you want to keep Markdown code blocks in your Markdown files
	keepMarkdownCodeBlocks: false,
}

News & Releases

Check out the changelog for what’s has been released.

Subscribe to Typopo Newsletter to be the first to know about all the new features and improvements.

Support

If you love Typopo and you find it helpful, support the project via Patreon.

Your support will let me continue improving Typopo ecosystem—the app, NPM package and VS Code Extension.

Feedback

Have you found a bug? Do you have an idea for a feature request? You’re more then welcome to submit an issue here on GitHub.

If you prefer to reach out me via email, feel free to drop me a line at help@typopo.org.

License

Licensed under MIT license. (See LICENCE.TXT.)

Special thanks

  • @Viclick for adjusting the repo for modularisation (2.0.0)
  • @tomashruby for consultation on architecture (2.0.0)
  • @skurzinz for consultation & test on German typographic rules (2.2.0)
  • Filip Blažek for consultation on typography rules
  • @vit-svoboda for fixing the package to run in Node.js projects (2.3.1)

Keywords

FAQs

Last updated on 08 Jun 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc