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

Applique les règles typographiques françaises usuelles (espaces insécables, unités, ordinaux,
guillemets, abréviations) via un core Python pur, que reprennent une CLI pour les fichiers
AsciiDoc et un adaptateur pour les notes Anki. La CLI réécrit les `.adoc` en place sans toucher
aux blocs littéraux, commentaires, titres ni attributs, et n'ajoute les espaces insécables
qu'avec `--nbsp`.

🎯 Quand : pour la seule typographie ; sur une doc AsciiDoc, `adocx` (dépôt `asciidoc-utils`)
y ajoute ses règles éditoriales et la vérification des liens.

[source,bash]
----
pip install french-typo
# corriger en place un fichier ou un dossier AsciiDoc
french-typo docs/
----

== 📐 Règles appliquées

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`).

---

== ✨ 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
----

L'outil ponctue aussi les fins d'items de liste (`;` pour les intermédiaires, `.` pour le
dernier). Pour ne pas y toucher :

[source,bash]
----
french-typo --nbsp --no-list-punctuation 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, de code et de formule (`----`, `....`, `++++`) ;
* 🚫 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 ;
* 🔒 sans jamais modifier ce qui n'est pas du texte : formules (`stem:[…]`, `latexmath:[…]`),
cible des macros (`link:`, `xref:`, `image:`…), URL, code inline et renvois `<<…>>`. Le
libellé entre crochets d'un lien reste corrigé ;
* 🔢 en écrivant les ordinaux en exposant AsciiDoc (`1^er^`, `2^e^`, `n^o^`), pas en HTML ;
* 📋 en ponctuant les fins d'items de liste, sauf avec `--no-list-punctuation` ; un item
qui se termine par `:`, `?`, `!` ou `…` garde sa ponctuation ;
* 🈳 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.7.0

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.7.0
File Size Uploaded Provenance Actions
french_typo-1.7.0.tar.gz 19.1 kB With provenance Details for french_typo-1.7.0.tar.gz

Built distribution (wheel)

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

Total release size: 39.4 kB

Release files / french_typo-1.7.0.tar.gz

Download URL french_typo-1.7.0.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c5329415319169c8701afd0c6327120b1f61839191c03f7535d42f9fef18b026
BLAKE2b-256 checksum
How to use checksums
49fd4c8808286ffea2f79de3ab9facb53f2aba3dd0a2da63af5d6d553ea4840e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 1, 2026.

Transparency log

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

Download URL french_typo-1.7.0-py3-none-any.whl
Size 20.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8cccd0ff78e19445e326991cf612cc7051bbafd1d7488c3ec50709a3a74cbc12
BLAKE2b-256 checksum
How to use checksums
59f2c396088aaacd5c182634408202ef5e03d80792e589e0bcbb3905fe31befe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 1, 2026.

Transparency log

Security for french-typo 1.7.0

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.7.0.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 Nov 1, 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