Conservative typographic fixer for HTML, PHP, Hugo templates and text files
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.
Converts straight quotes to language-specific curly quotes: „ “ for Czech, « » for French, " " for English, etc.
Automatically adds NBSP after single-letter prepositions (cs: v, s, z, k, o, u, a, i) and before units (5 kg, 20 %, 10 €).
Converts -- to en-dash (–) for ranges (10–20) and em-dash (—) for parenthetical thoughts with proper spacing.
French spacing: adds space before ? ! : ; «. Thousands separators and decimal points per language.
Fixes common abbreviations: s. r. o., tj., tzn., a.s. with proper non-breaking spaces.
Optional conversion: (c) → ©, (r) → ®, (tm) → ™, +- → ±, -> → →, etc.
TypoLima supports 33+ languages with language-specific rules for quotes, spacing, and punctuation:
| Code | Language | Quotes | Special Features |
|---|---|---|---|
| cs | Czech | „ “ | Prepositions, s.r.o. |
| sk | Slovak | „ “ | Prepositions |
| en / en-US / en-GB | English | " " | Thousands sep |
| fr | French | « » | Space before ?!:; |
| de | German | „ “ | Thousands sep |
| it | Italian | « » | |
| es | Spanish | « » | |
| pt / pt-PT / pt-BR | Portuguese | « » | |
| pl | Polish | „ “ | |
| nl | Dutch | „ “ | |
| hu | Hungarian | „ “ | |
| ru | Russian | « » | |
| uk | Ukrainian | « » | |
| bg | Bulgarian | „ “ | |
| + 15 more | ro, tr, vi, sv, fi, no, da, hr, sl, et, ca, el, id, tl, sw, eo | Various |
brew install heptau/tap/typolima
pipx install git+https://github.com/heptau/typolima.git
pip install git+https://github.com/heptau/typolima.git
git clone https://github.com/heptau/typolima.git
cd typolima
pip install .
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
--lang — Language code (cs, en, fr, de, etc.)--in-place — Modify files in place (default: output to stdout)--dry-run — Show what would be changed without modifying--diff — Show detailed diff (requires --dry-run)--recursive — Process directories recursively--aggressive — Convert (c) → ©, +- → ±, etc.--include PATTERN — Include files matching glob pattern (can be used multiple times)--exclude PATTERN — Exclude files matching glob pattern (can be used multiple times)--backup — Create .bak backup before modifying (requires --in-place)--auto-detect — Auto-detect language from HTML lang attribute, filename, or .typolimarc config--verbose — Show detailed statistics about changes (quotes, dashes, NBSP count)typolima content/*.html --lang cs --in-place
Before: "Ahoj" jdu k lesu
After: „Ahoj“ jdu k lesu
typolima public/ --lang fr --recursive --dry-run --diff
Before: Salut?
After: Salut ?
typolima public/ --lang cs --recursive --in-place
Add to package.json: "postbuild": "typolima public/ --lang cs --recursive --in-place"
typolima text.md --lang en --aggressive
Converts: (c) → ©, (tm) → ™, -> → →, ==> → ⟹
# 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"
# 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 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.
# Show detailed statistics about changes
typolima site/ --lang cs --verbose
Shows: Changed files count, quotes fixed, dashes converted, NBSP inserted.
# .typolimarc example
language: cs
recursive: true
exclude:
- "_*"
- "*.min.*"
Place .typolimarc in your project root to set default options.