polytypo 1.2.0 → 1.3.1
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 +48 -0
- package/dist/{chunk-KAO74OJ6.js → chunk-4GYU4TXA.js} +2 -2
- package/dist/{chunk-6NTDU63P.js → chunk-5NCJ3Y65.js} +35 -11
- package/dist/chunk-5NCJ3Y65.js.map +1 -0
- package/dist/chunk-5U3DRTV7.js +205 -0
- package/dist/chunk-5U3DRTV7.js.map +1 -0
- package/dist/chunk-5VNPHCL2.cjs +264 -0
- package/dist/chunk-5VNPHCL2.cjs.map +1 -0
- package/dist/{chunk-POGDWVG5.cjs → chunk-AR6FDQAX.cjs} +40 -16
- package/dist/chunk-AR6FDQAX.cjs.map +1 -0
- package/dist/chunk-B7WXSXRG.js +31 -0
- package/dist/chunk-B7WXSXRG.js.map +1 -0
- package/dist/{chunk-VARU43JT.js → chunk-DXWMSR26.js} +4 -154
- package/dist/chunk-DXWMSR26.js.map +1 -0
- package/dist/chunk-ECYUONLP.cjs +205 -0
- package/dist/chunk-ECYUONLP.cjs.map +1 -0
- package/dist/chunk-FK3F3YZT.cjs +33 -0
- package/dist/chunk-FK3F3YZT.cjs.map +1 -0
- package/dist/chunk-QNSBCZU5.cjs +31 -0
- package/dist/chunk-QNSBCZU5.cjs.map +1 -0
- package/dist/chunk-THTCAO3O.cjs +147 -0
- package/dist/chunk-THTCAO3O.cjs.map +1 -0
- package/dist/chunk-UBEV2AC3.js +264 -0
- package/dist/chunk-UBEV2AC3.js.map +1 -0
- package/dist/chunk-V4EOJ44S.cjs +5778 -0
- package/dist/chunk-V4EOJ44S.cjs.map +1 -0
- package/dist/chunk-VC5XLP6O.js +33 -0
- package/dist/chunk-VC5XLP6O.js.map +1 -0
- package/dist/chunk-VKJVMMCI.js +5778 -0
- package/dist/chunk-VKJVMMCI.js.map +1 -0
- package/dist/{chunk-YYHKX5HE.cjs → chunk-W2T7B2SH.cjs} +3 -3
- package/dist/{chunk-YYHKX5HE.cjs.map → chunk-W2T7B2SH.cjs.map} +1 -1
- package/dist/{errors-joZChNws.d.ts → errors-CGFOVO3h.d.cts} +34 -4
- package/dist/{errors-joZChNws.d.cts → errors-CGFOVO3h.d.ts} +34 -4
- package/dist/html.cjs +15 -7
- package/dist/html.cjs.map +1 -1
- package/dist/html.d.cts +9 -3
- package/dist/html.d.ts +9 -3
- package/dist/html.js +12 -4
- package/dist/html.js.map +1 -1
- package/dist/index.cjs +33 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +28 -7
- package/dist/index.js.map +1 -1
- package/dist/markdown.cjs +15 -7
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.d.cts +9 -3
- package/dist/markdown.d.ts +9 -3
- package/dist/markdown.js +12 -4
- package/dist/markdown.js.map +1 -1
- package/dist/text.cjs +13 -6
- package/dist/text.cjs.map +1 -1
- package/dist/text.d.cts +8 -3
- package/dist/text.d.ts +8 -3
- package/dist/text.js +10 -3
- package/dist/text.js.map +1 -1
- package/dist/yaml.cjs +29 -0
- package/dist/yaml.cjs.map +1 -0
- package/dist/yaml.d.cts +27 -0
- package/dist/yaml.d.ts +27 -0
- package/dist/yaml.js +29 -0
- package/dist/yaml.js.map +1 -0
- package/package.json +12 -2
- package/dist/chunk-44A6YP7S.js +0 -21
- package/dist/chunk-44A6YP7S.js.map +0 -1
- package/dist/chunk-5VBDCDS6.cjs +0 -19
- package/dist/chunk-5VBDCDS6.cjs.map +0 -1
- package/dist/chunk-6NTDU63P.js.map +0 -1
- package/dist/chunk-B4O4R6HI.cjs +0 -5633
- package/dist/chunk-B4O4R6HI.cjs.map +0 -1
- package/dist/chunk-HGUA2NVX.cjs +0 -21
- package/dist/chunk-HGUA2NVX.cjs.map +0 -1
- package/dist/chunk-LS57O4KJ.cjs +0 -297
- package/dist/chunk-LS57O4KJ.cjs.map +0 -1
- package/dist/chunk-OHF7OFWY.js +0 -5633
- package/dist/chunk-OHF7OFWY.js.map +0 -1
- package/dist/chunk-POGDWVG5.cjs.map +0 -1
- package/dist/chunk-RC3UKUYZ.js +0 -19
- package/dist/chunk-RC3UKUYZ.js.map +0 -1
- package/dist/chunk-VARU43JT.js.map +0 -1
- /package/dist/{chunk-KAO74OJ6.js.map → chunk-4GYU4TXA.js.map} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkV4EOJ44Scjs = require('./chunk-V4EOJ44S.cjs');
|
|
4
4
|
|
|
5
5
|
// src/engine/assert-fixed-mode.ts
|
|
6
6
|
function assertFixedMode(mode, fixed, entryPoint) {
|
|
7
7
|
if (mode === void 0 || mode === fixed) return;
|
|
8
|
-
throw new (0,
|
|
8
|
+
throw new (0, _chunkV4EOJ44Scjs.PolytypoError)(
|
|
9
9
|
"POLYTYPO_INVALID_MODE",
|
|
10
10
|
`"${entryPoint}" only supports mode "${fixed}". Received "${String(mode)}" \u2014 import from "polytypo" for the other modes, or omit \`mode\` here.`
|
|
11
11
|
);
|
|
@@ -14,4 +14,4 @@ function assertFixedMode(mode, fixed, entryPoint) {
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
exports.assertFixedMode = assertFixedMode;
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
17
|
+
//# sourceMappingURL=chunk-W2T7B2SH.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-W2T7B2SH.cjs","../src/engine/assert-fixed-mode.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACMO,SAAS,eAAA,CAAgB,IAAA,EAAe,KAAA,EAAa,UAAA,EAA0B;AACpF,EAAA,GAAA,CAAI,KAAA,IAAS,KAAA,EAAA,GAAa,KAAA,IAAS,KAAA,EAAO,MAAA;AAC1C,EAAA,MAAM,IAAI,oCAAA;AAAA,IACR,uBAAA;AAAA,IACA,CAAA,CAAA,EAAI,UAAU,CAAA,sBAAA,EAAyB,KAAK,CAAA,aAAA,EAAgB,MAAA,CAAO,IAAI,CAAC,CAAA,2EAAA;AAAA,EAE1E,CAAA;AACF;ADLA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-W2T7B2SH.cjs","sourcesContent":[null,"import { PolytypoError } from \"../errors.js\";\nimport type { Mode } from \"../types.js\";\n\n/**\n * `polytypo/text`, `polytypo/html` and `polytypo/markdown` each fix `mode` at the type level by\n * omitting it from their Options type (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1, criterion 6).\n * A plain-JS caller — or a TypeScript caller passing a wider-typed variable, which excess-property\n * checking does not catch — can still supply a conflicting `mode` at runtime. That is rejected\n * explicitly here, never silently ignored or overridden.\n */\nexport function assertFixedMode(mode: unknown, fixed: Mode, entryPoint: string): void {\n if (mode === undefined || mode === fixed) return;\n throw new PolytypoError(\n \"POLYTYPO_INVALID_MODE\",\n `\"${entryPoint}\" only supports mode \"${fixed}\". Received \"${String(mode)}\" — ` +\n `import from \"polytypo\" for the other modes, or omit \\`mode\\` here.`,\n );\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Mode = "text" | "html" | "markdown";
|
|
1
|
+
type Mode = "text" | "html" | "markdown" | "yaml";
|
|
2
2
|
/**
|
|
3
3
|
* `markdown` is not one language (spec/rules/modes.md 3.7.1). CommonMark and MDX disagree on
|
|
4
4
|
* ordinary documents, so the caller states which they have — it is the file extension, and the
|
|
@@ -11,8 +11,15 @@ interface Options {
|
|
|
11
11
|
/** Required. An unknown locale throws; there is never a fallback to English. */
|
|
12
12
|
locale: string;
|
|
13
13
|
mode?: Mode;
|
|
14
|
-
/** Required when `mode` is `"markdown"`, with no default; ignored in
|
|
14
|
+
/** Required when `mode` is `"markdown"`, with no default; ignored in the other three modes. */
|
|
15
15
|
dialect?: Dialect;
|
|
16
|
+
/**
|
|
17
|
+
* Required when `mode` is `"yaml"`, with no default; ignored in the other three modes
|
|
18
|
+
* (spec/rules/modes.md §3.8.2). The mapping keys whose scalar values are processable — YAML is
|
|
19
|
+
* a data format with islands of prose in it, so the caller names them and the library never
|
|
20
|
+
* guesses. An empty list is legal and processes nothing.
|
|
21
|
+
*/
|
|
22
|
+
keys?: readonly string[];
|
|
16
23
|
/**
|
|
17
24
|
* Per-rule override, keyed by `RuleId`. For a default-on rule (every rule except `ranges`),
|
|
18
25
|
* `false` disables it and `true` is a no-op. For `ranges` — off by default (spec 0.5.0) —
|
|
@@ -20,7 +27,15 @@ interface Options {
|
|
|
20
27
|
* key always means "use that rule's own default", never "off".
|
|
21
28
|
*/
|
|
22
29
|
rules?: Partial<Record<RuleId, boolean>>;
|
|
30
|
+
/**
|
|
31
|
+
* `"nbsp"` makes the engine emit U+00A0 everywhere it would emit U+202F — the narrow no-break
|
|
32
|
+
* space many common faces do not carry (nbsp.md §3.1a). Default `"narrow"`. This moves the
|
|
33
|
+
* rule's target rather than post-processing the output, so the result stays a fixed point.
|
|
34
|
+
*/
|
|
35
|
+
narrowNbsp?: NarrowNbsp;
|
|
23
36
|
}
|
|
37
|
+
/** nbsp.md §3.1a. `"narrow"` (the default) emits U+202F; `"nbsp"` emits U+00A0 in its place. */
|
|
38
|
+
type NarrowNbsp = "narrow" | "nbsp";
|
|
24
39
|
/** Mirrors spec/schema/locale.schema.json. Literal data only — no patterns, no priorities. */
|
|
25
40
|
interface QuotePair {
|
|
26
41
|
readonly open: string;
|
|
@@ -103,6 +118,12 @@ interface RuleContext {
|
|
|
103
118
|
readonly cp: readonly number[];
|
|
104
119
|
readonly locale: LocaleData;
|
|
105
120
|
readonly mode: Mode;
|
|
121
|
+
/**
|
|
122
|
+
* nbsp.md §3.1a's NARROW-TARGET, already resolved to a code point: U+202F by default, U+00A0
|
|
123
|
+
* when the caller passed `narrowNbsp: "nbsp"`. A rule reads a code point and never the option,
|
|
124
|
+
* so the string never reaches the pipeline.
|
|
125
|
+
*/
|
|
126
|
+
readonly narrowTarget: number;
|
|
106
127
|
}
|
|
107
128
|
interface Rule {
|
|
108
129
|
readonly id: RuleId;
|
|
@@ -110,11 +131,20 @@ interface Rule {
|
|
|
110
131
|
apply(ctx: RuleContext): Edit[];
|
|
111
132
|
}
|
|
112
133
|
|
|
113
|
-
|
|
134
|
+
/** One entry of `analyze`'s result, in input coordinates (analyze.md §2). */
|
|
135
|
+
interface Change {
|
|
136
|
+
readonly ruleId: RuleId;
|
|
137
|
+
readonly start: number;
|
|
138
|
+
readonly end: number;
|
|
139
|
+
readonly before: string;
|
|
140
|
+
readonly after: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
type PolytypoErrorCode = "POLYTYPO_UNKNOWN_LOCALE" | "POLYTYPO_INVALID_MODE" | "POLYTYPO_INVALID_DIALECT" | "POLYTYPO_UNKNOWN_RULE" | "POLYTYPO_MALFORMED_LOCALE_DATA" | "POLYTYPO_RULE_CONTRACT" | "POLYTYPO_MALFORMED_INPUT" | "POLYTYPO_INVALID_OPTION";
|
|
114
144
|
/** Codes are the contract across all five runtimes; messages are English and are not (ARCHITECTURE.md 4.6). */
|
|
115
145
|
declare class PolytypoError extends Error {
|
|
116
146
|
readonly code: PolytypoErrorCode;
|
|
117
147
|
constructor(code: PolytypoErrorCode, message: string);
|
|
118
148
|
}
|
|
119
149
|
|
|
120
|
-
export { type Dialect as D, type Edit as E, type LocaleData as L, type Mode as M, type Options as O, PolytypoError as P, type QuotePair as Q, type Rule as R, type LocaleSource as a, type PolytypoErrorCode as b, type RuleContext as c, type RuleId as d };
|
|
150
|
+
export { type Change as C, type Dialect as D, type Edit as E, type LocaleData as L, type Mode as M, type NarrowNbsp as N, type Options as O, PolytypoError as P, type QuotePair as Q, type Rule as R, type LocaleSource as a, type PolytypoErrorCode as b, type RuleContext as c, type RuleId as d };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Mode = "text" | "html" | "markdown";
|
|
1
|
+
type Mode = "text" | "html" | "markdown" | "yaml";
|
|
2
2
|
/**
|
|
3
3
|
* `markdown` is not one language (spec/rules/modes.md 3.7.1). CommonMark and MDX disagree on
|
|
4
4
|
* ordinary documents, so the caller states which they have — it is the file extension, and the
|
|
@@ -11,8 +11,15 @@ interface Options {
|
|
|
11
11
|
/** Required. An unknown locale throws; there is never a fallback to English. */
|
|
12
12
|
locale: string;
|
|
13
13
|
mode?: Mode;
|
|
14
|
-
/** Required when `mode` is `"markdown"`, with no default; ignored in
|
|
14
|
+
/** Required when `mode` is `"markdown"`, with no default; ignored in the other three modes. */
|
|
15
15
|
dialect?: Dialect;
|
|
16
|
+
/**
|
|
17
|
+
* Required when `mode` is `"yaml"`, with no default; ignored in the other three modes
|
|
18
|
+
* (spec/rules/modes.md §3.8.2). The mapping keys whose scalar values are processable — YAML is
|
|
19
|
+
* a data format with islands of prose in it, so the caller names them and the library never
|
|
20
|
+
* guesses. An empty list is legal and processes nothing.
|
|
21
|
+
*/
|
|
22
|
+
keys?: readonly string[];
|
|
16
23
|
/**
|
|
17
24
|
* Per-rule override, keyed by `RuleId`. For a default-on rule (every rule except `ranges`),
|
|
18
25
|
* `false` disables it and `true` is a no-op. For `ranges` — off by default (spec 0.5.0) —
|
|
@@ -20,7 +27,15 @@ interface Options {
|
|
|
20
27
|
* key always means "use that rule's own default", never "off".
|
|
21
28
|
*/
|
|
22
29
|
rules?: Partial<Record<RuleId, boolean>>;
|
|
30
|
+
/**
|
|
31
|
+
* `"nbsp"` makes the engine emit U+00A0 everywhere it would emit U+202F — the narrow no-break
|
|
32
|
+
* space many common faces do not carry (nbsp.md §3.1a). Default `"narrow"`. This moves the
|
|
33
|
+
* rule's target rather than post-processing the output, so the result stays a fixed point.
|
|
34
|
+
*/
|
|
35
|
+
narrowNbsp?: NarrowNbsp;
|
|
23
36
|
}
|
|
37
|
+
/** nbsp.md §3.1a. `"narrow"` (the default) emits U+202F; `"nbsp"` emits U+00A0 in its place. */
|
|
38
|
+
type NarrowNbsp = "narrow" | "nbsp";
|
|
24
39
|
/** Mirrors spec/schema/locale.schema.json. Literal data only — no patterns, no priorities. */
|
|
25
40
|
interface QuotePair {
|
|
26
41
|
readonly open: string;
|
|
@@ -103,6 +118,12 @@ interface RuleContext {
|
|
|
103
118
|
readonly cp: readonly number[];
|
|
104
119
|
readonly locale: LocaleData;
|
|
105
120
|
readonly mode: Mode;
|
|
121
|
+
/**
|
|
122
|
+
* nbsp.md §3.1a's NARROW-TARGET, already resolved to a code point: U+202F by default, U+00A0
|
|
123
|
+
* when the caller passed `narrowNbsp: "nbsp"`. A rule reads a code point and never the option,
|
|
124
|
+
* so the string never reaches the pipeline.
|
|
125
|
+
*/
|
|
126
|
+
readonly narrowTarget: number;
|
|
106
127
|
}
|
|
107
128
|
interface Rule {
|
|
108
129
|
readonly id: RuleId;
|
|
@@ -110,11 +131,20 @@ interface Rule {
|
|
|
110
131
|
apply(ctx: RuleContext): Edit[];
|
|
111
132
|
}
|
|
112
133
|
|
|
113
|
-
|
|
134
|
+
/** One entry of `analyze`'s result, in input coordinates (analyze.md §2). */
|
|
135
|
+
interface Change {
|
|
136
|
+
readonly ruleId: RuleId;
|
|
137
|
+
readonly start: number;
|
|
138
|
+
readonly end: number;
|
|
139
|
+
readonly before: string;
|
|
140
|
+
readonly after: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
type PolytypoErrorCode = "POLYTYPO_UNKNOWN_LOCALE" | "POLYTYPO_INVALID_MODE" | "POLYTYPO_INVALID_DIALECT" | "POLYTYPO_UNKNOWN_RULE" | "POLYTYPO_MALFORMED_LOCALE_DATA" | "POLYTYPO_RULE_CONTRACT" | "POLYTYPO_MALFORMED_INPUT" | "POLYTYPO_INVALID_OPTION";
|
|
114
144
|
/** Codes are the contract across all five runtimes; messages are English and are not (ARCHITECTURE.md 4.6). */
|
|
115
145
|
declare class PolytypoError extends Error {
|
|
116
146
|
readonly code: PolytypoErrorCode;
|
|
117
147
|
constructor(code: PolytypoErrorCode, message: string);
|
|
118
148
|
}
|
|
119
149
|
|
|
120
|
-
export { type Dialect as D, type Edit as E, type LocaleData as L, type Mode as M, type Options as O, PolytypoError as P, type QuotePair as Q, type Rule as R, type LocaleSource as a, type PolytypoErrorCode as b, type RuleContext as c, type RuleId as d };
|
|
150
|
+
export { type Change as C, type Dialect as D, type Edit as E, type LocaleData as L, type Mode as M, type NarrowNbsp as N, type Options as O, PolytypoError as P, type QuotePair as Q, type Rule as R, type LocaleSource as a, type PolytypoErrorCode as b, type RuleContext as c, type RuleId as d };
|
package/dist/html.cjs
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var _chunkHGUA2NVXcjs = require('./chunk-HGUA2NVX.cjs');
|
|
4
|
-
require('./chunk-LS57O4KJ.cjs');
|
|
5
3
|
|
|
4
|
+
var _chunkFK3F3YZTcjs = require('./chunk-FK3F3YZT.cjs');
|
|
5
|
+
require('./chunk-THTCAO3O.cjs');
|
|
6
|
+
require('./chunk-ECYUONLP.cjs');
|
|
6
7
|
|
|
7
|
-
var _chunkYYHKX5HEcjs = require('./chunk-YYHKX5HE.cjs');
|
|
8
8
|
|
|
9
|
+
var _chunkW2T7B2SHcjs = require('./chunk-W2T7B2SH.cjs');
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
var _chunkV4EOJ44Scjs = require('./chunk-V4EOJ44S.cjs');
|
|
11
13
|
|
|
12
14
|
// src/index.html.ts
|
|
13
15
|
function transform(input, options) {
|
|
14
16
|
const given = _nullishCoalesce(options, () => ( {}));
|
|
15
|
-
|
|
16
|
-
return
|
|
17
|
+
_chunkW2T7B2SHcjs.assertFixedMode.call(void 0, given.mode, "html", "polytypo/html");
|
|
18
|
+
return _chunkFK3F3YZTcjs.runHtmlPipeline.call(void 0, input, given);
|
|
19
|
+
}
|
|
20
|
+
function analyze(input, options) {
|
|
21
|
+
const given = _nullishCoalesce(options, () => ( {}));
|
|
22
|
+
_chunkW2T7B2SHcjs.assertFixedMode.call(void 0, given.mode, "html", "polytypo/html");
|
|
23
|
+
return _chunkFK3F3YZTcjs.analyzeHtmlPipeline.call(void 0, input, given);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
|
|
20
27
|
|
|
21
|
-
|
|
28
|
+
|
|
29
|
+
exports.PolytypoError = _chunkV4EOJ44Scjs.PolytypoError; exports.analyze = analyze; exports.transform = transform;
|
|
22
30
|
//# sourceMappingURL=html.cjs.map
|
package/dist/html.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/html.cjs","../src/index.html.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/html.cjs","../src/index.html.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACGO,SAAS,SAAA,CAAU,KAAA,EAAe,OAAA,EAA8B;AACrE,EAAA,MAAM,MAAA,mBAAS,OAAA,UAAW,CAAC,GAAA;AAC3B,EAAA,+CAAA,KAAgB,CAAM,IAAA,EAAM,MAAA,EAAQ,eAAe,CAAA;AACnD,EAAA,OAAO,+CAAA,KAAgB,EAAO,KAAK,CAAA;AACrC;AAOO,SAAS,OAAA,CAAQ,KAAA,EAAe,OAAA,EAAgC;AACrE,EAAA,MAAM,MAAA,mBAAS,OAAA,UAAW,CAAC,GAAA;AAC3B,EAAA,+CAAA,KAAgB,CAAM,IAAA,EAAM,MAAA,EAAQ,eAAe,CAAA;AACnD,EAAA,OAAO,mDAAA,KAAoB,EAAO,KAAK,CAAA;AACzC;ADPA;AACE;AACA;AACA;AACF,kHAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/html.cjs","sourcesContent":[null,"import { assertFixedMode } from \"./engine/assert-fixed-mode.js\";\nimport { analyzeHtmlPipeline, runHtmlPipeline } from \"./engine/html-pipeline.js\";\nimport type { Change } from \"./engine/origin.js\";\nimport type { Options } from \"./types.js\";\n\n/**\n * `polytypo/html` — HTML-only entry point. Its module graph includes `parse5` but excludes the\n * Micromark/MDX stack (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1): it imports\n * `./engine/html-pipeline.js` directly and never `./engine/pipeline.js` or `./modes/markdown.js`.\n *\n * `mode` is absent from `HtmlOptions`, since this entry only ever runs `html` mode. `dialect` is\n * likewise absent — it has no effect in `html` mode even in the aggregate entry (types.ts), so\n * there is nothing for it to conflict with here.\n */\nexport type HtmlOptions = Omit<Options, \"mode\" | \"dialect\">;\n\nexport function transform(input: string, options: HtmlOptions): string {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return runHtmlPipeline(input, given);\n}\n\n/**\n * The same pipeline as this entry's `transform`, reporting instead of applying\n * (spec/rules/analyze.md). Offsets are code-point offsets into `input` — into the document,\n * not into a span (analyze.md §6).\n */\nexport function analyze(input: string, options: HtmlOptions): Change[] {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return analyzeHtmlPipeline(input, given);\n}\n\nexport { PolytypoError } from \"./errors.js\";\nexport type { PolytypoErrorCode } from \"./errors.js\";\nexport type { Change } from \"./engine/origin.js\";\nexport type { NarrowNbsp } from \"./types.js\";\nexport type { LocaleData, LocaleSource, QuotePair, Rule, RuleContext, RuleId } from \"./types.js\";\n"]}
|
package/dist/html.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as Options } from './errors-
|
|
2
|
-
export { L as LocaleData, a as LocaleSource, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-
|
|
1
|
+
import { O as Options, C as Change } from './errors-CGFOVO3h.cjs';
|
|
2
|
+
export { L as LocaleData, a as LocaleSource, N as NarrowNbsp, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-CGFOVO3h.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* `polytypo/html` — HTML-only entry point. Its module graph includes `parse5` but excludes the
|
|
@@ -12,5 +12,11 @@ export { L as LocaleData, a as LocaleSource, P as PolytypoError, b as PolytypoEr
|
|
|
12
12
|
*/
|
|
13
13
|
type HtmlOptions = Omit<Options, "mode" | "dialect">;
|
|
14
14
|
declare function transform(input: string, options: HtmlOptions): string;
|
|
15
|
+
/**
|
|
16
|
+
* The same pipeline as this entry's `transform`, reporting instead of applying
|
|
17
|
+
* (spec/rules/analyze.md). Offsets are code-point offsets into `input` — into the document,
|
|
18
|
+
* not into a span (analyze.md §6).
|
|
19
|
+
*/
|
|
20
|
+
declare function analyze(input: string, options: HtmlOptions): Change[];
|
|
15
21
|
|
|
16
|
-
export { type HtmlOptions, transform };
|
|
22
|
+
export { Change, type HtmlOptions, analyze, transform };
|
package/dist/html.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as Options } from './errors-
|
|
2
|
-
export { L as LocaleData, a as LocaleSource, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-
|
|
1
|
+
import { O as Options, C as Change } from './errors-CGFOVO3h.js';
|
|
2
|
+
export { L as LocaleData, a as LocaleSource, N as NarrowNbsp, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-CGFOVO3h.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* `polytypo/html` — HTML-only entry point. Its module graph includes `parse5` but excludes the
|
|
@@ -12,5 +12,11 @@ export { L as LocaleData, a as LocaleSource, P as PolytypoError, b as PolytypoEr
|
|
|
12
12
|
*/
|
|
13
13
|
type HtmlOptions = Omit<Options, "mode" | "dialect">;
|
|
14
14
|
declare function transform(input: string, options: HtmlOptions): string;
|
|
15
|
+
/**
|
|
16
|
+
* The same pipeline as this entry's `transform`, reporting instead of applying
|
|
17
|
+
* (spec/rules/analyze.md). Offsets are code-point offsets into `input` — into the document,
|
|
18
|
+
* not into a span (analyze.md §6).
|
|
19
|
+
*/
|
|
20
|
+
declare function analyze(input: string, options: HtmlOptions): Change[];
|
|
15
21
|
|
|
16
|
-
export { type HtmlOptions, transform };
|
|
22
|
+
export { Change, type HtmlOptions, analyze, transform };
|
package/dist/html.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
+
analyzeHtmlPipeline,
|
|
2
3
|
runHtmlPipeline
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-VC5XLP6O.js";
|
|
5
|
+
import "./chunk-DXWMSR26.js";
|
|
6
|
+
import "./chunk-5U3DRTV7.js";
|
|
5
7
|
import {
|
|
6
8
|
assertFixedMode
|
|
7
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4GYU4TXA.js";
|
|
8
10
|
import {
|
|
9
11
|
PolytypoError
|
|
10
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VKJVMMCI.js";
|
|
11
13
|
|
|
12
14
|
// src/index.html.ts
|
|
13
15
|
function transform(input, options) {
|
|
@@ -15,8 +17,14 @@ function transform(input, options) {
|
|
|
15
17
|
assertFixedMode(given.mode, "html", "polytypo/html");
|
|
16
18
|
return runHtmlPipeline(input, given);
|
|
17
19
|
}
|
|
20
|
+
function analyze(input, options) {
|
|
21
|
+
const given = options ?? {};
|
|
22
|
+
assertFixedMode(given.mode, "html", "polytypo/html");
|
|
23
|
+
return analyzeHtmlPipeline(input, given);
|
|
24
|
+
}
|
|
18
25
|
export {
|
|
19
26
|
PolytypoError,
|
|
27
|
+
analyze,
|
|
20
28
|
transform
|
|
21
29
|
};
|
|
22
30
|
//# sourceMappingURL=html.js.map
|
package/dist/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.html.ts"],"sourcesContent":["import { assertFixedMode } from \"./engine/assert-fixed-mode.js\";\nimport { runHtmlPipeline } from \"./engine/html-pipeline.js\";\nimport type { Options } from \"./types.js\";\n\n/**\n * `polytypo/html` — HTML-only entry point. Its module graph includes `parse5` but excludes the\n * Micromark/MDX stack (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1): it imports\n * `./engine/html-pipeline.js` directly and never `./engine/pipeline.js` or `./modes/markdown.js`.\n *\n * `mode` is absent from `HtmlOptions`, since this entry only ever runs `html` mode. `dialect` is\n * likewise absent — it has no effect in `html` mode even in the aggregate entry (types.ts), so\n * there is nothing for it to conflict with here.\n */\nexport type HtmlOptions = Omit<Options, \"mode\" | \"dialect\">;\n\nexport function transform(input: string, options: HtmlOptions): string {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return runHtmlPipeline(input, given);\n}\n\nexport { PolytypoError } from \"./errors.js\";\nexport type { PolytypoErrorCode } from \"./errors.js\";\nexport type { LocaleData, LocaleSource, QuotePair, Rule, RuleContext, RuleId } from \"./types.js\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.html.ts"],"sourcesContent":["import { assertFixedMode } from \"./engine/assert-fixed-mode.js\";\nimport { analyzeHtmlPipeline, runHtmlPipeline } from \"./engine/html-pipeline.js\";\nimport type { Change } from \"./engine/origin.js\";\nimport type { Options } from \"./types.js\";\n\n/**\n * `polytypo/html` — HTML-only entry point. Its module graph includes `parse5` but excludes the\n * Micromark/MDX stack (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1): it imports\n * `./engine/html-pipeline.js` directly and never `./engine/pipeline.js` or `./modes/markdown.js`.\n *\n * `mode` is absent from `HtmlOptions`, since this entry only ever runs `html` mode. `dialect` is\n * likewise absent — it has no effect in `html` mode even in the aggregate entry (types.ts), so\n * there is nothing for it to conflict with here.\n */\nexport type HtmlOptions = Omit<Options, \"mode\" | \"dialect\">;\n\nexport function transform(input: string, options: HtmlOptions): string {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return runHtmlPipeline(input, given);\n}\n\n/**\n * The same pipeline as this entry's `transform`, reporting instead of applying\n * (spec/rules/analyze.md). Offsets are code-point offsets into `input` — into the document,\n * not into a span (analyze.md §6).\n */\nexport function analyze(input: string, options: HtmlOptions): Change[] {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return analyzeHtmlPipeline(input, given);\n}\n\nexport { PolytypoError } from \"./errors.js\";\nexport type { PolytypoErrorCode } from \"./errors.js\";\nexport type { Change } from \"./engine/origin.js\";\nexport type { NarrowNbsp } from \"./types.js\";\nexport type { LocaleData, LocaleSource, QuotePair, Rule, RuleContext, RuleId } from \"./types.js\";\n"],"mappings":";;;;;;;;;;;;;;AAgBO,SAAS,UAAU,OAAe,SAA8B;AACrE,QAAM,QAAS,WAAW,CAAC;AAC3B,kBAAgB,MAAM,MAAM,QAAQ,eAAe;AACnD,SAAO,gBAAgB,OAAO,KAAK;AACrC;AAOO,SAAS,QAAQ,OAAe,SAAgC;AACrE,QAAM,QAAS,WAAW,CAAC;AAC3B,kBAAgB,MAAM,MAAM,QAAQ,eAAe;AACnD,SAAO,oBAAoB,OAAO,KAAK;AACzC;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,40 +1,61 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var _chunk5VBDCDS6cjs = require('./chunk-5VBDCDS6.cjs');
|
|
4
3
|
|
|
4
|
+
var _chunkQNSBCZU5cjs = require('./chunk-QNSBCZU5.cjs');
|
|
5
5
|
|
|
6
|
-
var _chunkHGUA2NVXcjs = require('./chunk-HGUA2NVX.cjs');
|
|
7
6
|
|
|
8
7
|
|
|
9
|
-
var
|
|
10
|
-
require('./chunk-LS57O4KJ.cjs');
|
|
8
|
+
var _chunkFK3F3YZTcjs = require('./chunk-FK3F3YZT.cjs');
|
|
11
9
|
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
|
|
12
|
+
var _chunkAR6FDQAXcjs = require('./chunk-AR6FDQAX.cjs');
|
|
13
|
+
require('./chunk-THTCAO3O.cjs');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var _chunk5VNPHCL2cjs = require('./chunk-5VNPHCL2.cjs');
|
|
18
|
+
require('./chunk-ECYUONLP.cjs');
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var _chunkV4EOJ44Scjs = require('./chunk-V4EOJ44S.cjs');
|
|
14
22
|
|
|
15
23
|
// src/engine/pipeline.ts
|
|
16
24
|
function resolveMode(mode) {
|
|
17
25
|
if (mode === void 0 || mode === "text") return "text";
|
|
18
|
-
if (mode === "html" || mode === "markdown") return mode;
|
|
19
|
-
throw new (0,
|
|
26
|
+
if (mode === "html" || mode === "markdown" || mode === "yaml") return mode;
|
|
27
|
+
throw new (0, _chunkV4EOJ44Scjs.PolytypoError)(
|
|
20
28
|
"POLYTYPO_INVALID_MODE",
|
|
21
|
-
`Unknown mode "${String(mode)}". Expected "text", "html" or "
|
|
29
|
+
`Unknown mode "${String(mode)}". Expected "text", "html", "markdown" or "yaml".`
|
|
22
30
|
);
|
|
23
31
|
}
|
|
24
32
|
function runPipeline(input, options) {
|
|
25
33
|
const given = _nullishCoalesce(options, () => ( {}));
|
|
26
34
|
const mode = resolveMode(given.mode);
|
|
27
|
-
if (mode === "text") return
|
|
28
|
-
if (mode === "html") return
|
|
29
|
-
return
|
|
35
|
+
if (mode === "text") return _chunkQNSBCZU5cjs.runTextPipeline.call(void 0, input, given);
|
|
36
|
+
if (mode === "html") return _chunkFK3F3YZTcjs.runHtmlPipeline.call(void 0, input, given);
|
|
37
|
+
if (mode === "yaml") return _chunk5VNPHCL2cjs.runYamlPipeline.call(void 0, input, given);
|
|
38
|
+
return _chunkAR6FDQAXcjs.runMarkdownPipeline.call(void 0, input, given);
|
|
39
|
+
}
|
|
40
|
+
function runAnalyze(input, options) {
|
|
41
|
+
const given = _nullishCoalesce(options, () => ( {}));
|
|
42
|
+
const mode = resolveMode(given.mode);
|
|
43
|
+
if (mode === "text") return _chunkQNSBCZU5cjs.analyzeTextPipeline.call(void 0, input, given);
|
|
44
|
+
if (mode === "html") return _chunkFK3F3YZTcjs.analyzeHtmlPipeline.call(void 0, input, given);
|
|
45
|
+
if (mode === "yaml") return _chunk5VNPHCL2cjs.analyzeYamlPipeline.call(void 0, input, given);
|
|
46
|
+
return _chunkAR6FDQAXcjs.analyzeMarkdownPipeline.call(void 0, input, given);
|
|
30
47
|
}
|
|
31
48
|
|
|
32
49
|
// src/index.ts
|
|
33
50
|
function transform(input, options) {
|
|
34
51
|
return runPipeline(input, options);
|
|
35
52
|
}
|
|
53
|
+
function analyze(input, options) {
|
|
54
|
+
return runAnalyze(input, options);
|
|
55
|
+
}
|
|
56
|
+
|
|
36
57
|
|
|
37
58
|
|
|
38
59
|
|
|
39
|
-
exports.PolytypoError =
|
|
60
|
+
exports.PolytypoError = _chunkV4EOJ44Scjs.PolytypoError; exports.analyze = analyze; exports.transform = transform;
|
|
40
61
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/index.cjs","../src/engine/pipeline.ts","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/index.cjs","../src/engine/pipeline.ts","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACZA,SAAS,WAAA,CAAY,IAAA,EAA8B;AACjD,EAAA,GAAA,CAAI,KAAA,IAAS,KAAA,EAAA,GAAa,KAAA,IAAS,MAAA,EAAQ,OAAO,MAAA;AAClD,EAAA,GAAA,CAAI,KAAA,IAAS,OAAA,GAAU,KAAA,IAAS,WAAA,GAAc,KAAA,IAAS,MAAA,EAAQ,OAAO,IAAA;AACtE,EAAA,MAAM,IAAI,oCAAA;AAAA,IACR,uBAAA;AAAA,IACA,CAAA,cAAA,EAAiB,MAAA,CAAO,IAAI,CAAC,CAAA,iDAAA;AAAA,EAC/B,CAAA;AACF;AASO,SAAS,WAAA,CAAY,KAAA,EAAe,OAAA,EAA0B;AAInE,EAAA,MAAM,MAAA,mBAA0B,OAAA,UAAW,CAAC,GAAA;AAC5C,EAAA,MAAM,KAAA,EAAO,WAAA,CAAY,KAAA,CAAM,IAAI,CAAA;AACnC,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,OAAO,+CAAA,KAAgB,EAAO,KAAK,CAAA;AACxD,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,OAAO,+CAAA,KAAgB,EAAO,KAAK,CAAA;AACxD,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,OAAO,+CAAA,KAAgB,EAAO,KAAK,CAAA;AACxD,EAAA,OAAO,mDAAA,KAAoB,EAAO,KAAK,CAAA;AACzC;AAOO,SAAS,UAAA,CAAW,KAAA,EAAe,OAAA,EAA4B;AACpE,EAAA,MAAM,MAAA,mBAA0B,OAAA,UAAW,CAAC,GAAA;AAC5C,EAAA,MAAM,KAAA,EAAO,WAAA,CAAY,KAAA,CAAM,IAAI,CAAA;AACnC,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,OAAO,mDAAA,KAAoB,EAAO,KAAK,CAAA;AAC5D,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,OAAO,mDAAA,KAAoB,EAAO,KAAK,CAAA;AAC5D,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,OAAO,mDAAA,KAAoB,EAAO,KAAK,CAAA;AAC5D,EAAA,OAAO,uDAAA,KAAwB,EAAO,KAAK,CAAA;AAC7C;ADHA;AACA;AE5CO,SAAS,SAAA,CAAU,KAAA,EAAe,OAAA,EAA0B;AACjE,EAAA,OAAO,WAAA,CAAY,KAAA,EAAO,OAAO,CAAA;AACnC;AAYO,SAAS,OAAA,CAAQ,KAAA,EAAe,OAAA,EAA4B;AACjE,EAAA,OAAO,UAAA,CAAW,KAAA,EAAO,OAAO,CAAA;AAClC;AFmCA;AACE;AACA;AACA;AACF,kHAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/index.cjs","sourcesContent":[null,"import { PolytypoError } from \"../errors.js\";\nimport type { Mode, Options } from \"../types.js\";\nimport { analyzeHtmlPipeline, runHtmlPipeline } from \"./html-pipeline.js\";\nimport { analyzeMarkdownPipeline, runMarkdownPipeline } from \"./markdown-pipeline.js\";\nimport { analyzeTextPipeline, runTextPipeline } from \"./text-pipeline.js\";\nimport { analyzeYamlPipeline, runYamlPipeline } from \"./yaml-pipeline.js\";\nimport type { Change } from \"./origin.js\";\n\nexport { planRules } from \"./rule-runner.js\";\n\nfunction resolveMode(mode: Mode | undefined): Mode {\n if (mode === undefined || mode === \"text\") return \"text\";\n if (mode === \"html\" || mode === \"markdown\" || mode === \"yaml\") return mode;\n throw new PolytypoError(\n \"POLYTYPO_INVALID_MODE\",\n `Unknown mode \"${String(mode)}\". Expected \"text\", \"html\", \"markdown\" or \"yaml\".`,\n );\n}\n\n/**\n * The aggregate entry's dispatcher: every mode is reachable, so it is the only pipeline module\n * that imports all four mode-specific ones (and therefore the only one whose module graph\n * includes both `parse5` and the Micromark/MDX stack). `polytypo/text`, `polytypo/html` and\n * `polytypo/markdown` each call their own mode-specific pipeline directly and never import this\n * module (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1).\n */\nexport function runPipeline(input: string, options: Options): string {\n // A plain-JS caller can omit the options object entirely. Reading through a null here would\n // raise a native TypeError, which is outside the error taxonomy; an absent `locale` is an\n // unknown locale and must say so with a code (locale-resolution.md 3.1).\n const given: Partial<Options> = options ?? {};\n const mode = resolveMode(given.mode);\n if (mode === \"text\") return runTextPipeline(input, given);\n if (mode === \"html\") return runHtmlPipeline(input, given);\n if (mode === \"yaml\") return runYamlPipeline(input, given);\n return runMarkdownPipeline(input, given);\n}\n\n/**\n * The dispatcher for `analyze` (analyze.md §1). Mode resolution, and therefore\n * POLYTYPO_INVALID_MODE, is shared with `runPipeline` rather than duplicated: A1 requires the\n * two entry points to accept and reject exactly the same arguments.\n */\nexport function runAnalyze(input: string, options: Options): Change[] {\n const given: Partial<Options> = options ?? {};\n const mode = resolveMode(given.mode);\n if (mode === \"text\") return analyzeTextPipeline(input, given);\n if (mode === \"html\") return analyzeHtmlPipeline(input, given);\n if (mode === \"yaml\") return analyzeYamlPipeline(input, given);\n return analyzeMarkdownPipeline(input, given);\n}\n","import { runAnalyze, runPipeline } from \"./engine/pipeline.js\";\nimport type { Change } from \"./engine/origin.js\";\nimport type { Options } from \"./types.js\";\n\nexport function transform(input: string, options: Options): string {\n return runPipeline(input, options);\n}\n\n/**\n * The same pipeline as `transform`, reporting what it would do instead of doing it\n * (spec/rules/analyze.md). Offsets are code-point offsets into `input` in every mode.\n *\n * What it guarantees: the list is empty exactly when `transform` would return the input\n * unchanged, every `ruleId` was enabled for the call, and every offset is inside the input.\n * What it does not: the list is a report, not a patch — two rules may touch the same original\n * range, so replaying it is not guaranteed to reproduce `transform`'s output. Call `transform`\n * for the text (analyze.md §4, §5).\n */\nexport function analyze(input: string, options: Options): Change[] {\n return runAnalyze(input, options);\n}\n\nexport { PolytypoError } from \"./errors.js\";\nexport type { PolytypoErrorCode } from \"./errors.js\";\nexport type { Change } from \"./engine/origin.js\";\nexport type {\n Dialect,\n Edit,\n LocaleData,\n LocaleSource,\n Mode,\n NarrowNbsp,\n Options,\n QuotePair,\n Rule,\n RuleContext,\n RuleId,\n} from \"./types.js\";\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import { O as Options } from './errors-
|
|
2
|
-
export { D as Dialect, E as Edit, L as LocaleData, a as LocaleSource, M as Mode, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-
|
|
1
|
+
import { O as Options, C as Change } from './errors-CGFOVO3h.cjs';
|
|
2
|
+
export { D as Dialect, E as Edit, L as LocaleData, a as LocaleSource, M as Mode, N as NarrowNbsp, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-CGFOVO3h.cjs';
|
|
3
3
|
|
|
4
4
|
declare function transform(input: string, options: Options): string;
|
|
5
|
+
/**
|
|
6
|
+
* The same pipeline as `transform`, reporting what it would do instead of doing it
|
|
7
|
+
* (spec/rules/analyze.md). Offsets are code-point offsets into `input` in every mode.
|
|
8
|
+
*
|
|
9
|
+
* What it guarantees: the list is empty exactly when `transform` would return the input
|
|
10
|
+
* unchanged, every `ruleId` was enabled for the call, and every offset is inside the input.
|
|
11
|
+
* What it does not: the list is a report, not a patch — two rules may touch the same original
|
|
12
|
+
* range, so replaying it is not guaranteed to reproduce `transform`'s output. Call `transform`
|
|
13
|
+
* for the text (analyze.md §4, §5).
|
|
14
|
+
*/
|
|
15
|
+
declare function analyze(input: string, options: Options): Change[];
|
|
5
16
|
|
|
6
|
-
export { Options, transform };
|
|
17
|
+
export { Change, Options, analyze, transform };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import { O as Options } from './errors-
|
|
2
|
-
export { D as Dialect, E as Edit, L as LocaleData, a as LocaleSource, M as Mode, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-
|
|
1
|
+
import { O as Options, C as Change } from './errors-CGFOVO3h.js';
|
|
2
|
+
export { D as Dialect, E as Edit, L as LocaleData, a as LocaleSource, M as Mode, N as NarrowNbsp, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-CGFOVO3h.js';
|
|
3
3
|
|
|
4
4
|
declare function transform(input: string, options: Options): string;
|
|
5
|
+
/**
|
|
6
|
+
* The same pipeline as `transform`, reporting what it would do instead of doing it
|
|
7
|
+
* (spec/rules/analyze.md). Offsets are code-point offsets into `input` in every mode.
|
|
8
|
+
*
|
|
9
|
+
* What it guarantees: the list is empty exactly when `transform` would return the input
|
|
10
|
+
* unchanged, every `ruleId` was enabled for the call, and every offset is inside the input.
|
|
11
|
+
* What it does not: the list is a report, not a patch — two rules may touch the same original
|
|
12
|
+
* range, so replaying it is not guaranteed to reproduce `transform`'s output. Call `transform`
|
|
13
|
+
* for the text (analyze.md §4, §5).
|
|
14
|
+
*/
|
|
15
|
+
declare function analyze(input: string, options: Options): Change[];
|
|
5
16
|
|
|
6
|
-
export { Options, transform };
|
|
17
|
+
export { Change, Options, analyze, transform };
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
|
+
analyzeTextPipeline,
|
|
2
3
|
runTextPipeline
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-B7WXSXRG.js";
|
|
4
5
|
import {
|
|
6
|
+
analyzeHtmlPipeline,
|
|
5
7
|
runHtmlPipeline
|
|
6
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VC5XLP6O.js";
|
|
7
9
|
import {
|
|
10
|
+
analyzeMarkdownPipeline,
|
|
8
11
|
runMarkdownPipeline
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-5NCJ3Y65.js";
|
|
13
|
+
import "./chunk-DXWMSR26.js";
|
|
14
|
+
import {
|
|
15
|
+
analyzeYamlPipeline,
|
|
16
|
+
runYamlPipeline
|
|
17
|
+
} from "./chunk-UBEV2AC3.js";
|
|
18
|
+
import "./chunk-5U3DRTV7.js";
|
|
11
19
|
import {
|
|
12
20
|
PolytypoError
|
|
13
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-VKJVMMCI.js";
|
|
14
22
|
|
|
15
23
|
// src/engine/pipeline.ts
|
|
16
24
|
function resolveMode(mode) {
|
|
17
25
|
if (mode === void 0 || mode === "text") return "text";
|
|
18
|
-
if (mode === "html" || mode === "markdown") return mode;
|
|
26
|
+
if (mode === "html" || mode === "markdown" || mode === "yaml") return mode;
|
|
19
27
|
throw new PolytypoError(
|
|
20
28
|
"POLYTYPO_INVALID_MODE",
|
|
21
|
-
`Unknown mode "${String(mode)}". Expected "text", "html" or "
|
|
29
|
+
`Unknown mode "${String(mode)}". Expected "text", "html", "markdown" or "yaml".`
|
|
22
30
|
);
|
|
23
31
|
}
|
|
24
32
|
function runPipeline(input, options) {
|
|
@@ -26,15 +34,28 @@ function runPipeline(input, options) {
|
|
|
26
34
|
const mode = resolveMode(given.mode);
|
|
27
35
|
if (mode === "text") return runTextPipeline(input, given);
|
|
28
36
|
if (mode === "html") return runHtmlPipeline(input, given);
|
|
37
|
+
if (mode === "yaml") return runYamlPipeline(input, given);
|
|
29
38
|
return runMarkdownPipeline(input, given);
|
|
30
39
|
}
|
|
40
|
+
function runAnalyze(input, options) {
|
|
41
|
+
const given = options ?? {};
|
|
42
|
+
const mode = resolveMode(given.mode);
|
|
43
|
+
if (mode === "text") return analyzeTextPipeline(input, given);
|
|
44
|
+
if (mode === "html") return analyzeHtmlPipeline(input, given);
|
|
45
|
+
if (mode === "yaml") return analyzeYamlPipeline(input, given);
|
|
46
|
+
return analyzeMarkdownPipeline(input, given);
|
|
47
|
+
}
|
|
31
48
|
|
|
32
49
|
// src/index.ts
|
|
33
50
|
function transform(input, options) {
|
|
34
51
|
return runPipeline(input, options);
|
|
35
52
|
}
|
|
53
|
+
function analyze(input, options) {
|
|
54
|
+
return runAnalyze(input, options);
|
|
55
|
+
}
|
|
36
56
|
export {
|
|
37
57
|
PolytypoError,
|
|
58
|
+
analyze,
|
|
38
59
|
transform
|
|
39
60
|
};
|
|
40
61
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/engine/pipeline.ts","../src/index.ts"],"sourcesContent":["import { PolytypoError } from \"../errors.js\";\nimport type { Mode, Options } from \"../types.js\";\nimport { runHtmlPipeline } from \"./html-pipeline.js\";\nimport { runMarkdownPipeline } from \"./markdown-pipeline.js\";\nimport { runTextPipeline } from \"./text-pipeline.js\";\n\nexport { planRules } from \"./rule-runner.js\";\n\nfunction resolveMode(mode: Mode | undefined): Mode {\n if (mode === undefined || mode === \"text\") return \"text\";\n if (mode === \"html\" || mode === \"markdown\") return mode;\n throw new PolytypoError(\n \"POLYTYPO_INVALID_MODE\",\n `Unknown mode \"${String(mode)}\". Expected \"text\", \"html\" or \"
|
|
1
|
+
{"version":3,"sources":["../src/engine/pipeline.ts","../src/index.ts"],"sourcesContent":["import { PolytypoError } from \"../errors.js\";\nimport type { Mode, Options } from \"../types.js\";\nimport { analyzeHtmlPipeline, runHtmlPipeline } from \"./html-pipeline.js\";\nimport { analyzeMarkdownPipeline, runMarkdownPipeline } from \"./markdown-pipeline.js\";\nimport { analyzeTextPipeline, runTextPipeline } from \"./text-pipeline.js\";\nimport { analyzeYamlPipeline, runYamlPipeline } from \"./yaml-pipeline.js\";\nimport type { Change } from \"./origin.js\";\n\nexport { planRules } from \"./rule-runner.js\";\n\nfunction resolveMode(mode: Mode | undefined): Mode {\n if (mode === undefined || mode === \"text\") return \"text\";\n if (mode === \"html\" || mode === \"markdown\" || mode === \"yaml\") return mode;\n throw new PolytypoError(\n \"POLYTYPO_INVALID_MODE\",\n `Unknown mode \"${String(mode)}\". Expected \"text\", \"html\", \"markdown\" or \"yaml\".`,\n );\n}\n\n/**\n * The aggregate entry's dispatcher: every mode is reachable, so it is the only pipeline module\n * that imports all four mode-specific ones (and therefore the only one whose module graph\n * includes both `parse5` and the Micromark/MDX stack). `polytypo/text`, `polytypo/html` and\n * `polytypo/markdown` each call their own mode-specific pipeline directly and never import this\n * module (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1).\n */\nexport function runPipeline(input: string, options: Options): string {\n // A plain-JS caller can omit the options object entirely. Reading through a null here would\n // raise a native TypeError, which is outside the error taxonomy; an absent `locale` is an\n // unknown locale and must say so with a code (locale-resolution.md 3.1).\n const given: Partial<Options> = options ?? {};\n const mode = resolveMode(given.mode);\n if (mode === \"text\") return runTextPipeline(input, given);\n if (mode === \"html\") return runHtmlPipeline(input, given);\n if (mode === \"yaml\") return runYamlPipeline(input, given);\n return runMarkdownPipeline(input, given);\n}\n\n/**\n * The dispatcher for `analyze` (analyze.md §1). Mode resolution, and therefore\n * POLYTYPO_INVALID_MODE, is shared with `runPipeline` rather than duplicated: A1 requires the\n * two entry points to accept and reject exactly the same arguments.\n */\nexport function runAnalyze(input: string, options: Options): Change[] {\n const given: Partial<Options> = options ?? {};\n const mode = resolveMode(given.mode);\n if (mode === \"text\") return analyzeTextPipeline(input, given);\n if (mode === \"html\") return analyzeHtmlPipeline(input, given);\n if (mode === \"yaml\") return analyzeYamlPipeline(input, given);\n return analyzeMarkdownPipeline(input, given);\n}\n","import { runAnalyze, runPipeline } from \"./engine/pipeline.js\";\nimport type { Change } from \"./engine/origin.js\";\nimport type { Options } from \"./types.js\";\n\nexport function transform(input: string, options: Options): string {\n return runPipeline(input, options);\n}\n\n/**\n * The same pipeline as `transform`, reporting what it would do instead of doing it\n * (spec/rules/analyze.md). Offsets are code-point offsets into `input` in every mode.\n *\n * What it guarantees: the list is empty exactly when `transform` would return the input\n * unchanged, every `ruleId` was enabled for the call, and every offset is inside the input.\n * What it does not: the list is a report, not a patch — two rules may touch the same original\n * range, so replaying it is not guaranteed to reproduce `transform`'s output. Call `transform`\n * for the text (analyze.md §4, §5).\n */\nexport function analyze(input: string, options: Options): Change[] {\n return runAnalyze(input, options);\n}\n\nexport { PolytypoError } from \"./errors.js\";\nexport type { PolytypoErrorCode } from \"./errors.js\";\nexport type { Change } from \"./engine/origin.js\";\nexport type {\n Dialect,\n Edit,\n LocaleData,\n LocaleSource,\n Mode,\n NarrowNbsp,\n Options,\n QuotePair,\n Rule,\n RuleContext,\n RuleId,\n} from \"./types.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAUA,SAAS,YAAY,MAA8B;AACjD,MAAI,SAAS,UAAa,SAAS,OAAQ,QAAO;AAClD,MAAI,SAAS,UAAU,SAAS,cAAc,SAAS,OAAQ,QAAO;AACtE,QAAM,IAAI;AAAA,IACR;AAAA,IACA,iBAAiB,OAAO,IAAI,CAAC;AAAA,EAC/B;AACF;AASO,SAAS,YAAY,OAAe,SAA0B;AAInE,QAAM,QAA0B,WAAW,CAAC;AAC5C,QAAM,OAAO,YAAY,MAAM,IAAI;AACnC,MAAI,SAAS,OAAQ,QAAO,gBAAgB,OAAO,KAAK;AACxD,MAAI,SAAS,OAAQ,QAAO,gBAAgB,OAAO,KAAK;AACxD,MAAI,SAAS,OAAQ,QAAO,gBAAgB,OAAO,KAAK;AACxD,SAAO,oBAAoB,OAAO,KAAK;AACzC;AAOO,SAAS,WAAW,OAAe,SAA4B;AACpE,QAAM,QAA0B,WAAW,CAAC;AAC5C,QAAM,OAAO,YAAY,MAAM,IAAI;AACnC,MAAI,SAAS,OAAQ,QAAO,oBAAoB,OAAO,KAAK;AAC5D,MAAI,SAAS,OAAQ,QAAO,oBAAoB,OAAO,KAAK;AAC5D,MAAI,SAAS,OAAQ,QAAO,oBAAoB,OAAO,KAAK;AAC5D,SAAO,wBAAwB,OAAO,KAAK;AAC7C;;;AC9CO,SAAS,UAAU,OAAe,SAA0B;AACjE,SAAO,YAAY,OAAO,OAAO;AACnC;AAYO,SAAS,QAAQ,OAAe,SAA4B;AACjE,SAAO,WAAW,OAAO,OAAO;AAClC;","names":[]}
|
package/dist/markdown.cjs
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var _chunkPOGDWVG5cjs = require('./chunk-POGDWVG5.cjs');
|
|
4
|
-
require('./chunk-LS57O4KJ.cjs');
|
|
5
3
|
|
|
4
|
+
var _chunkAR6FDQAXcjs = require('./chunk-AR6FDQAX.cjs');
|
|
5
|
+
require('./chunk-THTCAO3O.cjs');
|
|
6
|
+
require('./chunk-ECYUONLP.cjs');
|
|
6
7
|
|
|
7
|
-
var _chunkYYHKX5HEcjs = require('./chunk-YYHKX5HE.cjs');
|
|
8
8
|
|
|
9
|
+
var _chunkW2T7B2SHcjs = require('./chunk-W2T7B2SH.cjs');
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
var _chunkV4EOJ44Scjs = require('./chunk-V4EOJ44S.cjs');
|
|
11
13
|
|
|
12
14
|
// src/index.markdown.ts
|
|
13
15
|
function transform(input, options) {
|
|
14
16
|
const given = _nullishCoalesce(options, () => ( {}));
|
|
15
|
-
|
|
16
|
-
return
|
|
17
|
+
_chunkW2T7B2SHcjs.assertFixedMode.call(void 0, given.mode, "markdown", "polytypo/markdown");
|
|
18
|
+
return _chunkAR6FDQAXcjs.runMarkdownPipeline.call(void 0, input, given);
|
|
19
|
+
}
|
|
20
|
+
function analyze(input, options) {
|
|
21
|
+
const given = _nullishCoalesce(options, () => ( {}));
|
|
22
|
+
_chunkW2T7B2SHcjs.assertFixedMode.call(void 0, given.mode, "markdown", "polytypo/markdown");
|
|
23
|
+
return _chunkAR6FDQAXcjs.analyzeMarkdownPipeline.call(void 0, input, given);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
|
|
20
27
|
|
|
21
|
-
|
|
28
|
+
|
|
29
|
+
exports.PolytypoError = _chunkV4EOJ44Scjs.PolytypoError; exports.analyze = analyze; exports.transform = transform;
|
|
22
30
|
//# sourceMappingURL=markdown.cjs.map
|
package/dist/markdown.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/markdown.cjs","../src/index.markdown.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/markdown.cjs","../src/index.markdown.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACMO,SAAS,SAAA,CAAU,KAAA,EAAe,OAAA,EAAkC;AACzE,EAAA,MAAM,MAAA,mBAAS,OAAA,UAAW,CAAC,GAAA;AAC3B,EAAA,+CAAA,KAAgB,CAAM,IAAA,EAAM,UAAA,EAAY,mBAAmB,CAAA;AAC3D,EAAA,OAAO,mDAAA,KAAoB,EAAO,KAAK,CAAA;AACzC;AAOO,SAAS,OAAA,CAAQ,KAAA,EAAe,OAAA,EAAoC;AACzE,EAAA,MAAM,MAAA,mBAAS,OAAA,UAAW,CAAC,GAAA;AAC3B,EAAA,+CAAA,KAAgB,CAAM,IAAA,EAAM,UAAA,EAAY,mBAAmB,CAAA;AAC3D,EAAA,OAAO,uDAAA,KAAwB,EAAO,KAAK,CAAA;AAC7C;ADVA;AACE;AACA;AACA;AACF,kHAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/markdown.cjs","sourcesContent":[null,"import { assertFixedMode } from \"./engine/assert-fixed-mode.js\";\nimport { analyzeMarkdownPipeline, runMarkdownPipeline } from \"./engine/markdown-pipeline.js\";\nimport type { Change } from \"./engine/origin.js\";\nimport type { Dialect, Options } from \"./types.js\";\n\n/**\n * `polytypo/markdown` — Markdown-only entry point. Its module graph includes the Micromark/MDX\n * stack and `parse5` (the latter via `./modes/markdown.js` importing `./modes/html.js` for\n * normative embedded-HTML handling, modes.md 3.7) — both are legitimately reachable here\n * (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1). It imports `./engine/markdown-pipeline.js`\n * directly and never `./engine/pipeline.js`.\n *\n * `mode` is absent from `MarkdownOptions`, since this entry only ever runs `markdown` mode.\n * `dialect` keeps the aggregate entry's contract: required, no default (types.ts).\n */\nexport type MarkdownOptions = Omit<Options, \"mode\"> & {\n dialect: Dialect;\n};\n\nexport function transform(input: string, options: MarkdownOptions): string {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"markdown\", \"polytypo/markdown\");\n return runMarkdownPipeline(input, given);\n}\n\n/**\n * The same pipeline as this entry's `transform`, reporting instead of applying\n * (spec/rules/analyze.md). Offsets are code-point offsets into `input` — into the document,\n * not into a span (analyze.md §6).\n */\nexport function analyze(input: string, options: MarkdownOptions): Change[] {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"markdown\", \"polytypo/markdown\");\n return analyzeMarkdownPipeline(input, given);\n}\n\nexport { PolytypoError } from \"./errors.js\";\nexport type { PolytypoErrorCode } from \"./errors.js\";\nexport type {\n Dialect,\n LocaleData,\n LocaleSource,\n NarrowNbsp,\n QuotePair,\n Rule,\n RuleContext,\n RuleId,\n} from \"./types.js\";\n"]}
|