Skip to main content

polytypo

polytypo

PyPI version CI PyPI downloads License: MIT

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.

Release files for polytypo 1.2.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 polytypo 1.2.0
File Size Uploaded
polytypo-1.2.0.tar.gz 252.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for polytypo 1.2.0
File Interpreter ABI Platform
polytypo-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 343.4 kB

Release files / polytypo-1.2.0.tar.gz

Download URL polytypo-1.2.0.tar.gz
Size 252.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b8ad1fe28af425fb92ad30889ec09a5bdc2d5618df971c57ca28c4d5eec94958
BLAKE2b-256 checksum
How to use checksums
b3c2345a1296971884d713a5d2ce0f467dea433692fcd8ccf839c3e2f6e68a46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 17, 2026.

Transparency log

Release files / polytypo-1.2.0-py3-none-any.whl

Download URL polytypo-1.2.0-py3-none-any.whl
Size 91.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
effa80c662b0838bde1104468b430ef7f0737ed1f2ab7c202463fe19d2909ed1
BLAKE2b-256 checksum
How to use checksums
277b6382b0bb8427601658bbcb5a3b6790c3321ea4673c0a811e241b6249b48c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 17, 2026.

Transparency log

Release history Release notifications | RSS feed

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

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