polytypo 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -10
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/polytypo/polytypo/main/brand/logo/polytypo-lockup-stacked.svg" alt="polytypo" width="260">
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
spec, designed for byte-identical output across runtimes.
|
|
5
|
+
<h1 align="center">polytypo</h1>
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/polytypo"><img src="https://img.shields.io/npm/v/polytypo.svg" alt="npm version"></a>
|
|
9
|
+
<a href="https://github.com/polytypo/polytypo-js/actions/workflows/ci.yml"><img src="https://github.com/polytypo/polytypo-js/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/polytypo"><img src="https://img.shields.io/npm/dm/polytypo.svg" alt="npm downloads"></a>
|
|
11
|
+
<a href="https://www.jsdelivr.com/package/npm/polytypo"><img src="https://data.jsdelivr.com/v1/package/npm/polytypo/badge" alt="jsDelivr hits"></a>
|
|
12
|
+
<a href="LICENSE"><img src="https://img.shields.io/npm/l/polytypo.svg" alt="License: MIT"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
Locale-correct quotes, dashes, ellipses, apostrophes, symbols and no-break spaces —<br>
|
|
17
|
+
one portable spec, designed for byte-identical output across runtimes.
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<strong>Try it live, no install: <a href="https://polytypo.dev/">polytypo.dev</a></strong>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
This is the JavaScript/TypeScript implementation. The full spec — all locales, all rules, worked
|
|
25
|
+
examples in each — lives in [polytypo/polytypo](https://github.com/polytypo/polytypo). The
|
|
26
|
+
[browser playground](https://polytypo.dev/playground/) runs this exact package, compiled to a
|
|
27
|
+
browser bundle — paste your own text to try it against any locale before installing anything.
|
|
9
28
|
|
|
10
29
|
## Install
|
|
11
30
|
|
|
@@ -18,13 +37,32 @@ npm install polytypo
|
|
|
18
37
|
```ts
|
|
19
38
|
import { transform } from "polytypo";
|
|
20
39
|
|
|
21
|
-
transform(`She said, "it's fine
|
|
22
|
-
// She said, “it’s fine
|
|
40
|
+
transform(`She said, "it's fine" -- but I wasn't sure...`, { locale: "en-US" });
|
|
41
|
+
// She said, “it’s fine”—but I wasn’t sure…
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Same input, one locale changed — quotes, dash spacing and all follow the target locale, not a
|
|
45
|
+
single hardcoded style:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
transform(`Sie sagte: "Alles gut" -- aber ich war mir nicht sicher...`, { locale: "de-DE" });
|
|
49
|
+
// Sie sagte: „Alles gut“ – aber ich war mir nicht sicher…
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
HTML and Markdown are first-class modes, not an afterthought — tags, attributes and fenced code
|
|
53
|
+
are left alone; only text content is touched:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { transform } from "polytypo/html";
|
|
57
|
+
|
|
58
|
+
transform(`<a title="test... wait">Wait... she said "go on."</a>`, { locale: "en-US" });
|
|
59
|
+
// <a title="test... wait">Wait… she said “go on.”</a>
|
|
23
60
|
```
|
|
24
61
|
|
|
25
62
|
Subpath entries (`polytypo/text`, `polytypo/html`, `polytypo/markdown`) exclude the parser
|
|
26
|
-
dependencies the other modes don't need
|
|
27
|
-
must be
|
|
63
|
+
dependencies the other modes don't need, and each defaults `mode` to itself. The aggregate
|
|
64
|
+
`polytypo` entry defaults `mode` to `"text"`; `locale` has no default anywhere and must always be
|
|
65
|
+
passed explicitly — there is no silent fallback to English.
|
|
28
66
|
|
|
29
67
|
## Licence
|
|
30
68
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polytypo",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Normalize typography across languages: locale-correct quotes, dashes, ellipses and no-break spaces.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typography",
|
|
7
|
-
"
|
|
7
|
+
"normalize-typography",
|
|
8
8
|
"i18n",
|
|
9
9
|
"l10n",
|
|
10
10
|
"locale",
|