TypoLima GitHub

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
Before

Řekl "Ahoj" -- a šel k lesu za 5 kg.

After · --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.

„Text“cs · sk · de · bg · et
99 below, 66 above
„Text”pl · hu · ro · hr · sl
99 below, 99 above
“Text”en · nl · tr · vi
66 above, 99 above
« Text »fr · it · es · ru · uk
»Text«da (reversed guillemets)
”Text”sv · fi (same mark both sides)

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,5NBSP after short words
caCatalà«text» “text”1.234,5NBSP after short words
csČeština„text“ ‚text‘1 234,5NBSP after short words, abbreviations
daDansk»text« ‘text’1.234,5NBSP after short words
deDeutsch„text“ ‚text‘1.234,5NBSP after short words
elΕλληνικά«text» “text”1.234,5NBSP after short words, abbreviations
en-GBEnglish (UK)‘text’ “text”1,234.5NBSP after short words
en-USEnglish (US)“text” ‘text’1,234.5NBSP after short words
enEnglish“text” ‘text’1,234.5NBSP after short words
eoEsperanto«text» “text”1 234,5NBSP after short words
esEspañol«text» “text”1.234,5NBSP after short words
etEesti„text“ ‘text’1 234,5NBSP after short words
fiSuomi”text” ’text’1 234,5NBSP after short words
frFrançais«text» ‹text›1 234,5NBSP after short words, space before ? ! : ; %
hrHrvatski„text” ‘text’1.234,5NBSP after short words
huMagyar„text” »text«1 234,5NBSP after short words
idBahasa Indonesia“text” ‘text’1.234,5NBSP after short words
itItaliano«text» “text”1.234,5NBSP after short words
nlNederlands“text” ‘text’1.234,5NBSP after short words
noNorsk«text» ‘text’1 234,5NBSP after short words
plPolski„text” «text»1 234,5NBSP after short words
pt-BRPortuguês (Brasil)“text” ‘text’1.234,5NBSP after short words
pt-PTPortuguês (Portugal)«text» “text”1.234,5NBSP after short words
ptPortuguês«text» “text”1.234,5NBSP after short words
roRomână„text” «text»1.234,5NBSP after short words
ruРусский«text» „text“1 234,5NBSP after short words
skSlovenčina„text“ ‚text‘1 234,5NBSP after short words, abbreviations
slSlovenščina„text” ‘text’1.234,5NBSP after short words
svSvenska”text” ’text’1 234,5NBSP after short words
swKiswahili“text” ‘text’1,234.5NBSP after short words
tlTagalog“text” ‘text’1,234.5NBSP after short words
trTürkçe“text” ‘text’1.234,5NBSP after short words
ukУкраїнська«text» „text“1 234,5NBSP after short words
viTiếng Việt“text” ‘text’1.234,5NBSP 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

--lang, -l
Language code (cs, en, fr, de, en-GB, pt-BR, …)
--auto-detect, -a
Detect language from the HTML lang attribute, filename or .typolimarc
--in-place, -i
Modify files in place (default: output to stdout)
--backup, -b
Create a .bak backup first (requires --in-place)
--dry-run
Show what would change without modifying anything
--diff
Show a detailed diff
--recursive, -r
Process directories recursively
--aggressive
Also convert (c) → ©, +- → ±, -> → → and similar
--preserve-format
HTML only: edit text in place without re-serializing the document
--include PATTERN
Only process files matching the glob (repeatable)
--exclude PATTERN
Skip files matching the glob (repeatable)
--verbose, -v
Show statistics: quotes, dashes, NBSP and other changes

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.

Ready to polish your text?

TypoLima is free and open source (MIT).

View on GitHub →