Skip to main content

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>&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/
----

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

french_typo-1.2.1.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

french_typo-1.2.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file french_typo-1.2.1.tar.gz.

File metadata

  • Download URL: french_typo-1.2.1.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for french_typo-1.2.1.tar.gz
Algorithm Hash digest
SHA256 a4b2143d0f52083f883390768b0f2f522d9a0db88e3a25dd2c1a02ab6adf6be5
MD5 dd3b61c14555f480733b57363f33b542
BLAKE2b-256 00637a63725d479151f1180a5bf43a178005b46f184673126c61112ef871cdf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for french_typo-1.2.1.tar.gz:

Publisher: release.yml on dhrions/french-typo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file french_typo-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: french_typo-1.2.1-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

Hashes for french_typo-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a030992b86c6ec027579347aa2265e5fd88df33a6341cf847fe9314461c2e08
MD5 38126019cf2657a1e36b1537e260af56
BLAKE2b-256 b03753271d1318a6fea9657e79e142f865fcd524d82f307df9515867b214778c

See more details on using hashes here.

Provenance

The following attestation bundles were made for french_typo-1.2.1-py3-none-any.whl:

Publisher: release.yml on dhrions/french-typo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page