polytypo
Locale-correct quotes, dashes, ellipses, apostrophes, symbols and no-break spaces —
one portable spec, designed for byte-identical output across runtimes.
Try it live, no install: polytypo.dev
This is the Python implementation. The full spec — all locales, all rules, worked examples in
each — lives in polytypo/polytypo. This runtime supports
the text and html modes fully, and markdown for the commonmark dialect only — mdx
raises POLYTYPO_INVALID_DIALECT (no MDX/JSX parser is available for Python; see
Supported dialects).
Install
pip install polytypo
Usage
from polytypo import transform
transform("She said, \"it's fine\" -- but I wasn't sure...", locale="en-US")
# She said, “it’s fine”—but I wasn’t sure…
Same input, one locale changed — quotes, dash spacing and all follow the target locale, not a single hardcoded style:
transform('Sie sagte: "Alles gut" -- aber ich war mir nicht sicher...', locale="de-DE")
# Sie sagte: „Alles gut“ – aber ich war mir nicht sicher…
HTML and Markdown are first-class modes, not an afterthought — tags, attributes and fenced code are left alone; only text content is touched:
from polytypo.html import transform
transform('<a title="test... wait">Wait... she said "go on."</a>', locale="en-US")
# <a title="test... wait">Wait… she said “go on.”</a>
polytypo.text, polytypo.html and polytypo.markdown each exclude the parser dependency the
other modes don't need (importing polytypo.text never imports html.parser-based span
extraction or tree-sitter). The aggregate polytypo module supports every mode via a mode
keyword, defaulting to "text". locale has no default anywhere and must always be passed
explicitly — there is no silent fallback to English.
import polytypo
polytypo.transform("...", locale="fr", mode="markdown", dialect="commonmark")
Supported dialects
markdown mode requires a dialect keyword, exactly as the spec requires (no default,
detection is forbidden). This runtime supports dialect="commonmark" (CommonMark plus GFM —
tables, strikethrough, task lists, autolink literals). dialect="mdx" is a real dialect the spec
names, but this runtime has no MDX/JSX parser for it and raises POLYTYPO_INVALID_DIALECT
immediately rather than silently mishandling it — a narrower, honest conformance claim, not a
port defect.
Licence
MIT. See LICENSE.
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 polytypo-1.0.1.tar.gz.
File metadata
- Download URL: polytypo-1.0.1.tar.gz
- Upload date:
- Size: 246.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94011b8a1484835144faa261c0333f64f6026752983df5971f803672e5c9db87
|
|
| MD5 |
0cccf48f675b55a3a24b5135f7f20f18
|
|
| BLAKE2b-256 |
28122bf583fafd249987ef6185ed8477fe9893f24db93c84d72bc7e81dd522ce
|
Provenance
The following attestation bundles were made for polytypo-1.0.1.tar.gz:
Publisher:
release.yml on polytypo/polytypo-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polytypo-1.0.1.tar.gz -
Subject digest:
94011b8a1484835144faa261c0333f64f6026752983df5971f803672e5c9db87 - Sigstore transparency entry: 2761358526
- Sigstore integration time:
-
Permalink:
polytypo/polytypo-python@9b7649855d49ef7bf96af5f316c821d573e4d237 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/polytypo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9b7649855d49ef7bf96af5f316c821d573e4d237 -
Trigger Event:
push
-
Statement type:
File details
Details for the file polytypo-1.0.1-py3-none-any.whl.
File metadata
- Download URL: polytypo-1.0.1-py3-none-any.whl
- Upload date:
- Size: 90.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cb471060e3adf19bfa5babeea5947a4980bb1bf388d0dc3bae0f637f7688a14
|
|
| MD5 |
3d221bec28adf922239b116c90954bd3
|
|
| BLAKE2b-256 |
bc58628669303164492f9ceabe18982789508287ec20eac6a76eaffe11c75bbf
|
Provenance
The following attestation bundles were made for polytypo-1.0.1-py3-none-any.whl:
Publisher:
release.yml on polytypo/polytypo-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polytypo-1.0.1-py3-none-any.whl -
Subject digest:
7cb471060e3adf19bfa5babeea5947a4980bb1bf388d0dc3bae0f637f7688a14 - Sigstore transparency entry: 2761358545
- Sigstore integration time:
-
Permalink:
polytypo/polytypo-python@9b7649855d49ef7bf96af5f316c821d573e4d237 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/polytypo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9b7649855d49ef7bf96af5f316c821d573e4d237 -
Trigger Event:
push
-
Statement type: