punctilio 1.7.6 → 1.7.7

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 +14 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  > *punctilio* (n.): precise observance of formalities.
2
2
 
3
- Pretty good at making your text pretty. The most feature-complete and reliable English typography package.
3
+ [![Test](https://github.com/alexander-turner/punctilio/actions/workflows/test.yml/badge.svg)](https://github.com/alexander-turner/punctilio/actions/workflows/test.yml)
4
+ [![Lint](https://github.com/alexander-turner/punctilio/actions/workflows/lint.yml/badge.svg)](https://github.com/alexander-turner/punctilio/actions/workflows/lint.yml)
5
+ [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/alexander-turner/punctilio)
6
+
7
+ Pretty good at making your text pretty. The most feature-complete and reliable English typography package—transforms plain ASCII punctuation into typographically correct Unicode, even across HTML element boundaries.
8
+
9
+ **Smart quotes** · **Em/en dashes** · **Ellipses** · **Math symbols** · **Legal symbols** · **Arrows** · **Primes** · **Fractions** · **Superscripts** · **Ligatures** · **Non-breaking spaces** · **HTML-aware**
4
10
 
5
11
  ```typescript
6
12
  import { transform } from 'punctilio'
@@ -9,10 +15,6 @@ transform('"It\'s a beautiful thing, the destruction of words..." -- 1984')
9
15
  // → “It’s a beautiful thing, the destruction of words…”—1984
10
16
  ```
11
17
 
12
- [![Test](https://github.com/alexander-turner/punctilio/actions/workflows/test.yml/badge.svg)](https://github.com/alexander-turner/punctilio/actions/workflows/test.yml)
13
- [![Lint](https://github.com/alexander-turner/punctilio/actions/workflows/lint.yml/badge.svg)](https://github.com/alexander-turner/punctilio/actions/workflows/lint.yml)
14
- [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/alexander-turner/punctilio)
15
-
16
18
  ```bash
17
19
  npm install punctilio
18
20
  ```
@@ -102,13 +104,15 @@ import rehypePunctilio from 'punctilio/rehype'
102
104
 
103
105
  unified()
104
106
  .use(rehypeParse)
105
- .use(rehypePunctilio, { dashStyle: 'american' })
107
+ .use(rehypePunctilio)
106
108
  .use(rehypeStringify)
107
- .process('<p>"Hello..." -- world</p>')
108
- // → <p>"Hello…"—world</p>
109
+ .process('<p><em>"Wait</em>..." -- she said</p>')
110
+ // → <p><em>"Wait</em>…"—she said</p>
111
+ // The opening quote inside <em> and the closing quote outside it
112
+ // are both resolved correctly across the element boundary.
109
113
  ```
110
114
 
111
- For manual DOM walking or custom transforms, use `transformElement` from `punctilio/rehype`. Note: `punctilio` transforms plain text or HTML—not raw Markdown.
115
+ For manual DOM walking or custom transforms, use `transformElement` from `punctilio/rehype`.
112
116
 
113
117
  ## Options
114
118
 
@@ -130,7 +134,7 @@ transform(text, {
130
134
  })
131
135
  ```
132
136
 
133
- - Prime marks (`5'10"` → `5′10″`) require semantic understanding to distinguish from closing quotes (e.g. `"Term 1"` should produce closing quotes). `punctilio` counts quotes to heuristically guess whether the matched number at the end of a quote (if not, it requires a prime mark). Other libraries like `tipograph` 0.7.4 use simpler patterns that make more mistakes. That said, `punctilio` is still not perfect and will sometimes wrongly convert to ending quotation marks: `transform('I said "5" sounds right"')` will wrongly produce a closed double quote after the 5” instead of a double prime (correct).
137
+ - Fully general prime mark conversion (e.g. `5'10"` → `5′10″`) requires semantic understanding to distinguish from closing quotes (e.g. `"Term 1"` should produce closing quotes). `punctilio` counts quotes to heuristically guess whether the matched number at the end of a quote (if not, it requires a prime mark). Other libraries like `tipograph` 0.7.4 use simpler patterns that make more mistakes.
134
138
  - The `american` style follows the [Chicago Manual of Style](https://www.chicagomanualofstyle.org/):
135
139
  - Periods and commas go inside quotation marks (“Hello,” she said.)
136
140
  - Unspaced em-dashes between words (word—word)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "punctilio",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "description": "Smart typography transformations: curly quotes, em-dashes, en-dashes, and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",