TypoLima is a tiny, conservative command-line tool that fixes common typographic issues in HTML, PHP, Hugo templates and plain text files according to language-specific rules.
Why the name? TypoLima combines "Typo" with the Latin word lima (file/polish), which was used by classical authors to describe the final, meticulous polishing of a literary work (labor limae).
It only touches text content (never tags, attributes, scripts, style blocks, Hugo {{ }} shortcodes etc.) and prefers to do nothing rather than risk breaking something.
- Smart curly quotes („ “ for cs, « » for fr, etc.)
- Non-breaking spaces after single-letter prepositions (cs, de, fr …)
- NBSP before units (5 kg, 20 %)
- Intelligent dashes (en-dash
–for ranges10–20, or parenthetical thoughts with NBSP) - Common abbreviations (cs:
s. r. o.,tj.,tzn.) - Automatic units & symbols:
m2→m²,cm3→cm³ - Smart prices:
100,-→100,– - Correct thousands / decimal separators per language
- Spaces around punctuation (especially French style: ? ! : ;)
- Aggressive mode:
(c)→©,+-→±,->→→etc. - Very conservative – skips uncertain cases
- Works on HTML, PHP, Hugo templates, Markdown …
European: cs, sk, pl, en (en-US, en-GB), de, fr, it, es, pt (pt-PT, pt-BR), nl, hu, ro, bg, uk, ru, el, fi, sv, no, da, hr, sl, et, ca
Other: tr, vi, id, tl (Tagalog), sw (Swahili), eo (Esperanto)
Run typolima --lang cs (use any supported code) to process files.
Option A – via Homebrew (Recommended for macOS)
If you use Homebrew, you can install TypoLima directly from the heptau tap:
brew install heptau/tap/typolimaOption B – via pip (from GitHub)
pip install git+https://github.com/heptau/typolima.gitOption C – From source
git clone https://github.com/heptau/typolima.git
cd typolima
pip install .typolima --help
# Basic usage
typolima article.html --lang cs --in-place
# Show what would change (very useful!)
typolima public/**/*.html --lang fr --dry-run --diff
# Process whole Hugo output
typolima public/ --lang cs --recursive --in-place
# More aggressive mode (convert (c) to ©, +- to ± etc.)
typolima text.md --lang en --aggressive
# Include only specific file types
typolima content/ --lang cs --recursive --include "*.html" --include "*.md"
# Exclude certain files (e.g., partials, includes)
typolima public/ --lang de --recursive --exclude "_*"
# Combine include and exclude
typolima site/ --lang fr --recursive --include "*.html" --exclude "*.min.html"
# With backup (creates .bak files)
typolima *.html --lang cs --in-place --backup
# Auto-detect language from HTML lang attribute, filename, or .typolimarc
typolima site/ --recursive --auto-detect
# Show detailed statistics about changes (quotes, dashes, NBSP count)
typolima site/ --lang cs --verbose{
"scripts": {
"postbuild": "typolima public/**/*.html --lang cs --in-place"
}
}- Only replaces obvious straight quotes → curly
- NBSP after prepositions only when very clear context
- Skips anything inside
,, <script>, {{ … }}, --dry-run --diffalways shows colorful diff first
--lang cs – Czech
--lang en – English (default)
--lang en-US / --lang en-GB – US/UK English variants
--lang pt-BR / --lang pt-PT – Portuguese variants
- See
--help for full list
# Process multiple file types
typolima content/ --lang cs --recursive --dry-run
# Fix specific extensions only
typolima site/*.html site/*.php --lang de --in-place
# Show detailed diff before applying
typolima public/ --lang fr --diff --dry-run
# Include only specific file patterns (glob)
typolima site/ --lang cs --recursive --include "*.html"
# Exclude files matching pattern
typolima public/ --lang de --recursive --exclude "_*"
# Create backup before in-place changes
typolima site/ --lang cs --in-place --backup
# Auto-detect language from HTML lang attribute, filename pattern, or .typolimarc
typolima site/ --recursive --auto-detect
Create a .typolimarc file in your project root for default settings:
language: cs
recursive: true
exclude:
- "_*"
- "*.min.*"
Example file: .typolimarc.example
"Error: missing dependencies"
pip install beautifulsoup4 lxml pyyaml
"Rules file not found"
Make sure you're using a valid language code from the supported list.
File not changing?
- Use
--dry-run --diff to see what would be changed
- Check if file has proper UTF-8 encoding
- Ensure text contains patterns matching the language rules
Performance issues with many files?
Use --recursive flag which enables caching and optimizations.
- Contributing: Please see CONTRIBUTING.md for guidelines on how to add new languages or report issues.
- License: This project is licensed under the MIT License.