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 dépôt contient une intégration Anki historique (`format_anki_notes/`), qui utilise le moteur
`french_typo.core` pour formater les champs des notes :
* 📝 formatage d’une note individuelle ;
* 📚 formatage par lot depuis le navigateur ;
* 🔤 gestion des cloze (`{{c1::...}}`) et du HTML.
⚠️ Cette partie dépend de l’API Anki (`aqt`) et **n’est pas incluse dans le paquet PyPI**.
---
=== 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
├── format_anki_notes/ # Add-on Anki (hors PyPI)
└── tests/ # Tests unitaires
----
`format_anki_notes/` (add-on Anki legacy, exclu du build pip via `exclude` dans `pyproject.toml`) dépend de `french_typo/`, publié séparément sur 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.).
---
== 📜 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.1.0.tar.gz.
File metadata
- Download URL: french_typo-1.1.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6011c34296e4bf5fcdf82aa6794d39f6e7edc648c2827d7898677dcf6b9021b0
|
|
| MD5 |
e0c97f1dd18ef8f755876fd14b0c6712
|
|
| BLAKE2b-256 |
bc1c0ce4a9723c5098b80526ce7cd20185026c27b6daf2554104304eeb9bea7f
|
Provenance
The following attestation bundles were made for french_typo-1.1.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.1.0.tar.gz -
Subject digest:
6011c34296e4bf5fcdf82aa6794d39f6e7edc648c2827d7898677dcf6b9021b0 - Sigstore transparency entry: 2257138630
- Sigstore integration time:
-
Permalink:
dhrions/french-typo@240ee12373e2444d89daf9c6e2df5a2349b9e2f8 -
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@240ee12373e2444d89daf9c6e2df5a2349b9e2f8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file french_typo-1.1.0-py3-none-any.whl.
File metadata
- Download URL: french_typo-1.1.0-py3-none-any.whl
- Upload date:
- Size: 12.7 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 |
6e0d43624f386b93dfbf9e1a75c22d94b7bdfcda10472dda5188bccad5c17146
|
|
| MD5 |
b0fff82e6a6fca1f68a43703227742b1
|
|
| BLAKE2b-256 |
bf7a7d9009f1df36883a303a26365f114f3a4885a500a5e3724c2ef1daca56b3
|
Provenance
The following attestation bundles were made for french_typo-1.1.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.1.0-py3-none-any.whl -
Subject digest:
6e0d43624f386b93dfbf9e1a75c22d94b7bdfcda10472dda5188bccad5c17146 - Sigstore transparency entry: 2257138640
- Sigstore integration time:
-
Permalink:
dhrions/french-typo@240ee12373e2444d89daf9c6e2df5a2349b9e2f8 -
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@240ee12373e2444d89daf9c6e2df5a2349b9e2f8 -
Trigger Event:
push
-
Statement type: