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.
- package/README.md +14 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
> *punctilio* (n.): precise observance of formalities.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/alexander-turner/punctilio/actions/workflows/test.yml)
|
|
4
|
+
[](https://github.com/alexander-turner/punctilio/actions/workflows/lint.yml)
|
|
5
|
+
[](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
|
-
[](https://github.com/alexander-turner/punctilio/actions/workflows/test.yml)
|
|
13
|
-
[](https://github.com/alexander-turner/punctilio/actions/workflows/lint.yml)
|
|
14
|
-
[](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
|
|
107
|
+
.use(rehypePunctilio)
|
|
106
108
|
.use(rehypeStringify)
|
|
107
|
-
.process('<p>"
|
|
108
|
-
// → <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`.
|
|
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
|
-
-
|
|
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)
|