punctilio 3.11.3 → 3.12.0
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/dist/cli.d.ts +1 -12
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -27
- package/dist/cli.js.map +1 -1
- package/dist/constants.d.ts +13 -61
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +12 -61
- package/dist/constants.js.map +1 -1
- package/dist/dashes.d.ts +0 -9
- package/dist/dashes.d.ts.map +1 -1
- package/dist/dashes.js +4 -26
- package/dist/dashes.js.map +1 -1
- package/dist/html.d.ts +1 -32
- package/dist/html.d.ts.map +1 -1
- package/dist/html.js +1 -29
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +4 -43
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -41
- package/dist/index.js.map +1 -1
- package/dist/markdown.d.ts +1 -34
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +1 -34
- package/dist/markdown.js.map +1 -1
- package/dist/nbsp.d.ts +1 -68
- package/dist/nbsp.d.ts.map +1 -1
- package/dist/nbsp.js +6 -86
- package/dist/nbsp.js.map +1 -1
- package/dist/prettier-plugin.d.ts +0 -14
- package/dist/prettier-plugin.d.ts.map +1 -1
- package/dist/prettier-plugin.js +0 -19
- package/dist/prettier-plugin.js.map +1 -1
- package/dist/quotes.d.ts +0 -3
- package/dist/quotes.d.ts.map +1 -1
- package/dist/quotes.js +11 -58
- package/dist/quotes.js.map +1 -1
- package/dist/rehype.d.ts +4 -141
- package/dist/rehype.d.ts.map +1 -1
- package/dist/rehype.js +7 -144
- package/dist/rehype.js.map +1 -1
- package/dist/remark.d.ts +0 -30
- package/dist/remark.d.ts.map +1 -1
- package/dist/remark.js +0 -41
- package/dist/remark.js.map +1 -1
- package/dist/symbols.d.ts +1 -7
- package/dist/symbols.d.ts.map +1 -1
- package/dist/symbols.js +9 -53
- package/dist/symbols.js.map +1 -1
- package/dist/utils.d.ts +10 -58
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +12 -59
- package/dist/utils.js.map +1 -1
- package/package.json +5 -5
- package/src/cli.ts +6 -32
- package/src/constants.ts +13 -62
- package/src/dashes.ts +4 -27
- package/src/html.ts +1 -33
- package/src/index.ts +20 -43
- package/src/markdown.ts +1 -38
- package/src/nbsp.ts +6 -87
- package/src/prettier-plugin.ts +0 -20
- package/src/quotes.ts +11 -59
- package/src/rehype.ts +8 -162
- package/src/remark.ts +0 -42
- package/src/symbols.ts +9 -66
- package/src/utils.ts +11 -60
package/dist/html.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convenience module for HTML-to-HTML typography transformations.
|
|
3
|
-
*
|
|
4
|
-
* Provides a single function that takes HTML input and returns
|
|
5
|
-
* typographically improved HTML output.
|
|
6
|
-
*
|
|
7
|
-
* Requires `unified`, `rehype-parse`, and `rehype-stringify` to be installed.
|
|
8
|
-
*
|
|
9
|
-
* @packageDocumentation
|
|
10
|
-
*/
|
|
11
1
|
import { unified } from "unified";
|
|
12
2
|
import rehypeParse from "rehype-parse";
|
|
13
3
|
import rehypeStringify from "rehype-stringify";
|
|
@@ -25,28 +15,10 @@ const MAX_PROCESSOR_CACHE_SIZE = 8;
|
|
|
25
15
|
const processorCache = new QuickLRU({
|
|
26
16
|
maxSize: MAX_PROCESSOR_CACHE_SIZE,
|
|
27
17
|
});
|
|
28
|
-
/**
|
|
29
|
-
* Clears the processor cache. Exported for test isolation only.
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
18
|
+
/** @internal */
|
|
32
19
|
export function clearProcessorCache() {
|
|
33
20
|
processorCache.clear();
|
|
34
21
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Transforms HTML text with typographic improvements.
|
|
37
|
-
*
|
|
38
|
-
* Parses the input as HTML, applies punctilio typography transformations,
|
|
39
|
-
* and serializes back to HTML. The unified processor pipeline is cached
|
|
40
|
-
* and reused across calls with identical options.
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```ts
|
|
44
|
-
* import { transformHtml } from 'punctilio/html'
|
|
45
|
-
*
|
|
46
|
-
* await transformHtml('<p>"Hello" -- world</p>')
|
|
47
|
-
* // → '<p>“Hello”—world</p>'
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
22
|
export async function transformHtml(input, options = {}) {
|
|
51
23
|
// Function-valued options aren't JSON-serializable, so the cache key
|
|
52
24
|
// can't distinguish them. Bypass the cache to avoid returning a
|
package/dist/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,WAAW,MAAM,cAAc,CAAA;AACtC,OAAO,eAAe,MAAM,kBAAkB,CAAA;AAC9C,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,eAAe,EAA+B,MAAM,aAAa,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAW5C,SAAS,eAAe,CAAC,OAAoB;IAC3C,MAAM,EAAE,QAAQ,EAAE,GAAG,gBAAgB,EAAE,GAAG,OAAO,CAAA;IACjD,OAAO,OAAO,EAAE;SACb,GAAG,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,QAAQ,IAAI,IAAI,EAAE,CAAC;SAChD,GAAG,CAAC,eAAe,EAAE,gBAAgB,CAAC;SACtC,GAAG,CAAC,eAAe,CAAC,CAAA;AACzB,CAAC;AAED,MAAM,wBAAwB,GAAG,CAAC,CAAA;AAElC,MAAM,cAAc,GAAG,IAAI,QAAQ,CAA6C;IAC9E,OAAO,EAAE,wBAAwB;CAClC,CAAC,CAAA;AAEF,gBAAgB;AAChB,MAAM,UAAU,mBAAmB;IACjC,cAAc,CAAC,KAAK,EAAE,CAAA;AACxB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAAa,EACb,UAAuB,EAAE;IAEzB,qEAAqE;IACrE,gEAAgE;IAChE,iDAAiD;IACjD,IAAI,OAAO,OAAO,CAAC,cAAc,KAAK,UAAU,EAAE,CAAC;QACjD,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC5D,OAAO,MAAM,CAAC,MAAM,CAAC,CAAA;IACvB,CAAC;IAED,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IAE3C,IAAI,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IAC9C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;QACpC,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;IAC3C,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAA;AACvB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* punctilio - Smart typography transformations
|
|
3
|
-
*
|
|
4
|
-
* A library for converting plain ASCII punctuation into typographically
|
|
5
|
-
* correct Unicode characters. Handles smart quotes, em-dashes, en-dashes,
|
|
6
|
-
* minus signs, ellipses, multiplication signs, and more.
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
*/
|
|
10
1
|
export { DEFAULT_SEPARATOR, UNICODE_SYMBOLS } from "./constants.js";
|
|
11
|
-
import type
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
import { type DashStyle } from "./dashes.js";
|
|
3
|
+
import { type PunctuationStyle } from "./quotes.js";
|
|
4
|
+
export { DASH_STYLES, type DashOptions, type DashStyle, enDashDateRange, enDashNumberRange, hyphenReplace, minusReplace, numberRangeDisallowedPrefixes, } from "./dashes.js";
|
|
14
5
|
export { HONORIFICS, nbspAfterCopyrightSymbols, nbspAfterHonorifics, nbspAfterReferenceAbbreviations, nbspAfterSectionSymbols, nbspAfterShortWords, nbspBeforeLastWord, nbspBetweenInitials, nbspBetweenNumberAndUnit, type NbspOptions, nbspTransform, REFERENCE_ABBREVIATIONS, UNITS, } from "./nbsp.js";
|
|
15
|
-
export { classifyApostrophes, niceQuotes, type PunctuationStyle, type QuoteOptions } from "./quotes.js";
|
|
6
|
+
export { classifyApostrophes, niceQuotes, PUNCTUATION_STYLES, type PunctuationStyle, type QuoteOptions } from "./quotes.js";
|
|
16
7
|
export interface TransformOptions {
|
|
17
8
|
/**
|
|
18
9
|
* A boundary marker character used when transforming text that spans
|
|
@@ -121,35 +112,5 @@ export interface TransformOptions {
|
|
|
121
112
|
export { arrows, collapseSpaces, degrees, ellipsis, fractions, legalSymbols, mathSymbols, multiplication, primeMarks, punctuationLigatures, superscriptOrdinal, type SymbolOptions, symbolTransform, } from "./symbols.js";
|
|
122
113
|
export { assertSeparatorAbsent, assertSeparatorCountPreserved, countSeparators, transformTextNodes } from "./utils.js";
|
|
123
114
|
export declare const MODIFIER_LETTER_APOSTROPHE: "ʼ";
|
|
124
|
-
/**
|
|
125
|
-
* Applies all typography transformations: smart quotes, proper dashes,
|
|
126
|
-
* and symbol improvements.
|
|
127
|
-
*
|
|
128
|
-
* This is a convenience function that applies transformations in sequence:
|
|
129
|
-
* 1. hyphenReplace (em-dashes, en-dashes, minus signs)
|
|
130
|
-
* 2. primeMarks (feet/inches, arcminutes/arcseconds)
|
|
131
|
-
* 3. niceQuotes (smart quotes)
|
|
132
|
-
* 4. symbolTransform (ellipses, multiplication, math symbols, legal symbols, arrows)
|
|
133
|
-
* 5. fractions (disabled by default)
|
|
134
|
-
* 6. degrees (disabled by default)
|
|
135
|
-
* 7. superscript (disabled by default)
|
|
136
|
-
* 8. ligatures (disabled by default)
|
|
137
|
-
* 9. collapseSpaces (collapses multiple spaces into one)
|
|
138
|
-
* 10. nbsp (non-breaking spaces, enabled by default)
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```ts
|
|
142
|
-
* import { transform } from 'punctilio'
|
|
143
|
-
*
|
|
144
|
-
* transform('"Hello," she said - "it\'s pages 1-5."')
|
|
145
|
-
* // → '"Hello," she said—"it's pages 1–5."'
|
|
146
|
-
*
|
|
147
|
-
* transform('Wait... 5x5 != 25 (c) 2024')
|
|
148
|
-
* // → 'Wait… 5×5 ≠ 25 © 2024'
|
|
149
|
-
*
|
|
150
|
-
* transform('Add 1/2 cup', { fractions: true })
|
|
151
|
-
* // → 'Add ½ cup'
|
|
152
|
-
* ```
|
|
153
|
-
*/
|
|
154
115
|
export declare function transform(text: string, options?: TransformOptions): string;
|
|
155
116
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACvE,OAAO,EACL,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,6BAA6B,GAC9B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,UAAU,EACV,yBAAyB,EACzB,mBAAmB,EACnB,+BAA+B,EAC/B,uBAAuB,EACvB,mBA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,MAAM,0BAA0B,KAA6C,CAAA;AAgBpF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAuF9E"}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* punctilio - Smart typography transformations
|
|
3
|
-
*
|
|
4
|
-
* A library for converting plain ASCII punctuation into typographically
|
|
5
|
-
* correct Unicode characters. Handles smart quotes, em-dashes, en-dashes,
|
|
6
|
-
* minus signs, ellipses, multiplication signs, and more.
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
*/
|
|
10
1
|
export { DEFAULT_SEPARATOR, UNICODE_SYMBOLS } from "./constants.js";
|
|
11
|
-
|
|
2
|
+
import { DASH_STYLES } from "./dashes.js";
|
|
3
|
+
import { PUNCTUATION_STYLES } from "./quotes.js";
|
|
4
|
+
export { DASH_STYLES, enDashDateRange, enDashNumberRange, hyphenReplace, minusReplace, numberRangeDisallowedPrefixes, } from "./dashes.js";
|
|
12
5
|
export { HONORIFICS, nbspAfterCopyrightSymbols, nbspAfterHonorifics, nbspAfterReferenceAbbreviations, nbspAfterSectionSymbols, nbspAfterShortWords, nbspBeforeLastWord, nbspBetweenInitials, nbspBetweenNumberAndUnit, nbspTransform, REFERENCE_ABBREVIATIONS, UNITS, } from "./nbsp.js";
|
|
13
|
-
export { classifyApostrophes, niceQuotes } from "./quotes.js";
|
|
6
|
+
export { classifyApostrophes, niceQuotes, PUNCTUATION_STYLES } from "./quotes.js";
|
|
14
7
|
import { niceQuotes } from "./quotes.js";
|
|
15
8
|
import { hyphenReplace } from "./dashes.js";
|
|
16
9
|
import { collapseSpaces as collapseSpacesTransform, degrees as degreesTransform, fractions as fractionsTransform, punctuationLigatures as ligaturesTransform, primeMarks, superscriptOrdinal as superscriptTransform, symbolTransform } from "./symbols.js";
|
|
@@ -33,36 +26,6 @@ const defaultOpts = {
|
|
|
33
26
|
punctuationStyle: "american",
|
|
34
27
|
dashStyle: "american",
|
|
35
28
|
};
|
|
36
|
-
/**
|
|
37
|
-
* Applies all typography transformations: smart quotes, proper dashes,
|
|
38
|
-
* and symbol improvements.
|
|
39
|
-
*
|
|
40
|
-
* This is a convenience function that applies transformations in sequence:
|
|
41
|
-
* 1. hyphenReplace (em-dashes, en-dashes, minus signs)
|
|
42
|
-
* 2. primeMarks (feet/inches, arcminutes/arcseconds)
|
|
43
|
-
* 3. niceQuotes (smart quotes)
|
|
44
|
-
* 4. symbolTransform (ellipses, multiplication, math symbols, legal symbols, arrows)
|
|
45
|
-
* 5. fractions (disabled by default)
|
|
46
|
-
* 6. degrees (disabled by default)
|
|
47
|
-
* 7. superscript (disabled by default)
|
|
48
|
-
* 8. ligatures (disabled by default)
|
|
49
|
-
* 9. collapseSpaces (collapses multiple spaces into one)
|
|
50
|
-
* 10. nbsp (non-breaking spaces, enabled by default)
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```ts
|
|
54
|
-
* import { transform } from 'punctilio'
|
|
55
|
-
*
|
|
56
|
-
* transform('"Hello," she said - "it\'s pages 1-5."')
|
|
57
|
-
* // → '"Hello," she said—"it's pages 1–5."'
|
|
58
|
-
*
|
|
59
|
-
* transform('Wait... 5x5 != 25 (c) 2024')
|
|
60
|
-
* // → 'Wait… 5×5 ≠ 25 © 2024'
|
|
61
|
-
*
|
|
62
|
-
* transform('Add 1/2 cup', { fractions: true })
|
|
63
|
-
* // → 'Add ½ cup'
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
29
|
export function transform(text, options = {}) {
|
|
67
30
|
const separator = options.separator ?? DEFAULT_SEPARATOR;
|
|
68
31
|
if (separator.length === 0) {
|
|
@@ -75,6 +38,16 @@ export function transform(text, options = {}) {
|
|
|
75
38
|
throw new Error(`Invalid separator: must contain only BMP characters (no characters outside the Basic Multilingual Plane). ` +
|
|
76
39
|
`Received "${separator}" which contains a non-BMP character.`);
|
|
77
40
|
}
|
|
41
|
+
const punctuationStyle = options.punctuationStyle ?? "american";
|
|
42
|
+
if (!PUNCTUATION_STYLES.includes(punctuationStyle)) {
|
|
43
|
+
throw new Error(`Invalid punctuationStyle: "${punctuationStyle}". ` +
|
|
44
|
+
`Must be one of: ${PUNCTUATION_STYLES.join(", ")}.`);
|
|
45
|
+
}
|
|
46
|
+
const dashStyle = options.dashStyle ?? "american";
|
|
47
|
+
if (!DASH_STYLES.includes(dashStyle)) {
|
|
48
|
+
throw new Error(`Invalid dashStyle: "${dashStyle}". ` +
|
|
49
|
+
`Must be one of: ${DASH_STYLES.join(", ")}.`);
|
|
50
|
+
}
|
|
78
51
|
const original = text;
|
|
79
52
|
const { symbols, fractions, degrees, superscript, ligatures, nbsp, collapseSpaces, checkIdempotency, ...pipelineOpts } = { ...defaultOpts, ...filterUndefined(options) };
|
|
80
53
|
text = hyphenReplace(text, pipelineOpts);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAyB,MAAM,aAAa,CAAA;AACvE,OAAO,EACL,WAAW,EAGX,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,6BAA6B,GAC9B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,UAAU,EACV,yBAAyB,EACzB,mBAAmB,EACnB,+BAA+B,EAC/B,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EAExB,aAAa,EACb,uBAAuB,EACvB,KAAK,GACN,MAAM,WAAW,CAAA;AAClB,OAAO,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;gBAChC,gBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI;gBACzD,gBAAgB,iBAAiB,CAAC,UAAU,EAAE,aAAa,CAAC,IAAI;gBAChE,uDAAuD,UAAU,IAAI;gBACrE,kDAAkD;gBAClD,2DAA2D,CAC5D,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/dist/markdown.d.ts
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convenience module for Markdown-to-Markdown typography transformations.
|
|
3
|
-
*
|
|
4
|
-
* Provides a single function that takes Markdown input and returns
|
|
5
|
-
* typographically improved Markdown output.
|
|
6
|
-
*
|
|
7
|
-
* Requires `unified`, `remark-parse`, and `remark-stringify` to be installed.
|
|
8
|
-
*
|
|
9
|
-
* @packageDocumentation
|
|
10
|
-
*/
|
|
11
1
|
import { type RemarkPunctilioOptions } from "./remark.js";
|
|
12
|
-
/**
|
|
13
|
-
* Options for the Markdown transform pipeline.
|
|
14
|
-
*/
|
|
15
2
|
export interface MarkdownOptions extends RemarkPunctilioOptions {
|
|
16
3
|
/**
|
|
17
4
|
* Character for emphasis (`*text*` vs `_text_`) and strong (`**text**` vs `__text__`).
|
|
@@ -28,27 +15,7 @@ export interface MarkdownOptions extends RemarkPunctilioOptions {
|
|
|
28
15
|
/** Thematic break marker. Default: "-" */
|
|
29
16
|
ruleMarker?: "-" | "*" | "_";
|
|
30
17
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Clears the processor cache. Exported for test isolation only.
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
18
|
+
/** @internal */
|
|
35
19
|
export declare function clearProcessorCache(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Transforms Markdown text with typographic improvements.
|
|
38
|
-
*
|
|
39
|
-
* Parses the input as Markdown, applies punctilio typography transformations
|
|
40
|
-
* (smart quotes, em-dashes, ellipses, etc.), and serializes back to Markdown.
|
|
41
|
-
*
|
|
42
|
-
* The unified processor pipeline is cached and reused across calls with
|
|
43
|
-
* identical options, avoiding redundant pipeline construction.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```ts
|
|
47
|
-
* import { transformMarkdown } from 'punctilio/markdown'
|
|
48
|
-
*
|
|
49
|
-
* await transformMarkdown('"Hello" -- world')
|
|
50
|
-
* // → '\u201CHello\u201D\u2014world'
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
20
|
export declare function transformMarkdown(input: string, options?: MarkdownOptions): Promise<string>;
|
|
54
21
|
//# sourceMappingURL=markdown.d.ts.map
|
package/dist/markdown.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmB,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAG1E,MAAM,WAAW,eAAgB,SAAQ,sBAAsB;IAC7D;;;OAGG;IACH,cAAc,CAAC,EAAE,GAAG,GAAG,GAAG,CAAA;IAE1B;;;OAGG;IACH,YAAY,CAAC,EAAE,GAAG,GAAG,GAAG,CAAA;IAExB,yDAAyD;IACzD,YAAY,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;IAE9B,0CAA0C;IAC1C,UAAU,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;CAC7B;AAoCD,gBAAgB;AAChB,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAWjB"}
|
package/dist/markdown.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convenience module for Markdown-to-Markdown typography transformations.
|
|
3
|
-
*
|
|
4
|
-
* Provides a single function that takes Markdown input and returns
|
|
5
|
-
* typographically improved Markdown output.
|
|
6
|
-
*
|
|
7
|
-
* Requires `unified`, `remark-parse`, and `remark-stringify` to be installed.
|
|
8
|
-
*
|
|
9
|
-
* @packageDocumentation
|
|
10
|
-
*/
|
|
11
1
|
import { unified } from "unified";
|
|
12
2
|
import remarkParse from "remark-parse";
|
|
13
3
|
import remarkGfm from "remark-gfm";
|
|
@@ -15,9 +5,6 @@ import remarkStringify from "remark-stringify";
|
|
|
15
5
|
import QuickLRU from "quick-lru";
|
|
16
6
|
import { remarkPunctilio } from "./remark.js";
|
|
17
7
|
import { stableStringify } from "./utils.js";
|
|
18
|
-
/**
|
|
19
|
-
* Creates a unified processor pipeline for Markdown typography transformations.
|
|
20
|
-
*/
|
|
21
8
|
function createProcessor(options) {
|
|
22
9
|
const { emphasisMarker, strongMarker, bulletMarker, ruleMarker, ...punctilioOptions } = options;
|
|
23
10
|
return unified()
|
|
@@ -42,30 +29,10 @@ const MAX_PROCESSOR_CACHE_SIZE = 8;
|
|
|
42
29
|
const processorCache = new QuickLRU({
|
|
43
30
|
maxSize: MAX_PROCESSOR_CACHE_SIZE,
|
|
44
31
|
});
|
|
45
|
-
/**
|
|
46
|
-
* Clears the processor cache. Exported for test isolation only.
|
|
47
|
-
* @internal
|
|
48
|
-
*/
|
|
32
|
+
/** @internal */
|
|
49
33
|
export function clearProcessorCache() {
|
|
50
34
|
processorCache.clear();
|
|
51
35
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Transforms Markdown text with typographic improvements.
|
|
54
|
-
*
|
|
55
|
-
* Parses the input as Markdown, applies punctilio typography transformations
|
|
56
|
-
* (smart quotes, em-dashes, ellipses, etc.), and serializes back to Markdown.
|
|
57
|
-
*
|
|
58
|
-
* The unified processor pipeline is cached and reused across calls with
|
|
59
|
-
* identical options, avoiding redundant pipeline construction.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```ts
|
|
63
|
-
* import { transformMarkdown } from 'punctilio/markdown'
|
|
64
|
-
*
|
|
65
|
-
* await transformMarkdown('"Hello" -- world')
|
|
66
|
-
* // → '\u201CHello\u201D\u2014world'
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
36
|
export async function transformMarkdown(input, options = {}) {
|
|
70
37
|
const optionsKey = stableStringify(options);
|
|
71
38
|
let processor = processorCache.get(optionsKey);
|
package/dist/markdown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,WAAW,MAAM,cAAc,CAAA;AACtC,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,eAAe,MAAM,kBAAkB,CAAA;AAC9C,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,eAAe,EAA+B,MAAM,aAAa,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAsB5C,SAAS,eAAe,CAAC,OAAwB;IAC/C,MAAM,EACJ,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,GAAG,gBAAgB,EACpB,GAAG,OAAO,CAAA;IAEX,OAAO,OAAO,EAAE;SACb,GAAG,CAAC,WAAW,CAAC;SAChB,GAAG,CAAC,SAAS,CAAC;SACd,GAAG,CAAC,eAAe,EAAE,gBAAgB,CAAC;SACtC,GAAG,CAAC,eAAe,EAAE;QACpB,QAAQ,EAAE,cAAc,IAAI,GAAG;QAC/B,MAAM,EAAE,YAAY,IAAI,GAAG;QAC3B,MAAM,EAAE,YAAY,IAAI,GAAG;QAC3B,IAAI,EAAE,UAAU,IAAI,GAAG;QACvB,kEAAkE;QAClE,uDAAuD;QACvD,GAAG,CAAC,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,sEAAsE;QACtE,sEAAsE;QACtE,6CAA6C;QAC7C,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;KACtD,CAAC,CAAA;AACN,CAAC;AAED,MAAM,wBAAwB,GAAG,CAAC,CAAA;AAElC,MAAM,cAAc,GAAG,IAAI,QAAQ,CAA6C;IAC9E,OAAO,EAAE,wBAAwB;CAClC,CAAC,CAAA;AAEF,gBAAgB;AAChB,MAAM,UAAU,mBAAmB;IACjC,cAAc,CAAC,KAAK,EAAE,CAAA;AACxB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAAa,EACb,UAA2B,EAAE;IAE7B,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IAE3C,IAAI,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IAC9C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;QACpC,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;IAC3C,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAA;AACvB,CAAC"}
|
package/dist/nbsp.d.ts
CHANGED
|
@@ -1,85 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Non-breaking space transformations for improved typography.
|
|
3
|
-
*
|
|
4
|
-
* Inserts non-breaking spaces (U+00A0) in positions where line breaks
|
|
5
|
-
* would be typographically undesirable: after short words, between
|
|
6
|
-
* numbers and units, before orphaned last words, etc.
|
|
7
|
-
*
|
|
8
|
-
* @module nbsp
|
|
9
|
-
*/
|
|
10
1
|
export interface NbspOptions {
|
|
11
2
|
/** Boundary marker for HTML element boundaries. Default: "\uE000\uE001" */
|
|
12
3
|
separator?: string;
|
|
13
4
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Common units for the number-unit nbsp pattern. Only matches these specific
|
|
16
|
-
* abbreviations after a number to avoid false positives like "chapter 3 above".
|
|
17
|
-
*/
|
|
5
|
+
/** Only specific abbreviations are matched to avoid false positives. */
|
|
18
6
|
export declare const UNITS: readonly string[];
|
|
19
7
|
export declare const HONORIFICS: readonly string[];
|
|
20
8
|
export declare const REFERENCE_ABBREVIATIONS: readonly string[];
|
|
21
|
-
/**
|
|
22
|
-
* Adds non-breaking space after short words (1-2 letters) to prevent them from
|
|
23
|
-
* being left alone at the end of a line.
|
|
24
|
-
*
|
|
25
|
-
* Skips when the short word is already preceded by an NBSP from an earlier
|
|
26
|
-
* transform, or when this match immediately follows the previous one
|
|
27
|
-
* (back-to-back short words in the same pass). Either case would bind three
|
|
28
|
-
* or more words into a single line-break atom — defeating widow protection.
|
|
29
|
-
*
|
|
30
|
-
* @example "a cat" → "a\u00A0cat", "I am" → "I\u00A0am"
|
|
31
|
-
*/
|
|
32
9
|
export declare function nbspAfterShortWords(text: string, options?: NbspOptions): string;
|
|
33
|
-
/**
|
|
34
|
-
* Adds non-breaking space between numbers and common units.
|
|
35
|
-
*
|
|
36
|
-
* @example "100 km" → "100\u00A0km", "5 kg" → "5\u00A0kg"
|
|
37
|
-
*/
|
|
38
10
|
export declare function nbspBetweenNumberAndUnit(text: string, options?: NbspOptions): string;
|
|
39
|
-
/**
|
|
40
|
-
* Adds non-breaking space before the last word to prevent widows.
|
|
41
|
-
*
|
|
42
|
-
* Only applies to final words of 1 to {@link MAX_LAST_WORD_LENGTH} characters,
|
|
43
|
-
* at end of string or paragraph break (\n\n). Uses non-multiline mode so $
|
|
44
|
-
* matches only the true end of string.
|
|
45
|
-
*
|
|
46
|
-
* Skips when the second-to-last word is already glued backwards via NBSP,
|
|
47
|
-
* so the phrase doesn't become a 3-word non-breaking atom.
|
|
48
|
-
*/
|
|
49
11
|
export declare function nbspBeforeLastWord(text: string, options?: NbspOptions): string;
|
|
50
|
-
/**
|
|
51
|
-
* Adds non-breaking space after reference abbreviations (Fig., Vol., p., etc.)
|
|
52
|
-
* when followed by a number.
|
|
53
|
-
*
|
|
54
|
-
* @example "Fig. 1" → "Fig.\u00A01", "p. 42" → "p.\u00A042"
|
|
55
|
-
*/
|
|
56
12
|
export declare function nbspAfterReferenceAbbreviations(text: string, options?: NbspOptions): string;
|
|
57
|
-
/**
|
|
58
|
-
* Adds non-breaking space after section (§) and paragraph (¶) symbols
|
|
59
|
-
* when followed by a number.
|
|
60
|
-
*
|
|
61
|
-
* @example "§ 5" → "§\u00A05"
|
|
62
|
-
*/
|
|
63
13
|
export declare function nbspAfterSectionSymbols(text: string, options?: NbspOptions): string;
|
|
64
|
-
/**
|
|
65
|
-
* Adds non-breaking space after honorific titles when followed by a capitalized name.
|
|
66
|
-
*
|
|
67
|
-
* @example "Dr. Smith" → "Dr.\u00A0Smith", "Mr. Jones" → "Mr.\u00A0Jones"
|
|
68
|
-
*/
|
|
69
14
|
export declare function nbspAfterHonorifics(text: string, options?: NbspOptions): string;
|
|
70
|
-
/**
|
|
71
|
-
* Adds non-breaking space after copyright, registered, and trademark
|
|
72
|
-
* symbols when followed by a year or capitalized name.
|
|
73
|
-
*
|
|
74
|
-
* @example "© 2024" → "©\u00A02024", "® Brand" → "®\u00A0Brand"
|
|
75
|
-
*/
|
|
76
15
|
export declare function nbspAfterCopyrightSymbols(text: string, options?: NbspOptions): string;
|
|
77
|
-
/**
|
|
78
|
-
* Adds non-breaking space between initials (e.g., "J. K. Rowling").
|
|
79
|
-
*
|
|
80
|
-
* @example "J. K. Rowling" → "J.\u00A0K.\u00A0Rowling"
|
|
81
|
-
*/
|
|
82
16
|
export declare function nbspBetweenInitials(text: string, options?: NbspOptions): string;
|
|
83
|
-
/** Apply all non-breaking space transformations in sequence. */
|
|
84
17
|
export declare function nbspTransform(text: string, options?: NbspOptions): string;
|
|
85
18
|
//# sourceMappingURL=nbsp.d.ts.map
|
package/dist/nbsp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nbsp.d.ts","sourceRoot":"","sources":["../src/nbsp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nbsp.d.ts","sourceRoot":"","sources":["../src/nbsp.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAMD,wEAAwE;AACxE,eAAO,MAAM,KAAK,EAAE,SAAS,MAAM,EAqClC,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAcvC,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EASpD,CAAA;AAcD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAanF;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAQxF;AAQD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CASlF;AAED,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAO/F;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAOvF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAOnF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAOzF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAOnF;AAgBD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAS7E"}
|
package/dist/nbsp.js
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Non-breaking space transformations for improved typography.
|
|
3
|
-
*
|
|
4
|
-
* Inserts non-breaking spaces (U+00A0) in positions where line breaks
|
|
5
|
-
* would be typographically undesirable: after short words, between
|
|
6
|
-
* numbers and units, before orphaned last words, etc.
|
|
7
|
-
*
|
|
8
|
-
* @module nbsp
|
|
9
|
-
*/
|
|
10
1
|
import { cachedRegExp, getEscapedSeparator, LATIN_LETTERS, NBSP_CHARS, SPACE_CHARS, UNICODE_SYMBOLS, wordBoundaryEnd } from "./constants.js";
|
|
11
2
|
const { NBSP, LEFT_DOUBLE_QUOTE, RIGHT_DOUBLE_QUOTE, LEFT_SINGLE_QUOTE, RIGHT_SINGLE_QUOTE, COPYRIGHT, REGISTERED, TRADEMARK, } = UNICODE_SYMBOLS;
|
|
12
|
-
/** Space pattern matching regular space, tab, and nbsp. */
|
|
13
3
|
const SPACE = `[${SPACE_CHARS}]`;
|
|
14
4
|
const UNICODE_UPPERCASE = "\\p{Lu}";
|
|
15
|
-
/**
|
|
16
|
-
* Common units for the number-unit nbsp pattern. Only matches these specific
|
|
17
|
-
* abbreviations after a number to avoid false positives like "chapter 3 above".
|
|
18
|
-
*/
|
|
5
|
+
/** Only specific abbreviations are matched to avoid false positives. */
|
|
19
6
|
export const UNITS = [
|
|
20
7
|
// Length
|
|
21
8
|
"km", "cm", "mm", "mi", "ft", "yd", "nm", "pm", "m",
|
|
@@ -88,17 +75,8 @@ const HONORIFIC_PATTERN = HONORIFICS.map((h) => `${h}\\.`).join("|");
|
|
|
88
75
|
const ABBREVIATION_PATTERN = REFERENCE_ABBREVIATIONS.map((a) => `${a}\\.`).join("|");
|
|
89
76
|
const PUNCTUATION_OR_QUOTE = `[.,!?:;)(${LEFT_DOUBLE_QUOTE}${RIGHT_DOUBLE_QUOTE}\u00AB\u00BB${LEFT_SINGLE_QUOTE}${RIGHT_SINGLE_QUOTE}"]`;
|
|
90
77
|
const COPYRIGHT_SYMBOLS = `[${COPYRIGHT}${REGISTERED}${TRADEMARK}]`;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* being left alone at the end of a line.
|
|
94
|
-
*
|
|
95
|
-
* Skips when the short word is already preceded by an NBSP from an earlier
|
|
96
|
-
* transform, or when this match immediately follows the previous one
|
|
97
|
-
* (back-to-back short words in the same pass). Either case would bind three
|
|
98
|
-
* or more words into a single line-break atom — defeating widow protection.
|
|
99
|
-
*
|
|
100
|
-
* @example "a cat" → "a\u00A0cat", "I am" → "I\u00A0am"
|
|
101
|
-
*/
|
|
78
|
+
// Skips when preceded by NBSP or back-to-back with the previous match,
|
|
79
|
+
// preventing 3+ words from binding into a single line-break atom.
|
|
102
80
|
export function nbspAfterShortWords(text, options = {}) {
|
|
103
81
|
const sep = getEscapedSeparator(options);
|
|
104
82
|
const pattern = cachedRegExp(`(?<=^|${SPACE}|${PUNCTUATION_OR_QUOTE}|>)(?<shortWord>[${LATIN_LETTERS}]{1,2})(?<marker>${sep}?)${SPACE}`, "gmu");
|
|
@@ -112,39 +90,16 @@ export function nbspAfterShortWords(text, options = {}) {
|
|
|
112
90
|
return `${shortWord}${marker}${NBSP}`;
|
|
113
91
|
});
|
|
114
92
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Adds non-breaking space between numbers and common units.
|
|
117
|
-
*
|
|
118
|
-
* @example "100 km" → "100\u00A0km", "5 kg" → "5\u00A0kg"
|
|
119
|
-
*/
|
|
120
93
|
export function nbspBetweenNumberAndUnit(text, options = {}) {
|
|
121
94
|
const sep = getEscapedSeparator(options);
|
|
122
95
|
const wbe = wordBoundaryEnd(sep);
|
|
123
96
|
const pattern = cachedRegExp(`(?<digit>\\d)(?<marker1>${sep}?)${SPACE}(?<marker2>${sep}?)(?<unit>${UNIT_PATTERN})${wbe}`, "gm");
|
|
124
97
|
return text.replace(pattern, `$<digit>$<marker1>${NBSP}$<marker2>$<unit>`);
|
|
125
98
|
}
|
|
126
|
-
/**
|
|
127
|
-
* Maximum length, in characters, of the "last word" that gets an NBSP
|
|
128
|
-
* glued to its preceding space. Short enough that a typical English word
|
|
129
|
-
* qualifies but an entire trailing URL or long token does not. Only affects
|
|
130
|
-
* widow prevention at end-of-string and paragraph breaks.
|
|
131
|
-
*/
|
|
132
99
|
const MAX_LAST_WORD_LENGTH = 10;
|
|
133
|
-
|
|
134
|
-
* Maximum word length, in characters, considered for the cascade check.
|
|
135
|
-
* Bounded so the lookbehind in `nbspBeforeLastWord` stays ReDoS-safe.
|
|
136
|
-
*/
|
|
100
|
+
// Bounded so the lookbehind stays ReDoS-safe.
|
|
137
101
|
const MAX_MIDDLE_WORD_LENGTH = 15;
|
|
138
|
-
|
|
139
|
-
* Adds non-breaking space before the last word to prevent widows.
|
|
140
|
-
*
|
|
141
|
-
* Only applies to final words of 1 to {@link MAX_LAST_WORD_LENGTH} characters,
|
|
142
|
-
* at end of string or paragraph break (\n\n). Uses non-multiline mode so $
|
|
143
|
-
* matches only the true end of string.
|
|
144
|
-
*
|
|
145
|
-
* Skips when the second-to-last word is already glued backwards via NBSP,
|
|
146
|
-
* so the phrase doesn't become a 3-word non-breaking atom.
|
|
147
|
-
*/
|
|
102
|
+
// Skips when the second-to-last word is already glued backwards via NBSP.
|
|
148
103
|
export function nbspBeforeLastWord(text, options = {}) {
|
|
149
104
|
const sep = getEscapedSeparator(options);
|
|
150
105
|
const cascadeBlock = `(?<![${NBSP_CHARS}][${LATIN_LETTERS}]{1,${MAX_MIDDLE_WORD_LENGTH}})`;
|
|
@@ -152,66 +107,32 @@ export function nbspBeforeLastWord(text, options = {}) {
|
|
|
152
107
|
const pattern = cachedRegExp(`${cascadeBlock}(?<=\\w|${sep})${SPACE}(?<lastWord>(?:(?!\\s)(?!${sep}).){1,${MAX_LAST_WORD_LENGTH}})(?<ending>${sep}?(?:\\n\\n|$))`, "g");
|
|
153
108
|
return text.replace(pattern, `${NBSP}$<lastWord>$<ending>`);
|
|
154
109
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Adds non-breaking space after reference abbreviations (Fig., Vol., p., etc.)
|
|
157
|
-
* when followed by a number.
|
|
158
|
-
*
|
|
159
|
-
* @example "Fig. 1" → "Fig.\u00A01", "p. 42" → "p.\u00A042"
|
|
160
|
-
*/
|
|
161
110
|
export function nbspAfterReferenceAbbreviations(text, options = {}) {
|
|
162
111
|
const sep = getEscapedSeparator(options);
|
|
163
112
|
const pattern = cachedRegExp(`(?<abbrev>${ABBREVIATION_PATTERN})(?<marker>${sep}?)${SPACE}(?=${sep}?\\d)`, "g");
|
|
164
113
|
return text.replace(pattern, `$<abbrev>$<marker>${NBSP}`);
|
|
165
114
|
}
|
|
166
|
-
/**
|
|
167
|
-
* Adds non-breaking space after section (§) and paragraph (¶) symbols
|
|
168
|
-
* when followed by a number.
|
|
169
|
-
*
|
|
170
|
-
* @example "§ 5" → "§\u00A05"
|
|
171
|
-
*/
|
|
172
115
|
export function nbspAfterSectionSymbols(text, options = {}) {
|
|
173
116
|
const sep = getEscapedSeparator(options);
|
|
174
117
|
const pattern = cachedRegExp(`(?<symbol>[§¶])(?<marker>${sep}?)${SPACE}(?=${sep}?\\d)`, "g");
|
|
175
118
|
return text.replace(pattern, `$<symbol>$<marker>${NBSP}`);
|
|
176
119
|
}
|
|
177
|
-
/**
|
|
178
|
-
* Adds non-breaking space after honorific titles when followed by a capitalized name.
|
|
179
|
-
*
|
|
180
|
-
* @example "Dr. Smith" → "Dr.\u00A0Smith", "Mr. Jones" → "Mr.\u00A0Jones"
|
|
181
|
-
*/
|
|
182
120
|
export function nbspAfterHonorifics(text, options = {}) {
|
|
183
121
|
const sep = getEscapedSeparator(options);
|
|
184
122
|
const pattern = cachedRegExp(`(?<honorific>${HONORIFIC_PATTERN})(?<marker>${sep}?)${SPACE}(?=${sep}?${UNICODE_UPPERCASE})`, "gu");
|
|
185
123
|
return text.replace(pattern, `$<honorific>$<marker>${NBSP}`);
|
|
186
124
|
}
|
|
187
|
-
/**
|
|
188
|
-
* Adds non-breaking space after copyright, registered, and trademark
|
|
189
|
-
* symbols when followed by a year or capitalized name.
|
|
190
|
-
*
|
|
191
|
-
* @example "© 2024" → "©\u00A02024", "® Brand" → "®\u00A0Brand"
|
|
192
|
-
*/
|
|
193
125
|
export function nbspAfterCopyrightSymbols(text, options = {}) {
|
|
194
126
|
const sep = getEscapedSeparator(options);
|
|
195
127
|
const pattern = cachedRegExp(`(?<symbol>${COPYRIGHT_SYMBOLS})(?<marker>${sep}?)${SPACE}(?=${sep}?[\\d${UNICODE_UPPERCASE}])`, "gu");
|
|
196
128
|
return text.replace(pattern, `$<symbol>$<marker>${NBSP}`);
|
|
197
129
|
}
|
|
198
|
-
/**
|
|
199
|
-
* Adds non-breaking space between initials (e.g., "J. K. Rowling").
|
|
200
|
-
*
|
|
201
|
-
* @example "J. K. Rowling" → "J.\u00A0K.\u00A0Rowling"
|
|
202
|
-
*/
|
|
203
130
|
export function nbspBetweenInitials(text, options = {}) {
|
|
204
131
|
const sep = getEscapedSeparator(options);
|
|
205
132
|
const pattern = cachedRegExp(`(?<initial>${UNICODE_UPPERCASE}\\.)(?<marker>${sep}?)${SPACE}(?=${sep}?${UNICODE_UPPERCASE})`, "gu");
|
|
206
133
|
return text.replace(pattern, `$<initial>$<marker>${NBSP}`);
|
|
207
134
|
}
|
|
208
|
-
|
|
209
|
-
* Ordered list of nbsp transforms. Specific patterns (honorifics, abbreviations,
|
|
210
|
-
* initials) come first so they claim their matches before the generic
|
|
211
|
-
* `nbspAfterShortWords`. For example, "No. 5" is matched by
|
|
212
|
-
* `nbspAfterReferenceAbbreviations` first, preventing `nbspAfterShortWords`
|
|
213
|
-
* from also matching "No" as a 2-letter short word.
|
|
214
|
-
*/
|
|
135
|
+
// Specific patterns first so they claim matches before generic nbspAfterShortWords.
|
|
215
136
|
const NBSP_TRANSFORMS = [
|
|
216
137
|
nbspAfterHonorifics,
|
|
217
138
|
nbspAfterReferenceAbbreviations,
|
|
@@ -222,7 +143,6 @@ const NBSP_TRANSFORMS = [
|
|
|
222
143
|
nbspAfterShortWords,
|
|
223
144
|
nbspBeforeLastWord,
|
|
224
145
|
];
|
|
225
|
-
/** Apply all non-breaking space transformations in sequence. */
|
|
226
146
|
export function nbspTransform(text, options = {}) {
|
|
227
147
|
// All nbsp patterns require a space, tab, or existing nbsp to match.
|
|
228
148
|
// Short-circuit if the text contains none of these.
|
package/dist/nbsp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nbsp.js","sourceRoot":"","sources":["../src/nbsp.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"nbsp.js","sourceRoot":"","sources":["../src/nbsp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE5I,MAAM,EACJ,IAAI,EACJ,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,SAAS,GACV,GAAG,eAAe,CAAA;AAOnB,MAAM,KAAK,GAAG,IAAI,WAAW,GAAG,CAAA;AAEhC,MAAM,iBAAiB,GAAG,SAAS,CAAA;AAEnC,wEAAwE;AACxE,MAAM,CAAC,MAAM,KAAK,GAAsB;IACtC,SAAS;IACT,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG;IACnD,OAAO;IACP,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IA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uB,EAAE;IACnE,qEAAqE;IACrE,oDAAoD;IACpD,IAAI,CAAC,YAAY,CAAC,IAAI,WAAW,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IAEjE,KAAK,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC;QACjC,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC1B,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Prettier plugin applying punctilio's typographic transforms to Markdown.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```jsonc
|
|
6
|
-
* // .prettierrc
|
|
7
|
-
* { "plugins": ["punctilio/prettier-plugin"] }
|
|
8
|
-
*
|
|
9
|
-
* // .punctiliorc.json (optional)
|
|
10
|
-
* { "punctuationStyle": "british", "skipTags": ["pre", "code"] }
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @packageDocumentation
|
|
14
|
-
*/
|
|
15
1
|
import type { Plugin } from "prettier";
|
|
16
2
|
declare const plugin: Plugin;
|
|
17
3
|
export default plugin;
|