punctilio 1.0.1 → 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.
Files changed (2) hide show
  1. package/README.md +30 -27
  2. package/package.json +6 -2
package/README.md CHANGED
@@ -23,7 +23,7 @@ As far as I can tell, `punctilio` is the most reliable and feature-complete. I b
23
23
 
24
24
  [^wrote]: While Claude is the number one contributor to this repository, that’s just because Claude has helped me port my existing code and add minor features. The core regular expressions (e.g. dashes, quotes, multiplication signs) are human-written.
25
25
 
26
- I tested `punctilio` 0.4 against [`smartypants`](https://www.npmjs.com/package/smartypants) 0.2.2, [`tipograph`](https://www.npmjs.com/package/tipograph) 0.7.4, and [`smartquotes`](https://www.npmjs.com/package/smartquotes) 2.3.2.[^python] These other packages have spotty feature coverage and inconsistent impact on text. For example, `smartypants` mishandles quotes after em dashes (though quite hard to see in GitHub's font) and lacks multiplication sign support.
26
+ I tested `punctilio` 1.0.1 against [`smartypants`](https://www.npmjs.com/package/smartypants) 0.2.2, [`tipograph`](https://www.npmjs.com/package/tipograph) 0.7.4, [`smartquotes`](https://www.npmjs.com/package/smartquotes) 2.3.2, [`typograf`](https://www.npmjs.com/package/typograf) 7.6.0, and [`retext-smartypants`](https://www.npmjs.com/package/retext-smartypants) 6.2.0.[^python] These other packages have spotty feature coverage and inconsistent impact on text. For example, `smartypants` mishandles quotes after em dashes (though quite hard to see in GitHub's font) and lacks multiplication sign support.
27
27
 
28
28
  [^python]: The Python libraries I found were closely related to the JavaScript packages, so I don’t include Python tests.
29
29
 
@@ -32,36 +32,39 @@ I tested `punctilio` 0.4 against [`smartypants`](https://www.npmjs.com/package/s
32
32
  | She said—"Hi!" | She said—”Hi!” (✗) | She said—“Hi!” (✓) |
33
33
  | 5x5 | 5x5 (✗) | 5×5 (✓) |
34
34
 
35
- By running [`benchmark.mjs`](./benchmark.mjs), I basically graded all libraries on a subset of [my unit tests](./src/tests/), selected to represent a wide range of features.
35
+ My [`benchmark.mjs`](./benchmark.mjs) measures how well libraries handle a [wide range of scenarios](./benchmark_cases.json). The benchmark normalizes stylistic differences (e.g. non-breaking vs regular space, British vs American dash spacing) for fair comparison.
36
36
 
37
37
  | Package | Score |
38
38
  |--------:|:------|
39
39
  | `punctilio` | 79/82 (96%) |
40
- | `tipograph` | 48/82 (59%) |
41
- | `smartquotes` | 30/82 (37%) |
42
- | `smartypants` | 28/82 (35%) |
43
-
44
- | Feature | Example | `smartypants` | `tipograph` | `smartquotes` | `punctilio` |
45
- |--------:|:-------:|:-------:|:-------:|:-------:|:-------:|
46
- | Smart quotes | "hello" “hello” | | | | |
47
- | Leading apostrophe | 'Twas → ’Twas | ✗ | ✗ | ✓ | ✓ |
48
- | Em dash | -- | ✓ | | | ✓ |
49
- | En dash (ranges) | 1-51–5 | ✗ | ✓ | ✗ | ✓ |
50
- | Minus sign | -5−5 | | | ✗ | ✓ |
51
- | Ellipsis | ... | | ✓ | ✗ | ✓ |
52
- | Multiplication | 5x5 → 5×5 | ✗ | ✗ | ✗ | ✓ |
53
- | Math symbols | != | | ✓ | ✗ | ✓ |
54
- | Legal symbols | (c)© | ✗ | © only | ✗ | ✓ |
55
- | Arrows | -> | ✗ | ✓ | ✗ | ✓ |
56
- | Prime marks | 5'10"5′10″ | ✗ | | ✓ | ✓ |
57
- | Degrees | 20 C20 °C | | ✗ | | ✓ |
58
- | Fractions | 1/2½ | ✗ | | ✗ | ✓ |
59
- | Superscripts | 1st1ˢᵗ | ✗ | ✗ | ✗ | ✓ |
60
- | Localization | American/British | ✗ | ✗ | ✗ | ✓ |
61
- | Ligatures | ?? | ✗ | | ✗ | ✓ |
62
- | Non-English quotes | „Hallo" (German) | ✗ | | ✗ | ✗ |
63
-
64
- As far as I can tell, `punctilio`’s only missing feature is non-English quote support. I don’t have a personal reason to use non-English localization, but feel free to make a pull request!
40
+ | `tipograph` | 51/82 (62%) |
41
+ | `typograf` | 42/82 (51%) |
42
+ | `smartquotes` | 31/82 (38%) |
43
+ | `smartypants` | 30/82 (37%) |
44
+ | `retext-smartypants` | 28/82 (34%) |
45
+
46
+ | Feature | Example | `smartypants` | `tipograph` | `smartquotes` | `typograf` | `punctilio` |
47
+ |--------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|
48
+ | Smart quotes | "hello""hello" | ✓ | | | ✓ | ✓ |
49
+ | Leading apostrophe | 'Twas'Twas | ✗ | ✗ | ✓ | ✗ | ✓ |
50
+ | Em dash | -- | | | ✗ | ✓ | ✓ |
51
+ | En dash (ranges) | 1-51–5 | | ✓ | ✗ | ✗ | ✓ |
52
+ | Minus sign | -55 | ✗ | ✓ | ✗ | ✗ | ✓ |
53
+ | Ellipsis | ... | | ✓ | ✗ | ✓ | ✓ |
54
+ | Multiplication | 5x55×5 | ✗ | | ✗ | ✓ | ✓ |
55
+ | Math symbols | != | ✗ | ✓ | ✗ | ✓ | ✓ |
56
+ | Legal symbols | (c)© | ✗ | © only | ✗ | ✓ | ✓ |
57
+ | Arrows | -> | | | ✗ | | ✓ |
58
+ | Prime marks | 5'10"5′10″ | ✗ | | ✓ | ✗ | ✓ |
59
+ | Degrees | 20 C 20 °C | ✗ | ✗ | ✗ | ✓ | ✓ |
60
+ | Fractions | 1/2 → ½ | ✗ | ✗ | ✗ | ✓ | ✓ |
61
+ | Superscripts | 1st1ˢᵗ | ✗ | | ✗ | ✗ | ✓ |
62
+ | Localization | American/British | ✗ | | ✗ | ✗ | ✓ |
63
+ | Ligatures | ?? → ⁇ | ✗ | ✓ | ✗ | ✗ | ✓ |
64
+ | Non-English quotes | „Hallo" (German) | | | | | |
65
+ | Non-breaking spaces | Chapter 1 | ✗ | ✗ | ✗ | ✓ | ✗ |
66
+
67
+ `typograf` uniquely inserts non-breaking spaces to prevent bad line breaks (e.g. before numbers, after colons). `punctilio`'s main missing feature is non-English quote support—feel free to make a pull request!
65
68
 
66
69
  ## Works with HTML DOMs via separation boundaries
67
70
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "punctilio",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Smart typography transformations: curly quotes, em-dashes, en-dashes, and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -44,12 +44,16 @@
44
44
  "eslint": "^9.39.2",
45
45
  "eslint-plugin-regexp": "^3.0.0",
46
46
  "jest": "^29.7.0",
47
+ "retext": "9.0.0",
48
+ "retext-smartypants": "6.2.0",
47
49
  "smartquotes": "2.3.2",
48
50
  "smartypants": "0.2.2",
49
51
  "tipograph": "0.7.4",
50
52
  "ts-jest": "^29.1.2",
51
53
  "typescript": "^5.3.3",
52
- "typescript-eslint": "^8.54.0"
54
+ "typescript-eslint": "^8.54.0",
55
+ "typograf": "7.6.0",
56
+ "unified": "11.0.5"
53
57
  },
54
58
  "scripts": {
55
59
  "build": "tsc",