Labor limae for the web
Typography, polished — never broken.
TypoLima fixes quotes, dashes, non-breaking spaces and number formats in HTML, PHP, Hugo templates, Markdown and plain text. It only touches text — never tags, scripts or template code.
brew install heptau/tap/typolima
Řekl "Ahoj" -- a šel k lesu za 5 kg.
--lang cs
Řekl „Ahoj“ – a šel k lesu za 5 kg.
marks a non-breaking space, so a line never ends on a lone “k” or splits “5 kg”.
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. When in doubt, it does nothing. Its name comes from the Latin lima (file, polish) — the final meticulous smoothing of a text, labor limae.
- HTML tags and attributes untouched
<script>,<style>,<code>,<pre>skipped- Hugo
{{ }}and PHP<?php ?>skipped - Markdown front matter and code blocks skipped
- ISO dates, IDs, URLs and codes left alone
- Dry run and diff before any file is written
Features
Each rule is defined per language in a small YAML file, so the same tool does the right thing in Czech, French and English.
Smart quotes
Straight quotes become the right pair for the language, including nested quotes: „a ‚b‘ c“ in Czech, « a ‹ b › c » in French.
Non-breaking spaces
Inserted after single-letter prepositions (cs: v, s, z, k, o, u, a, i) and between a number and its unit or currency: 5 kg, 20 %, 10 €.
Dashes and ellipsis
-- becomes an en dash and --- an em dash, ranges become 10–20, and ... becomes …. Hyphens in ISO dates stay as they are.
Numbers and prices
Thousands and decimal separators per language (1 234,5 vs. 1,234.5), price dashes (100,- → 100,–) and m2 → m². IČO, IDs and PSČ are never regrouped.
Punctuation spacing
French spacing before ? ! : ; % and after «. Spaces after sentence-ending periods are fixed without tearing abbreviations such as Ph.D. or s. r. o.
Aggressive mode
Opt-in symbols: (c) → ©, (r) → ®, (tm) → ™, +- → ±, -> → →, ==> → ⟹.
Byte-for-byte HTML
--preserve-format edits text nodes in place, so attribute order, self-closing style and whitespace stay identical and the diff shows only real typographic changes.
Auto-detection
Picks the language from <html lang>, a filename such as article.cs.html, or your .typolimarc.
Why quotes differ by language
Each language has its own pair. They look similar, but they are not interchangeable.
99 below, 66 above
99 below, 99 above
66 above, 99 above
Czech uses „ and “ (U+201E and U+201C): the opening mark sits on the baseline like a 99, the closing mark sits at the top like a 66. If your Czech page shows “ ” (66 and 99 both on top), the cause is almost always the text (a wrong closing mark ” U+201D, or the wrong language setting) or a font that draws „ poorly, not the rules.
Tip: put lang="cs" on the page or element, and use a font with proper Central European glyphs (Source Serif 4, Inter and JetBrains Mono all qualify). Browsers use lang to pick language-appropriate glyph variants.
Supported languages
34 language variants, each with its own quotes, number format and spacing rules. This table is generated from the rule files.
| Code | Language | Quotes | Number | Special rules |
|---|---|---|---|---|
bg | Български | „text“ ‘text’ | 1 234,5 | NBSP after short words |
ca | Català | «text» “text” | 1.234,5 | NBSP after short words |
cs | Čeština | „text“ ‚text‘ | 1 234,5 | NBSP after short words, abbreviations |
da | Dansk | »text« ‘text’ | 1.234,5 | NBSP after short words |
de | Deutsch | „text“ ‚text‘ | 1.234,5 | NBSP after short words |
el | Ελληνικά | «text» “text” | 1.234,5 | NBSP after short words, abbreviations |
en-GB | English (UK) | ‘text’ “text” | 1,234.5 | NBSP after short words |
en-US | English (US) | “text” ‘text’ | 1,234.5 | NBSP after short words |
en | English | “text” ‘text’ | 1,234.5 | NBSP after short words |
eo | Esperanto | «text» “text” | 1 234,5 | NBSP after short words |
es | Español | «text» “text” | 1.234,5 | NBSP after short words |
et | Eesti | „text“ ‘text’ | 1 234,5 | NBSP after short words |
fi | Suomi | ”text” ’text’ | 1 234,5 | NBSP after short words |
fr | Français | «text» ‹text› | 1 234,5 | NBSP after short words, space before ? ! : ; % |
hr | Hrvatski | „text” ‘text’ | 1.234,5 | NBSP after short words |
hu | Magyar | „text” »text« | 1 234,5 | NBSP after short words |
id | Bahasa Indonesia | “text” ‘text’ | 1.234,5 | NBSP after short words |
it | Italiano | «text» “text” | 1.234,5 | NBSP after short words |
nl | Nederlands | “text” ‘text’ | 1.234,5 | NBSP after short words |
no | Norsk | «text» ‘text’ | 1 234,5 | NBSP after short words |
pl | Polski | „text” «text» | 1 234,5 | NBSP after short words |
pt-BR | Português (Brasil) | “text” ‘text’ | 1.234,5 | NBSP after short words |
pt-PT | Português (Portugal) | «text» “text” | 1.234,5 | NBSP after short words |
pt | Português | «text» “text” | 1.234,5 | NBSP after short words |
ro | Română | „text” «text» | 1.234,5 | NBSP after short words |
ru | Русский | «text» „text“ | 1 234,5 | NBSP after short words |
sk | Slovenčina | „text“ ‚text‘ | 1 234,5 | NBSP after short words, abbreviations |
sl | Slovenščina | „text” ‘text’ | 1.234,5 | NBSP after short words |
sv | Svenska | ”text” ’text’ | 1 234,5 | NBSP after short words |
sw | Kiswahili | “text” ‘text’ | 1,234.5 | NBSP after short words |
tl | Tagalog | “text” ‘text’ | 1,234.5 | NBSP after short words |
tr | Türkçe | “text” ‘text’ | 1.234,5 | NBSP after short words |
uk | Українська | «text» „text“ | 1 234,5 | NBSP after short words |
vi | Tiếng Việt | “text” ‘text’ | 1.234,5 | NBSP after short words |
Installation
Python 3.9+ is needed for pip and source installs. The Homebrew build is a standalone binary that runs on both Intel and Apple Silicon Macs.
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 .
Prebuilt binaries are on the Releases page.
Usage
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 --preserve-format
In package.json: "postbuild": "typolima public/ --lang cs --recursive --in-place"
Aggressive mode
typolima text.md --lang en --aggressive
Converts (c) → ©, (tm) → ™, -> → →, ==> → ⟹.
Include and exclude
# Only HTML files
typolima site/ --lang cs --recursive --include "*.html"
# Skip partials (files starting with _)
typolima public/ --lang de --recursive --exclude "_*"
# HTML but not minified
typolima site/ --lang fr --include "*.html" --exclude "*.min.html"
Backup before in-place changes
typolima site/ --lang cs --in-place --backup
Creates files such as index.html.bak before modifying the originals.
Auto-detect language
typolima site/ --recursive --auto-detect
Detects the language from <html lang="fr">, a filename like article.cs.html, or your .typolimarc.
Verbose statistics
typolima site/ --lang cs --verbose
Shows how many files changed and how many quotes, dashes and non-breaking spaces were fixed.
Config file
# .typolimarc
language: cs
recursive: true
preserve_format: true
exclude:
- "_*"
- "*.min.*"
Place .typolimarc in your project root to set default options.