TypoLima

Conservative typographic fixer for HTML, PHP, Hugo templates and text files

What is TypoLima?

TypoLima is a command-line tool that automatically fixes common typographic issues in web content while being extremely careful not to break code. It only touches text content — never HTML tags, attributes, scripts, or template variables like {{ }} or <?php ?>.

The name comes from the Latin word lima (file/polish), representing the final meticulous polishing of a text — labor limae.

Features

Smart Quotes

Converts straight quotes to language-specific curly quotes: „ “ for Czech, « » for French, " " for English, etc.

Non-Breaking Spaces

Automatically adds NBSP after single-letter prepositions (cs: v, s, z, k, o, u, a, i) and before units (5 kg, 20 %, 10 €).

Intelligent Dashes

Converts -- to en-dash (–) for ranges (10–20) and em-dash (—) for parenthetical thoughts with proper spacing.

Smart Punctuation

French spacing: adds space before ? ! : ; «. Thousands separators and decimal points per language.

Abbreviations

Fixes common abbreviations: s. r. o., tj., tzn., a.s. with proper non-breaking spaces.

Aggressive Mode

Optional conversion: (c) → ©, (r) → ®, (tm) → ™, +- → ±, -> → →, etc.

Supported Languages

TypoLima supports 33+ languages with language-specific rules for quotes, spacing, and punctuation:

Code Language Quotes Special Features
csCzech„ “Prepositions, s.r.o.
skSlovak„ “Prepositions
en / en-US / en-GBEnglish" "Thousands sep
frFrench« »Space before ?!:;
deGerman„ “Thousands sep
itItalian« »
esSpanish« »
pt / pt-PT / pt-BRPortuguese« »
plPolish„ “
nlDutch„ “
huHungarian„ “
ruRussian« »
ukUkrainian« »
bgBulgarian„ “
+ 15 morero, tr, vi, sv, fi, no, da, hr, sl, et, ca, el, id, tl, sw, eoVarious

Installation

macOS — Homebrew (Recommended)

brew install heptau/tap/typolima

pipx (Isolated)

pipx install git+https://github.com/heptau/typolima.git

pip

pip install git+https://github.com/heptau/typolima.git

From Source

git clone https://github.com/heptau/typolima.git
cd typolima
pip install .

Usage

Basic Commands

typolima --help

# Process a single file
typolima article.html --lang cs --in-place

# Dry run with diff
typolima *.html --lang en --dry-run --diff

# Recursive processing
typolima public/ --lang cs --recursive --in-place

Options

Examples

Fix Czech HTML files

typolima content/*.html --lang cs --in-place

Before: "Ahoj" jdu k lesu
After: „Ahoj“ jdu k lesu

French with diff

typolima public/ --lang fr --recursive --dry-run --diff

Before: Salut?
After: Salut ?

Hugo post-build

typolima public/ --lang cs --recursive --in-place

Add to package.json: "postbuild": "typolima public/ --lang cs --recursive --in-place"

Aggressive mode

typolima text.md --lang en --aggressive

Converts: (c) → ©, (tm) → ™, -> → →, ==> → ⟹

File filtering with include/exclude

# Include only HTML files
typolima site/ --lang cs --recursive --include "*.html"

# Exclude partials (files starting with _)
typolima public/ --lang de --recursive --exclude "_*"

# Combined: include html but exclude minified
typolima site/ --lang fr --include "*.html" --exclude "*.min.html"

Backup before in-place changes

# Create .bak backup files before modifying
typolima site/ --lang cs --in-place --backup

Creates backup files (e.g., index.html.bak) before modifying original files.

Auto-detect language

# Auto-detect from HTML lang attribute, filename pattern, or .typolimarc
typolima site/ --recursive --auto-detect

Automatically detects language from: <html lang="fr">, filename like article.cs.html, or .typolimarc config file.

Verbose statistics

# Show detailed statistics about changes
typolima site/ --lang cs --verbose

Shows: Changed files count, quotes fixed, dashes converted, NBSP inserted.

Config File

# .typolimarc example
language: cs
recursive: true
exclude:
  - "_*"
  - "*.min.*"

Place .typolimarc in your project root to set default options.

Ready to polish your text?

TypoLima is free and open source.

View on GitHub →