polytypo 1.1.0 → 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-EWZWHW3B.js → chunk-44A6YP7S.js} +3 -3
  3. package/dist/chunk-5VBDCDS6.cjs +19 -0
  4. package/dist/{chunk-A4HNRHBV.cjs.map → chunk-5VBDCDS6.cjs.map} +1 -1
  5. package/dist/{chunk-X2B4LIW3.js → chunk-6NTDU63P.js} +3 -3
  6. package/dist/{chunk-ADRRRKLB.cjs → chunk-B4O4R6HI.cjs} +16 -3
  7. package/dist/chunk-B4O4R6HI.cjs.map +1 -0
  8. package/dist/chunk-HGUA2NVX.cjs +21 -0
  9. package/dist/{chunk-IS7WKMGA.cjs.map → chunk-HGUA2NVX.cjs.map} +1 -1
  10. package/dist/{chunk-4FZZJB7Y.js → chunk-KAO74OJ6.js} +2 -2
  11. package/dist/{chunk-RNFW7474.cjs → chunk-LS57O4KJ.cjs} +14 -14
  12. package/dist/{chunk-RNFW7474.cjs.map → chunk-LS57O4KJ.cjs.map} +1 -1
  13. package/dist/{chunk-3XRMEZDM.js → chunk-OHF7OFWY.js} +16 -3
  14. package/dist/{chunk-3XRMEZDM.js.map → chunk-OHF7OFWY.js.map} +1 -1
  15. package/dist/{chunk-5BVKKURT.cjs → chunk-POGDWVG5.cjs} +11 -11
  16. package/dist/{chunk-5BVKKURT.cjs.map → chunk-POGDWVG5.cjs.map} +1 -1
  17. package/dist/{chunk-ILWDO7FZ.js → chunk-RC3UKUYZ.js} +2 -2
  18. package/dist/{chunk-ZBLCAVSM.js → chunk-VARU43JT.js} +2 -2
  19. package/dist/{chunk-CZRTSOOB.cjs → chunk-YYHKX5HE.cjs} +3 -3
  20. package/dist/{chunk-CZRTSOOB.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-A4HNRHBV.cjs +0 -19
  31. package/dist/chunk-ADRRRKLB.cjs.map +0 -1
  32. package/dist/chunk-IS7WKMGA.cjs +0 -21
  33. /package/dist/{chunk-EWZWHW3B.js.map → chunk-44A6YP7S.js.map} +0 -0
  34. /package/dist/{chunk-X2B4LIW3.js.map → chunk-6NTDU63P.js.map} +0 -0
  35. /package/dist/{chunk-4FZZJB7Y.js.map → chunk-KAO74OJ6.js.map} +0 -0
  36. /package/dist/{chunk-ILWDO7FZ.js.map → chunk-RC3UKUYZ.js.map} +0 -0
  37. /package/dist/{chunk-ZBLCAVSM.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-ZBLCAVSM.js";
4
+ } from "./chunk-VARU43JT.js";
5
5
  import {
6
6
  getLocaleData,
7
7
  planRules
8
- } from "./chunk-3XRMEZDM.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-EWZWHW3B.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-A4HNRHBV.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-A4HNRHBV.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-ZBLCAVSM.js";
6
+ } from "./chunk-VARU43JT.js";
7
7
  import {
8
8
  PolytypoError,
9
9
  getLocaleData,
10
10
  planRules
11
- } from "./chunk-3XRMEZDM.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-X2B4LIW3.js.map
163
+ //# sourceMappingURL=chunk-6NTDU63P.js.map
@@ -3897,6 +3897,16 @@ var CLOSEISH = /* @__PURE__ */ new Set([
3897
3897
  8211,
3898
3898
  8212
3899
3899
  ]);
3900
+ var OPENQUOTE = /* @__PURE__ */ new Set([
3901
+ 171,
3902
+ 8216,
3903
+ 8218,
3904
+ 8219,
3905
+ 8220,
3906
+ 8222,
3907
+ 8223,
3908
+ 8249
3909
+ ]);
3900
3910
  function at(cp, i) {
3901
3911
  const value = cp[i];
3902
3912
  return value === void 0 ? NONE : value;
@@ -3912,6 +3922,7 @@ function isApostrophe(left, right) {
3912
3922
  if (isAlnum(left) && isAlnum(right)) return true;
3913
3923
  if (isLetter(left) && (right === NONE || SPACELIKE.has(right) || CLOSEISH.has(right)))
3914
3924
  return true;
3925
+ if (isLetter(left) && OPENQUOTE.has(right)) return true;
3915
3926
  if ((left === NONE || SPACELIKE.has(left) || OPENISH.has(left)) && isAlnum(right)) return true;
3916
3927
  return false;
3917
3928
  }
@@ -4469,7 +4480,7 @@ function isOpenish(prep, cp) {
4469
4480
  return contains(prep.opens, cp);
4470
4481
  }
4471
4482
  function isCloseish(prep, cp) {
4472
- return contains(prep.closes, cp);
4483
+ return cp === MARKER || contains(prep.closes, cp);
4473
4484
  }
4474
4485
  function isMark(prep, cp) {
4475
4486
  return contains(prep.beforePunctuation, cp) || contains(prep.narrowBeforePunctuation, cp);
@@ -5247,7 +5258,9 @@ function isEmptyBracketGuarded(left, right) {
5247
5258
  }
5248
5259
  function isLoneDot(cp, e) {
5249
5260
  if (at7(cp, e) !== FULL_STOP4) return true;
5250
- return !isDotlike2(at7(cp, e + 1));
5261
+ const next = at7(cp, e + 1);
5262
+ if (isLetter(next) || isDigitAscii(next)) return false;
5263
+ return !isDotlike2(next);
5251
5264
  }
5252
5265
  function isDigitAscii(cp) {
5253
5266
  return cp >= DIGIT_ZERO7 && cp <= DIGIT_NINE6;
@@ -5617,4 +5630,4 @@ function runRules(cp, planned, locale, mode) {
5617
5630
 
5618
5631
 
5619
5632
  exports.PolytypoError = PolytypoError; exports.toCodePoints = toCodePoints; exports.fromCodePoints = fromCodePoints; exports.getLocaleData = getLocaleData; exports.MARKER = MARKER; exports.LINE_MARKER = LINE_MARKER; exports.isMarker = isMarker; exports.RULES = RULES; exports.applyEdits = applyEdits; exports.planRules = planRules; exports.runRules = runRules;
5620
- //# sourceMappingURL=chunk-ADRRRKLB.cjs.map
5633
+ //# sourceMappingURL=chunk-B4O4R6HI.cjs.map