polytypo 1.0.2 → 1.2.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.
Files changed (37) hide show
  1. package/README.md +14 -5
  2. package/dist/{chunk-UKWVAQMR.js → chunk-44A6YP7S.js} +3 -3
  3. package/dist/chunk-5VBDCDS6.cjs +19 -0
  4. package/dist/{chunk-DZ72ITYV.cjs.map → chunk-5VBDCDS6.cjs.map} +1 -1
  5. package/dist/{chunk-HZPDGNOO.js → chunk-6NTDU63P.js} +3 -3
  6. package/dist/{chunk-MOVY7OL2.cjs → chunk-B4O4R6HI.cjs} +183 -185
  7. package/dist/chunk-B4O4R6HI.cjs.map +1 -0
  8. package/dist/chunk-HGUA2NVX.cjs +21 -0
  9. package/dist/{chunk-F3BDCZSG.cjs.map → chunk-HGUA2NVX.cjs.map} +1 -1
  10. package/dist/{chunk-MMU4UU46.js → chunk-KAO74OJ6.js} +2 -2
  11. package/dist/{chunk-YS3FXB5V.cjs → chunk-LS57O4KJ.cjs} +14 -14
  12. package/dist/{chunk-YS3FXB5V.cjs.map → chunk-LS57O4KJ.cjs.map} +1 -1
  13. package/dist/{chunk-47XAYIKV.js → chunk-OHF7OFWY.js} +183 -185
  14. package/dist/{chunk-47XAYIKV.js.map → chunk-OHF7OFWY.js.map} +1 -1
  15. package/dist/{chunk-M2UGLSIB.cjs → chunk-POGDWVG5.cjs} +11 -11
  16. package/dist/{chunk-M2UGLSIB.cjs.map → chunk-POGDWVG5.cjs.map} +1 -1
  17. package/dist/{chunk-7L4ECXDJ.js → chunk-RC3UKUYZ.js} +2 -2
  18. package/dist/{chunk-E63PQ3N7.js → chunk-VARU43JT.js} +2 -2
  19. package/dist/{chunk-7IZAODBB.cjs → chunk-YYHKX5HE.cjs} +3 -3
  20. package/dist/{chunk-7IZAODBB.cjs.map → chunk-YYHKX5HE.cjs.map} +1 -1
  21. package/dist/html.cjs +7 -7
  22. package/dist/html.js +4 -4
  23. package/dist/index.cjs +10 -10
  24. package/dist/index.js +5 -5
  25. package/dist/markdown.cjs +7 -7
  26. package/dist/markdown.js +4 -4
  27. package/dist/text.cjs +6 -6
  28. package/dist/text.js +3 -3
  29. package/package.json +1 -1
  30. package/dist/chunk-DZ72ITYV.cjs +0 -19
  31. package/dist/chunk-F3BDCZSG.cjs +0 -21
  32. package/dist/chunk-MOVY7OL2.cjs.map +0 -1
  33. /package/dist/{chunk-UKWVAQMR.js.map → chunk-44A6YP7S.js.map} +0 -0
  34. /package/dist/{chunk-HZPDGNOO.js.map → chunk-6NTDU63P.js.map} +0 -0
  35. /package/dist/{chunk-MMU4UU46.js.map → chunk-KAO74OJ6.js.map} +0 -0
  36. /package/dist/{chunk-7L4ECXDJ.js.map → chunk-RC3UKUYZ.js.map} +0 -0
  37. /package/dist/{chunk-E63PQ3N7.js.map → chunk-VARU43JT.js.map} +0 -0
package/README.md CHANGED
@@ -35,7 +35,7 @@ npm install polytypo
35
35
  ## Usage
36
36
 
37
37
  ```ts
38
- import { transform } from "polytypo";
38
+ import { transform } from "polytypo/text";
39
39
 
40
40
  transform(`She said, "it's fine" -- but I wasn't sure...`, { locale: "en-US" });
41
41
  // She said, “it’s fine”—but I wasn’t sure…
@@ -49,6 +49,16 @@ transform(`Sie sagte: "Alles gut" -- aber ich war mir nicht sicher...`, { locale
49
49
  // Sie sagte: „Alles gut“ – aber ich war mir nicht sicher…
50
50
  ```
51
51
 
52
+ Import the entry for the mode you use. Each subpath entry defaults `mode` to itself and loads only
53
+ the parsers that mode needs:
54
+
55
+ | Entry | Parsers it loads |
56
+ | ------------------- | ------------------------------------------------------------- |
57
+ | `polytypo/text` | none |
58
+ | `polytypo/html` | parse5 |
59
+ | `polytypo/markdown` | parse5, micromark and its GFM, frontmatter and MDX extensions |
60
+ | `polytypo` | all of the above |
61
+
52
62
  HTML and Markdown are first-class modes, not an afterthought — tags, attributes and fenced code
53
63
  are left alone; only text content is touched:
54
64
 
@@ -59,10 +69,9 @@ transform(`<a title="test... wait">Wait... she said "go on."</a>`, { locale: "en
59
69
  // <a title="test... wait">Wait… she said “go on.”</a>
60
70
  ```
61
71
 
62
- Subpath entries (`polytypo/text`, `polytypo/html`, `polytypo/markdown`) exclude the parser
63
- dependencies the other modes don't need, and each defaults `mode` to itself. The aggregate
64
- `polytypo` entry defaults `mode` to `"text"`; `locale` has no default anywhere and must always be
65
- passed explicitly — there is no silent fallback to English.
72
+ The aggregate `polytypo` entry defaults `mode` to `"text"` and is the one to use when the mode is
73
+ chosen at runtime. `locale` has no default anywhere and must always be passed explicitly — there is
74
+ no silent fallback to English.
66
75
 
67
76
  ## Licence
68
77
 
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  htmlSpans,
3
3
  runOverSpans
4
- } from "./chunk-E63PQ3N7.js";
4
+ } from "./chunk-VARU43JT.js";
5
5
  import {
6
6
  getLocaleData,
7
7
  planRules
8
- } from "./chunk-47XAYIKV.js";
8
+ } from "./chunk-OHF7OFWY.js";
9
9
 
10
10
  // src/engine/html-pipeline.ts
11
11
  function runHtmlPipeline(input, options) {
@@ -18,4 +18,4 @@ function runHtmlPipeline(input, options) {
18
18
  export {
19
19
  runHtmlPipeline
20
20
  };
21
- //# sourceMappingURL=chunk-UKWVAQMR.js.map
21
+ //# sourceMappingURL=chunk-44A6YP7S.js.map
@@ -0,0 +1,19 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+ var _chunkB4O4R6HIcjs = require('./chunk-B4O4R6HI.cjs');
8
+
9
+ // src/engine/text-pipeline.ts
10
+ function runTextPipeline(input, options) {
11
+ const planned = _chunkB4O4R6HIcjs.planRules.call(void 0, options.rules);
12
+ const locale = _chunkB4O4R6HIcjs.getLocaleData.call(void 0, options.locale);
13
+ return _chunkB4O4R6HIcjs.fromCodePoints.call(void 0, _chunkB4O4R6HIcjs.runRules.call(void 0, _chunkB4O4R6HIcjs.toCodePoints.call(void 0, input), planned, locale, "text"));
14
+ }
15
+
16
+
17
+
18
+ exports.runTextPipeline = runTextPipeline;
19
+ //# sourceMappingURL=chunk-5VBDCDS6.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-DZ72ITYV.cjs","../src/engine/text-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACQO,SAAS,eAAA,CAAgB,KAAA,EAAe,OAAA,EAAmC;AAChF,EAAA,MAAM,QAAA,EAAU,yCAAA,OAAU,CAAQ,KAAK,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,6CAAA,OAAc,CAAQ,MAAM,CAAA;AAC3C,EAAA,OAAO,8CAAA,wCAAe,4CAAS,KAAkB,CAAA,EAAG,OAAA,EAAS,MAAA,EAAQ,MAAM,CAAC,CAAA;AAC9E;ADNA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-DZ72ITYV.cjs","sourcesContent":[null,"import type { Options } from \"../types.js\";\nimport { fromCodePoints, toCodePoints } from \"./codepoints.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { planRules, runRules } from \"./rule-runner.js\";\n\n/**\n * `text` mode only. Deliberately imports nothing from `../modes/html.js` or\n * `../modes/markdown.js` (or their parser dependencies) — this is what makes `polytypo/text`'s\n * module graph exclude `parse5` and the Micromark stack (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md\n * 5.1).\n *\n * Validation order — `planRules` before `getLocaleData` — mirrors the pre-Stage-5 aggregate\n * `runPipeline` exactly (an unknown-rule error must win over an unknown-locale error when both\n * are present, since that is public, tested behaviour, not an implementation detail this\n * refactor was authorised to change).\n */\nexport function runTextPipeline(input: string, options: Partial<Options>): string {\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n return fromCodePoints(runRules(toCodePoints(input), planned, locale, \"text\"));\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-5VBDCDS6.cjs","../src/engine/text-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACQO,SAAS,eAAA,CAAgB,KAAA,EAAe,OAAA,EAAmC;AAChF,EAAA,MAAM,QAAA,EAAU,yCAAA,OAAU,CAAQ,KAAK,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,6CAAA,OAAc,CAAQ,MAAM,CAAA;AAC3C,EAAA,OAAO,8CAAA,wCAAe,4CAAS,KAAkB,CAAA,EAAG,OAAA,EAAS,MAAA,EAAQ,MAAM,CAAC,CAAA;AAC9E;ADNA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-5VBDCDS6.cjs","sourcesContent":[null,"import type { Options } from \"../types.js\";\nimport { fromCodePoints, toCodePoints } from \"./codepoints.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { planRules, runRules } from \"./rule-runner.js\";\n\n/**\n * `text` mode only. Deliberately imports nothing from `../modes/html.js` or\n * `../modes/markdown.js` (or their parser dependencies) — this is what makes `polytypo/text`'s\n * module graph exclude `parse5` and the Micromark stack (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md\n * 5.1).\n *\n * Validation order — `planRules` before `getLocaleData` — mirrors the pre-Stage-5 aggregate\n * `runPipeline` exactly (an unknown-rule error must win over an unknown-locale error when both\n * are present, since that is public, tested behaviour, not an implementation detail this\n * refactor was authorised to change).\n */\nexport function runTextPipeline(input: string, options: Partial<Options>): string {\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n return fromCodePoints(runRules(toCodePoints(input), planned, locale, \"text\"));\n}\n"]}
@@ -3,12 +3,12 @@ import {
3
3
  isSkippedElement,
4
4
  runOverSpans,
5
5
  wrapParserErrors
6
- } from "./chunk-E63PQ3N7.js";
6
+ } from "./chunk-VARU43JT.js";
7
7
  import {
8
8
  PolytypoError,
9
9
  getLocaleData,
10
10
  planRules
11
- } from "./chunk-47XAYIKV.js";
11
+ } from "./chunk-OHF7OFWY.js";
12
12
 
13
13
  // src/modes/markdown.ts
14
14
  import { parse, postprocess, preprocess } from "micromark";
@@ -160,4 +160,4 @@ function runMarkdownPipeline(input, options) {
160
160
  export {
161
161
  runMarkdownPipeline
162
162
  };
163
- //# sourceMappingURL=chunk-HZPDGNOO.js.map
163
+ //# sourceMappingURL=chunk-6NTDU63P.js.map