punctilio 0.4.17 → 0.4.18
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 +4 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,15 +23,13 @@ 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`
|
|
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:
|
|
27
27
|
|
|
28
|
-
[^python]: The Python libraries I found were closely related to the JavaScript packages, so I don’t include Python tests.
|
|
28
|
+
[^python]: The Python libraries I found were closely related to the JavaScript packages, so I don’t include Python tests.
|
|
29
29
|
|
|
30
30
|
| Input | `smartypants` | `punctilio` |
|
|
31
31
|
|:-----:|:-----------------:|:-------:|
|
|
32
|
-
|
|
|
33
|
-
| the '99 season | the ‘99 season ✗ | the ’99 season ✓ |
|
|
34
|
-
| rock 'n' roll | rock ‘n’ roll ✗ | rock ’n’ roll ✓ |
|
|
32
|
+
| She said—"Hi!" | She said—”Hi!” ✗ | She said—“Hi!” ✓ |
|
|
35
33
|
|
|
36
34
|
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.
|
|
37
35
|
|
|
@@ -66,7 +64,7 @@ As far as I can tell, `punctilio`’s only missing feature is non-English quote
|
|
|
66
64
|
|
|
67
65
|
## Works with HTML DOMs via separation boundaries
|
|
68
66
|
|
|
69
|
-
Other typography libraries either transform plain strings or operate on AST nodes individually (`retext-smartypants` [can
|
|
67
|
+
Other typography libraries either transform plain strings or operate on AST nodes individually (`retext-smartypants` [can’t map changes back to HTML](https://github.com/rehypejs/rehype-retext)). But real HTML has text spanning multiple elements—if you concatenate text from `<em>Wait</em>...`, transform it, then try to split it back, you've lost track of where `</em>` belonged.
|
|
70
68
|
|
|
71
69
|
`punctilio` introduces _separation boundaries_. First, insert a “separator” character (default: `U+E000`) at each element boundary before transforming (like at the start and end of an `<em>`). Every regex allows this character mid-pattern without breaking matches. For example, `.[SEP]..` still becomes `…[SEP]`. `punctilio` validates the output by ensuring the separator count remains the same.
|
|
72
70
|
|