Skip to main content
= French Typo
Dhrions
Version 1.0.0, 27/07/2026
:sectnums:
:toc:
:toclevels: 3
:toc-title: Sommaire
:description: Moteur de correction typographique française (core Python, CLI, intégrations)
:keywords: typographie française, espaces insécables, Python, CLI, Anki, AsciiDoc
:icons: font

image::french-typo.png[French Typo,width=300,align=center]

ifdef::env-github[]
image:https://img.shields.io/badge/version-1.0.0-blue[]
image:https://img.shields.io/badge/license-MIT-green[]
image:https://img.shields.io/badge/python-3.8%2B-blue[]
endif::[]

== ⚡ TL;DR

* 📝 Corrige la typographie française usuelle (espaces insécables, unités, ordinaux) d'un texte, d'un fichier AsciiDoc ou d'une note Anki
* 🎯 Quand : en bibliothèque Python dans un autre outil, en CLI sur des fichiers `.adoc`, ou comme add-on Anki
* 🚀 `french-typo mon_fichier.adoc` — corrige un fichier AsciiDoc en place

== 📖 Introduction

**French Typo** est un moteur de correction typographique française écrit en Python.

Il applique automatiquement les règles typographiques françaises usuelles (conformes au
link:https://les-unpertinents.fr/Manuscrits/Lexique%20des%20r%C3%A8gles%20typographiques%20en%20usage%20%C3%A0%20l%27Imprimerie%20nationale2.pdf[lexique de l’Imprimerie nationale]) :

* 📏 espaces insécables avant les ponctuations doubles (`: ; ? ! % €`),
* 🔠 normalisation des unités (`KM` → `km`, `KG` → `kg`, etc.),
* 🔢 formatage des ordinaux (`1er` → `1<sup>er</sup>`, `n°4` → `n<sup>o</sup>4`),
* ✂️ suppression des espaces multiples,
* 🔤 gestion des guillemets français doubles et simples (« » et ‹ ›),
* 👤 espaces insécables après les abréviations usuelles (`M. Dupont`, `Dr Martin`, `St Étienne`).

Le projet est structuré autour :
* 🧩 d’un **core Python pur**, réutilisable partout ;
* 💻 d’une **CLI** pour le traitement de fichiers ;
* 🔌 d’**adaptateurs** pour des environnements spécifiques (Anki, AsciiDoc).

---

== ✨ Fonctionnalités

* ✅ Moteur typographique indépendant (sans dépendance UI)
* ✅ API Python simple et stable
* ✅ Interface en ligne de commande
* ✅ Support d’AsciiDoc
* ✅ Intégration Anki (HTML + cloze)
* ✅ Tests unitaires couvrant le core

---

== 🚀 Installation

=== Installation via pip (recommandée)

[source,bash]
----
pip install french-typo
----

---

== 💻 Utilisation

=== Utilisation en tant que bibliothèque Python

[source,python]
----
from french_typo import format_text

text = "Voir n°4 : 10 KM et article 5."
result = format_text(text, add_nbsp_enabled=True)

print(result)
# Voir n<sup>o</sup>&nbsp;4&nbsp;: 10&nbsp;km et article&nbsp;5.
----

`add_nbsp_enabled` insère les espaces insécables (`&nbsp;`) ; désactivé par défaut.

---

=== Utilisation via la CLI

French Typo fournit une commande `french-typo` pour corriger des fichiers AsciiDoc.

[source,bash]
----
french-typo mon_fichier.adoc
----

Ou récursivement sur un dossier :

[source,bash]
----
french-typo docs/
----

Par défaut, seules les règles typographiques hors espaces insécables sont appliquées
(unités, ordinaux, espaces superflues…). Pour ajouter les espaces insécables :

[source,bash]
----
french-typo --nbsp mon_fichier.adoc
----

Les fichiers sont modifiés *in place*.

---

== 🔗 Intégrations

=== Anki

Le moteur expose un adaptateur Anki (`french_typo.adapters.anki`) qui applique la typographie au
HTML des champs de notes :

* 🔤 gestion des cloze (`{{c1::...}}`) et du HTML ;
* 🚫 attributs des balises HTML (`src`, `href`, `style`…) jamais modifiés : ce ne sont pas du texte ;
* 📝 espaces insécables adaptés au rendu Anki.

L’add-on Anki qui consomme cet adaptateur vit dans un dépôt séparé :
link:https://github.com/dhrions/anki-french-typo[anki-french-typo].

---

=== AsciiDoc

L’adaptateur AsciiDoc permet de corriger automatiquement :

* 📄 les paragraphes standards ;
* 🚫 en ignorant les blocs littéraux (`----`) ;
* 🚫 en ignorant les commentaires (`//`) ;
* 🔤 en ignorant les marqueurs structurels (titres `= …`, attributs `:clé: valeur`,
chemins relatifs `./…`) et les URL, jamais touchés par les règles typographiques ;
* 🈳 en écrivant le vrai caractère insécable Unicode (`U+00A0`), pas l’entité HTML
`&nbsp;` — celle-ci reste réservée à l’adaptateur Anki, pensé pour du HTML. Un fichier
déjà formaté par une version antérieure de l’outil (avec l’entité) est relu et
reconnu correctement.

---

== 🏗️ Architecture du projet

[source]
----
french-typo/
├── french_typo/
│ ├── core/ # Moteur typographique pur
│ ├── adapters/ # Intégrations (Anki, AsciiDoc)
│ └── cli.py # Interface CLI
└── tests/ # Tests unitaires
----

Le dépôt ne contient que le moteur et sa CLI. Les intégrations applicatives (comme l’add-on
link:https://github.com/dhrions/anki-french-typo[anki-french-typo]) vivent dans leurs propres
dépôts et consomment `french-typo` depuis PyPI.

---

== 🛠️ Développement

=== Installation pour le développement

[source,bash]
----
git clone https://github.com/dhrions/french-typo.git
cd french-typo
python -m venv env
source env/bin/activate
pip install -e ".[dev]"
----

=== Exécuter les tests

[source,bash]
----
pytest
----

---

== 💭 Philosophie du projet

* 🧱 séparation stricte entre **moteur** et **interfaces** ;
* 🎯 API simple, explicite, testée ;
* 🪶 aucune dépendance lourde dans le core ;
* 🔮 extensible vers d’autres formats (Markdown, LaTeX, etc.).

---

== 🗺️ Feuille de route

Les jalons du projet sont décrits dans link:ROADMAP.md[ROADMAP.md] ; le backlog technique
détaillé vit dans link:TODO.md[TODO.md].

---

== 📜 Licence

Ce projet est distribué sous licence MIT.
Voir le fichier link:LICENSE[LICENSE].

Metadata

Release files for french-typo 1.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for french-typo 1.6.1
File Size Uploaded Provenance Actions
french_typo-1.6.1.tar.gz 16.9 kB With provenance Details for french_typo-1.6.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for french-typo 1.6.1
File Interpreter ABI Platform Actions
french_typo-1.6.1-py3-none-any.whl Python 3 none any Details for french_typo-1.6.1-py3-none-any.whl

Total release size: 34.8 kB

Release files / french_typo-1.6.1.tar.gz

Download URL french_typo-1.6.1.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0cd4983ac97d521589353cb1b952af9c1c5ee9dd68211e005ef6c62aecce5e6c
BLAKE2b-256 checksum
How to use checksums
7dd6dc84359ee40350f562b719ae902a23c2bfd5eec0087dbab9f74f47fb46fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / french_typo-1.6.1-py3-none-any.whl

Download URL french_typo-1.6.1-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6dca96aaf8de5dd28fed06907a743a841e4ee6084ab31fed4115aa9721cbc6ef
BLAKE2b-256 checksum
How to use checksums
fdd6512d077b69492ecb570259ce9f73c2b92471835ea1a03571f8b175f38e69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Security for french-typo 1.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for french_typo-1.6.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page