Skip to main content

Moteur de correction typographique française

Project description

= French Typo
Dhrions
0.2.0
: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-0.2.0-blue[]
image:https://img.shields.io/badge/license-MIT-green[]
image:https://img.shields.io/badge/python-3.8%2B-blue[]
endif::[]

== 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.core.formatter import format_text
from french_typo.core.profiles import TypoProfile

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

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

=== Profils disponibles

* `TypoProfile.PLAIN` : texte brut
* `TypoProfile.ANKI` : HTML + cloze Anki
* `TypoProfile.ASCIIDOCT` : texte AsciiDoc

[source,python]
----
format_text("« {{c1::test}} »", profile=TypoProfile.ANKI)
----

---

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

---

== 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 .
pip install -r requirements.txt
----

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

french_typo-1.0.0.tar.gz (11.2 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.0.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for french_typo-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4c9c59d7b3813c3f9b6ed231a5e179b419ccebcc36560b226b1b465d6347a532
MD5 5c7fa6e840e6201521293160e9842e6a
BLAKE2b-256 33e63db9000788ab31e1f0cac5b1bd7c9b8813977e4d2f25b6121f17c1c5194e

See more details on using hashes here.

Provenance

The following attestation bundles were made for french_typo-1.0.0.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.0.0-py3-none-any.whl.

File metadata

  • Download URL: french_typo-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for french_typo-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98e82bf487d1c67cb918de12113ebfb81f19f76dfb8b981d3868bd4e39226254
MD5 e8ff05acf6b991de673c5877feafdd98
BLAKE2b-256 d419c8fc8405312ba9520b0955e4b039eeff8307e80a1ec298fa9210a34c84c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for french_typo-1.0.0-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