Moteur de correction typographique française
Project description
= 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
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 (« »).
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> 4 : 10 km et article 5.
----
`add_nbsp_enabled` insère les espaces insécables (` `) ; 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/
----
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 ;
* 📝 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 (`//`).
---
== 🏗️ 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].
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file french_typo-1.2.0.tar.gz.
File metadata
- Download URL: french_typo-1.2.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d808961916c8a71c00b5fd714192ebad2eeb3ceb605f37c960b7216d6a5a63da
|
|
| MD5 |
8f664d580bad7327183d0fa35e6ce3fe
|
|
| BLAKE2b-256 |
e4f253208f185afd1fb61bde3e13fafc2b0e375099a59bd6bdf5fb704ead4f32
|
Provenance
The following attestation bundles were made for french_typo-1.2.0.tar.gz:
Publisher:
release.yml on dhrions/french-typo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
french_typo-1.2.0.tar.gz -
Subject digest:
d808961916c8a71c00b5fd714192ebad2eeb3ceb605f37c960b7216d6a5a63da - Sigstore transparency entry: 2257303014
- Sigstore integration time:
-
Permalink:
dhrions/french-typo@3ad70c58e21a8ce7d49a70fe6c14301c0b591b2d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dhrions
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3ad70c58e21a8ce7d49a70fe6c14301c0b591b2d -
Trigger Event:
push
-
Statement type:
File details
Details for the file french_typo-1.2.0-py3-none-any.whl.
File metadata
- Download URL: french_typo-1.2.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf8d7f0b4fd457601a194cf1c6fcaec0d3f255f1261b33257d529e22f9aad882
|
|
| MD5 |
990cf896d8089f18b9a91f785ed6044a
|
|
| BLAKE2b-256 |
31b79d6228b7c9e26b0254f914b2ae825d694ff41a0f41d9edd3d98483106aed
|
Provenance
The following attestation bundles were made for french_typo-1.2.0-py3-none-any.whl:
Publisher:
release.yml on dhrions/french-typo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
french_typo-1.2.0-py3-none-any.whl -
Subject digest:
cf8d7f0b4fd457601a194cf1c6fcaec0d3f255f1261b33257d529e22f9aad882 - Sigstore transparency entry: 2257303024
- Sigstore integration time:
-
Permalink:
dhrions/french-typo@3ad70c58e21a8ce7d49a70fe6c14301c0b591b2d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dhrions
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3ad70c58e21a8ce7d49a70fe6c14301c0b591b2d -
Trigger Event:
push
-
Statement type: