polytypo 1.0.2 → 1.1.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 (36) hide show
  1. package/dist/{chunk-47XAYIKV.js → chunk-3XRMEZDM.js} +168 -183
  2. package/dist/{chunk-47XAYIKV.js.map → chunk-3XRMEZDM.js.map} +1 -1
  3. package/dist/{chunk-MMU4UU46.js → chunk-4FZZJB7Y.js} +2 -2
  4. package/dist/{chunk-M2UGLSIB.cjs → chunk-5BVKKURT.cjs} +11 -11
  5. package/dist/{chunk-M2UGLSIB.cjs.map → chunk-5BVKKURT.cjs.map} +1 -1
  6. package/dist/chunk-A4HNRHBV.cjs +19 -0
  7. package/dist/{chunk-DZ72ITYV.cjs.map → chunk-A4HNRHBV.cjs.map} +1 -1
  8. package/dist/{chunk-MOVY7OL2.cjs → chunk-ADRRRKLB.cjs} +168 -183
  9. package/dist/chunk-ADRRRKLB.cjs.map +1 -0
  10. package/dist/{chunk-7IZAODBB.cjs → chunk-CZRTSOOB.cjs} +3 -3
  11. package/dist/{chunk-7IZAODBB.cjs.map → chunk-CZRTSOOB.cjs.map} +1 -1
  12. package/dist/{chunk-UKWVAQMR.js → chunk-EWZWHW3B.js} +3 -3
  13. package/dist/{chunk-7L4ECXDJ.js → chunk-ILWDO7FZ.js} +2 -2
  14. package/dist/chunk-IS7WKMGA.cjs +21 -0
  15. package/dist/{chunk-F3BDCZSG.cjs.map → chunk-IS7WKMGA.cjs.map} +1 -1
  16. package/dist/{chunk-YS3FXB5V.cjs → chunk-RNFW7474.cjs} +14 -14
  17. package/dist/{chunk-YS3FXB5V.cjs.map → chunk-RNFW7474.cjs.map} +1 -1
  18. package/dist/{chunk-HZPDGNOO.js → chunk-X2B4LIW3.js} +3 -3
  19. package/dist/{chunk-E63PQ3N7.js → chunk-ZBLCAVSM.js} +2 -2
  20. package/dist/html.cjs +7 -7
  21. package/dist/html.js +4 -4
  22. package/dist/index.cjs +10 -10
  23. package/dist/index.js +5 -5
  24. package/dist/markdown.cjs +7 -7
  25. package/dist/markdown.js +4 -4
  26. package/dist/text.cjs +6 -6
  27. package/dist/text.js +3 -3
  28. package/package.json +1 -1
  29. package/dist/chunk-DZ72ITYV.cjs +0 -19
  30. package/dist/chunk-F3BDCZSG.cjs +0 -21
  31. package/dist/chunk-MOVY7OL2.cjs.map +0 -1
  32. /package/dist/{chunk-MMU4UU46.js.map → chunk-4FZZJB7Y.js.map} +0 -0
  33. /package/dist/{chunk-UKWVAQMR.js.map → chunk-EWZWHW3B.js.map} +0 -0
  34. /package/dist/{chunk-7L4ECXDJ.js.map → chunk-ILWDO7FZ.js.map} +0 -0
  35. /package/dist/{chunk-HZPDGNOO.js.map → chunk-X2B4LIW3.js.map} +0 -0
  36. /package/dist/{chunk-E63PQ3N7.js.map → chunk-ZBLCAVSM.js.map} +0 -0
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkMOVY7OL2cjs = require('./chunk-MOVY7OL2.cjs');
3
+ var _chunkADRRRKLBcjs = require('./chunk-ADRRRKLB.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, _chunkMOVY7OL2cjs.PolytypoError)(
8
+ throw new (0, _chunkADRRRKLBcjs.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-7IZAODBB.cjs.map
17
+ //# sourceMappingURL=chunk-CZRTSOOB.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-7IZAODBB.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-7IZAODBB.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
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-CZRTSOOB.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-CZRTSOOB.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,11 +1,11 @@
1
1
  import {
2
2
  htmlSpans,
3
3
  runOverSpans
4
- } from "./chunk-E63PQ3N7.js";
4
+ } from "./chunk-ZBLCAVSM.js";
5
5
  import {
6
6
  getLocaleData,
7
7
  planRules
8
- } from "./chunk-47XAYIKV.js";
8
+ } from "./chunk-3XRMEZDM.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-EWZWHW3B.js.map
@@ -4,7 +4,7 @@ import {
4
4
  planRules,
5
5
  runRules,
6
6
  toCodePoints
7
- } from "./chunk-47XAYIKV.js";
7
+ } from "./chunk-3XRMEZDM.js";
8
8
 
9
9
  // src/engine/text-pipeline.ts
10
10
  function runTextPipeline(input, options) {
@@ -16,4 +16,4 @@ function runTextPipeline(input, options) {
16
16
  export {
17
17
  runTextPipeline
18
18
  };
19
- //# sourceMappingURL=chunk-7L4ECXDJ.js.map
19
+ //# sourceMappingURL=chunk-ILWDO7FZ.js.map
@@ -0,0 +1,21 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkRNFW7474cjs = require('./chunk-RNFW7474.cjs');
5
+
6
+
7
+
8
+ var _chunkADRRRKLBcjs = require('./chunk-ADRRRKLB.cjs');
9
+
10
+ // src/engine/html-pipeline.ts
11
+ function runHtmlPipeline(input, options) {
12
+ const planned = _chunkADRRRKLBcjs.planRules.call(void 0, options.rules);
13
+ const locale = _chunkADRRRKLBcjs.getLocaleData.call(void 0, options.locale);
14
+ const spans = _chunkRNFW7474cjs.htmlSpans.call(void 0, input);
15
+ return _chunkRNFW7474cjs.runOverSpans.call(void 0, input, spans, planned, locale, "html");
16
+ }
17
+
18
+
19
+
20
+ exports.runHtmlPipeline = runHtmlPipeline;
21
+ //# sourceMappingURL=chunk-IS7WKMGA.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-F3BDCZSG.cjs","../src/engine/html-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACMO,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,MAAM,MAAA,EAAQ,yCAAA,KAAe,CAAA;AAC7B,EAAA,OAAO,4CAAA,KAAa,EAAO,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,MAAM,CAAA;AAC3D;ADJA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-F3BDCZSG.cjs","sourcesContent":[null,"import { htmlSpans } from \"../modes/html.js\";\nimport type { Options } from \"../types.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { planRules } from \"./rule-runner.js\";\nimport { runOverSpans } from \"./span-runner.js\";\n\n/**\n * `html` mode only. Imports `parse5` (via `../modes/html.js`) and nothing from\n * `../modes/markdown.js` or the Micromark/MDX stack — this is what makes `polytypo/html`'s\n * module graph exclude the Markdown parser (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1).\n *\n * Validation order — `planRules` before `getLocaleData` before parsing — mirrors the pre-Stage-5\n * aggregate `runPipeline` exactly (an unknown-rule error must win over an unknown-locale error,\n * and both must win over a parse failure, since that is public, tested behaviour).\n */\nexport function runHtmlPipeline(input: string, options: Partial<Options>): string {\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const spans = htmlSpans(input);\n return runOverSpans(input, spans, planned, locale, \"html\");\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-IS7WKMGA.cjs","../src/engine/html-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACMO,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,MAAM,MAAA,EAAQ,yCAAA,KAAe,CAAA;AAC7B,EAAA,OAAO,4CAAA,KAAa,EAAO,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,MAAM,CAAA;AAC3D;ADJA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-IS7WKMGA.cjs","sourcesContent":[null,"import { htmlSpans } from \"../modes/html.js\";\nimport type { Options } from \"../types.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { planRules } from \"./rule-runner.js\";\nimport { runOverSpans } from \"./span-runner.js\";\n\n/**\n * `html` mode only. Imports `parse5` (via `../modes/html.js`) and nothing from\n * `../modes/markdown.js` or the Micromark/MDX stack — this is what makes `polytypo/html`'s\n * module graph exclude the Markdown parser (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1).\n *\n * Validation order — `planRules` before `getLocaleData` before parsing — mirrors the pre-Stage-5\n * aggregate `runPipeline` exactly (an unknown-rule error must win over an unknown-locale error,\n * and both must win over a parse failure, since that is public, tested behaviour).\n */\nexport function runHtmlPipeline(input: string, options: Partial<Options>): string {\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const spans = htmlSpans(input);\n return runOverSpans(input, spans, planned, locale, \"html\");\n}\n"]}
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkMOVY7OL2cjs = require('./chunk-MOVY7OL2.cjs');
10
+ var _chunkADRRRKLBcjs = require('./chunk-ADRRRKLB.cjs');
11
11
 
12
12
  // src/modes/html.ts
13
13
  var _parse5 = require('parse5');
@@ -27,8 +27,8 @@ function wrapParserErrors(what, run) {
27
27
  try {
28
28
  return run();
29
29
  } catch (error) {
30
- if (error instanceof _chunkMOVY7OL2cjs.PolytypoError) throw error;
31
- throw new (0, _chunkMOVY7OL2cjs.PolytypoError)(
30
+ if (error instanceof _chunkADRRRKLBcjs.PolytypoError) throw error;
31
+ throw new (0, _chunkADRRRKLBcjs.PolytypoError)(
32
32
  "POLYTYPO_MALFORMED_INPUT",
33
33
  `Input does not parse as ${what}: ${describe(error)}`
34
34
  );
@@ -171,7 +171,7 @@ function normalizeSpans(spans) {
171
171
  continue;
172
172
  }
173
173
  if (span.start < last.end) {
174
- throw new (0, _chunkMOVY7OL2cjs.PolytypoError)(
174
+ throw new (0, _chunkADRRRKLBcjs.PolytypoError)(
175
175
  "POLYTYPO_RULE_CONTRACT",
176
176
  `mode extractor produced overlapping spans (${last.start}, ${last.end}) and (${span.start}, ${span.end})`
177
177
  );
@@ -189,9 +189,9 @@ function concatenateSpans(source, spans) {
189
189
  let previous;
190
190
  for (const span of spans) {
191
191
  if (previous !== void 0) {
192
- cp.push(gapIsLineBoundary(source, previous.end, span.start) ? _chunkMOVY7OL2cjs.LINE_MARKER : _chunkMOVY7OL2cjs.MARKER);
192
+ cp.push(gapIsLineBoundary(source, previous.end, span.start) ? _chunkADRRRKLBcjs.LINE_MARKER : _chunkADRRRKLBcjs.MARKER);
193
193
  }
194
- for (const value of _chunkMOVY7OL2cjs.toCodePoints.call(void 0, source.slice(span.start, span.end))) cp.push(value);
194
+ for (const value of _chunkADRRRKLBcjs.toCodePoints.call(void 0, source.slice(span.start, span.end))) cp.push(value);
195
195
  previous = span;
196
196
  }
197
197
  return cp;
@@ -200,7 +200,7 @@ function spanRangesOf(cp) {
200
200
  const ranges = [];
201
201
  let first = 0;
202
202
  for (let i = 0; i < cp.length; i += 1) {
203
- if (_chunkMOVY7OL2cjs.isMarker.call(void 0, cp[i])) {
203
+ if (_chunkADRRRKLBcjs.isMarker.call(void 0, cp[i])) {
204
204
  ranges.push({ first, last: i - 1 });
205
205
  first = i + 1;
206
206
  }
@@ -219,7 +219,7 @@ function filterBoundaryEdits(cp, edits, ranges) {
219
219
  for (const edit of edits) {
220
220
  let containsMarker = false;
221
221
  for (let i = edit.start; i < edit.end; i += 1) {
222
- if (_chunkMOVY7OL2cjs.isMarker.call(void 0, cp[i])) {
222
+ if (_chunkADRRRKLBcjs.isMarker.call(void 0, cp[i])) {
223
223
  containsMarker = true;
224
224
  break;
225
225
  }
@@ -238,14 +238,14 @@ function filterBoundaryEdits(cp, edits, ranges) {
238
238
  function splitOnMarker(cp, expected) {
239
239
  const pieces = [[]];
240
240
  for (const value of cp) {
241
- if (_chunkMOVY7OL2cjs.isMarker.call(void 0, value)) {
241
+ if (_chunkADRRRKLBcjs.isMarker.call(void 0, value)) {
242
242
  pieces.push([]);
243
243
  continue;
244
244
  }
245
245
  pieces[pieces.length - 1].push(value);
246
246
  }
247
247
  if (pieces.length !== expected) {
248
- throw new (0, _chunkMOVY7OL2cjs.PolytypoError)(
248
+ throw new (0, _chunkADRRRKLBcjs.PolytypoError)(
249
249
  "POLYTYPO_RULE_CONTRACT",
250
250
  `boundary markers did not survive the pipeline: expected ${expected} spans, found ${pieces.length}`
251
251
  );
@@ -257,10 +257,10 @@ function splitOnMarker(cp, expected) {
257
257
  function runRulesOverSpans(cp, planned, locale, mode) {
258
258
  let current = cp;
259
259
  for (const id of planned) {
260
- const rule = _chunkMOVY7OL2cjs.RULES[id];
260
+ const rule = _chunkADRRRKLBcjs.RULES[id];
261
261
  if (rule === void 0) continue;
262
262
  const edits = rule.apply({ cp: current, locale, mode });
263
- current = _chunkMOVY7OL2cjs.applyEdits.call(void 0, current, filterBoundaryEdits(current, edits, spanRangesOf(current)), id);
263
+ current = _chunkADRRRKLBcjs.applyEdits.call(void 0, current, filterBoundaryEdits(current, edits, spanRangesOf(current)), id);
264
264
  }
265
265
  return current;
266
266
  }
@@ -278,7 +278,7 @@ function runOverSpans(source, spans, planned, locale, mode) {
278
278
  let cursor = 0;
279
279
  for (let i = 0; i < normalized.length; i += 1) {
280
280
  const span = normalized[i];
281
- const replacement = _chunkMOVY7OL2cjs.fromCodePoints.call(void 0, pieces[i]);
281
+ const replacement = _chunkADRRRKLBcjs.fromCodePoints.call(void 0, pieces[i]);
282
282
  const original = source.slice(span.start, span.end);
283
283
  out += source.slice(cursor, span.start);
284
284
  out += replacement === original ? original : replacement;
@@ -294,4 +294,4 @@ function runOverSpans(source, spans, planned, locale, mode) {
294
294
 
295
295
 
296
296
  exports.wrapParserErrors = wrapParserErrors; exports.isSkippedElement = isSkippedElement; exports.htmlSpans = htmlSpans; exports.htmlFragmentSpans = htmlFragmentSpans; exports.runOverSpans = runOverSpans;
297
- //# sourceMappingURL=chunk-YS3FXB5V.cjs.map
297
+ //# sourceMappingURL=chunk-RNFW7474.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-YS3FXB5V.cjs","../src/modes/html.ts","../src/modes/parse-error.ts","../src/modes/spans.ts","../src/engine/span-runner.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACXA,gCAAqC;ADarC;AACA;AEPA,SAAS,QAAA,CAAS,KAAA,EAAwB;AACxC,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,SAAA,GAAY,MAAA,IAAU,IAAA,EAAM,OAAO,MAAA,CAAO,KAAK,CAAA;AACpE,EAAA,MAAM,WAAA,EAAa,KAAA;AACnB,EAAA,MAAM,OAAA,EACJ,OAAO,UAAA,CAAW,OAAA,IAAW,SAAA,EAAW,UAAA,CAAW,OAAA,EAAU,KAAA,CAAgB,OAAA;AAC/E,EAAA,MAAM,MAAA,EAAQ,UAAA,CAAW,KAAA;AACzB,EAAA,GAAA,CACE,MAAA,IAAU,KAAA,GACV,MAAA,IAAU,KAAA,EAAA,GACV,OAAO,KAAA,CAAM,KAAA,IAAS,SAAA,GACtB,OAAO,KAAA,CAAM,OAAA,IAAW,QAAA,EACxB;AACA,IAAA,OAAO,CAAA,EAAA;AACT,EAAA;AACO,EAAA;AACT;AAcgB;AACV,EAAA;AACK,IAAA;AACA,EAAA;AACH,IAAA;AACE,IAAA;AACJ,MAAA;AACA,MAAA;AACF,IAAA;AACF,EAAA;AACF;AFVY;AACA;ACtBN;AACJ,EAAA;AACA,EAAA;AACA,EAA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;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-YS3FXB5V.cjs","sourcesContent":[null,"import { parse, parseFragment } from \"parse5\";\nimport type { DefaultTreeAdapterMap } from \"parse5\";\nimport { wrapParserErrors } from \"./parse-error.js\";\nimport type { Span } from \"./spans.js\";\n\ntype Node = DefaultTreeAdapterMap[\"node\"];\ntype ParentNode = DefaultTreeAdapterMap[\"parentNode\"];\n\n/**\n * spec/rules/modes.md 3.6, exhaustive and **closed**: extending it is a spec change, not an\n * implementation decision. `svg` and `math` are here because in MathML a quotation mark, a\n * hyphen and a prime are operators and identifiers — substituting a curly glyph changes what\n * the expression means. Everything not listed is processable, **including unknown and custom\n * elements**: guessing from a tag name is exactly the heuristic that diverges across runtimes.\n */\nconst SKIPPED_ELEMENTS: ReadonlySet<string> = new Set([\n \"code\",\n \"pre\",\n \"kbd\",\n \"samp\",\n \"var\",\n \"script\",\n \"style\",\n \"textarea\",\n \"svg\",\n \"math\",\n]);\n\nexport function isSkippedElement(tagName: string): boolean {\n return SKIPPED_ELEMENTS.has(tagName);\n}\n\nconst AMPERSAND = 0x26;\nconst SEMICOLON = 0x3b;\nconst HASH = 0x23;\nconst LOWER_X = 0x78;\nconst UPPER_X = 0x58;\n\n/** Longest named reference in the WHATWG table is 32 characters; the guard is a bound, not a rule. */\nconst MAX_REFERENCE_BODY = 34;\n\nfunction isAsciiDigit(unit: number): boolean {\n return unit >= 0x30 && unit <= 0x39;\n}\n\nfunction isAsciiHexDigit(unit: number): boolean {\n return isAsciiDigit(unit) || (unit >= 0x61 && unit <= 0x66) || (unit >= 0x41 && unit <= 0x46);\n}\n\nfunction isAsciiAlphanumeric(unit: number): boolean {\n return isAsciiDigit(unit) || (unit >= 0x61 && unit <= 0x7a) || (unit >= 0x41 && unit <= 0x5a);\n}\n\n/**\n * The end offset of a well-formed character reference starting at `at`, or -1. A bare `&` that a\n * parser would repair is deliberately **not** treated as a reference: it stays inside the span,\n * where no rule can emit or delete it, rather than manufacturing a boundary that suppresses\n * conversions around it.\n */\nfunction characterReferenceEnd(source: string, at: number, limit: number): number {\n if (source.charCodeAt(at) !== AMPERSAND) return -1;\n let i = at + 1;\n if (i >= limit) return -1;\n\n if (source.charCodeAt(i) === HASH) {\n i += 1;\n const unit = i < limit ? source.charCodeAt(i) : -1;\n const hex = unit === LOWER_X || unit === UPPER_X;\n if (hex) i += 1;\n const digitsAt = i;\n while (\n i < limit &&\n (hex ? isAsciiHexDigit(source.charCodeAt(i)) : isAsciiDigit(source.charCodeAt(i)))\n ) {\n i += 1;\n }\n if (i === digitsAt) return -1;\n return i < limit && source.charCodeAt(i) === SEMICOLON ? i + 1 : -1;\n }\n\n const nameAt = i;\n while (\n i < limit &&\n i - nameAt < MAX_REFERENCE_BODY &&\n isAsciiAlphanumeric(source.charCodeAt(i))\n ) {\n i += 1;\n }\n if (i === nameAt) return -1;\n return i < limit && source.charCodeAt(i) === SEMICOLON ? i + 1 : -1;\n}\n\n/**\n * modes.md 3.6: every character reference is skipped as an **opaque unit**, and a text node\n * containing one is split into spans around it. That is the only way `&nbsp;` survives as\n * `&nbsp;` instead of becoming a literal U+00A0 on the way out.\n */\nexport function splitCharacterReferences(source: string, start: number, end: number): Span[] {\n const spans: Span[] = [];\n let cursor = start;\n let i = start;\n while (i < end) {\n if (source.charCodeAt(i) === AMPERSAND) {\n const stop = characterReferenceEnd(source, i, end);\n if (stop > 0) {\n if (i > cursor) spans.push({ start: cursor, end: i });\n cursor = stop;\n i = stop;\n continue;\n }\n }\n i += 1;\n }\n if (end > cursor) spans.push({ start: cursor, end });\n return spans;\n}\n\nfunction isParent(node: Node): node is ParentNode {\n return \"childNodes\" in node;\n}\n\nfunction collect(node: Node, source: string, spans: Span[]): void {\n if (node.nodeName === \"#text\") {\n const location = node.sourceCodeLocation;\n if (location === undefined || location === null) return;\n for (const span of splitCharacterReferences(source, location.startOffset, location.endOffset)) {\n spans.push(span);\n }\n return;\n }\n\n // Comments, doctype and processing instructions never contribute a span (modes.md 3.6).\n if (node.nodeName === \"#comment\" || node.nodeName === \"#documentType\") return;\n\n if (\"tagName\" in node && isSkippedElement(node.tagName)) return;\n\n // A `template`'s children live in a separate document fragment; `template` is not skipped.\n if (node.nodeName === \"template\" && \"content\" in node) {\n collect(node.content, source, spans);\n return;\n }\n\n if (!isParent(node)) return;\n for (const child of node.childNodes) collect(child, source, spans);\n}\n\n/**\n * Locate the processable spans of an HTML document. The tree is used only to find offsets and is\n * then discarded — modes.md 4 forbids reserialisation, which is what makes attribute quoting,\n * self-closing forms, entity spelling, tag case and malformed-input recovery preserved by\n * construction rather than by effort.\n */\nexport function htmlSpans(source: string): Span[] {\n const document = wrapParserErrors(\"HTML\", () => parse(source, { sourceCodeLocationInfo: true }));\n const spans: Span[] = [];\n collect(document, source, spans);\n return spans;\n}\n\n/** The same, for a fragment: used for HTML blocks embedded in markdown (modes.md 3.7). */\nexport function htmlFragmentSpans(source: string, offset: number): Span[] {\n const fragment = wrapParserErrors(\"HTML\", () =>\n parseFragment(source, { sourceCodeLocationInfo: true }),\n );\n const spans: Span[] = [];\n collect(fragment, source, spans);\n return offset === 0\n ? spans\n : spans.map((span) => ({ start: span.start + offset, end: span.end + offset }));\n}\n","import { PolytypoError } from \"../errors.js\";\n\ninterface PositionedError {\n readonly reason?: unknown;\n readonly place?: { readonly line?: unknown; readonly column?: unknown } | null;\n}\n\nfunction describe(error: unknown): string {\n if (typeof error !== \"object\" || error === null) return String(error);\n const positioned = error as PositionedError;\n const reason =\n typeof positioned.reason === \"string\" ? positioned.reason : (error as Error).message;\n const place = positioned.place;\n if (\n place !== null &&\n place !== undefined &&\n typeof place.line === \"number\" &&\n typeof place.column === \"number\"\n ) {\n return `${reason} (line ${place.line}, column ${place.column})`;\n }\n return reason;\n}\n\n/**\n * spec/rules/modes.md 3.7.2. **The parser's own error type must never escape.** A\n * `VFileMessage`, a `Nokogiri::SyntaxError` or a Python exception on the public surface puts a\n * dependency's type into the contract and is unreproducible in the other four runtimes; only the\n * code is contractual (ARCHITECTURE.md 4.6), while the message and the source position are\n * useful and are not.\n *\n * Reachable in exactly one place: `dialect: \"mdx\"`, because MDX embeds JavaScript. HTML parsing\n * is specified with total error recovery and every byte sequence is valid CommonMark, so neither\n * of the other two languages can fail. The wrapper is applied to all of them anyway — the\n * guarantee is that no parser type escapes, not that this particular parser is trusted.\n */\nexport function wrapParserErrors<T>(what: string, run: () => T): T {\n try {\n return run();\n } catch (error) {\n if (error instanceof PolytypoError) throw error;\n throw new PolytypoError(\n \"POLYTYPO_MALFORMED_INPUT\",\n `Input does not parse as ${what}: ${describe(error)}`,\n );\n }\n}\n","import { toCodePoints } from \"../engine/codepoints.js\";\nimport { isMarker, LINE_MARKER, MARKER } from \"../engine/sentinels.js\";\nimport { PolytypoError } from \"../errors.js\";\nimport type { Edit } from \"../types.js\";\n\n/**\n * The boundary markers are defined in the engine (src/engine/sentinels.ts), which is where all\n * three non-code-point sentinels live and where their disjointness is maintained. They are\n * re-exported here because the mode layer is what writes them into the array.\n *\n * Which marker separates two spans is decided by the **raw source bytes of the gap between\n * them**, so it is decidable without asking the parser anything and is identical in five\n * runtimes: a gap containing a line terminator gives `LINE_MARKER`, anything else `MARKER`.\n */\nexport { LINE_MARKER, MARKER, isMarker } from \"../engine/sentinels.js\";\n\n/** `BREAK` as the rules define it (`spaces.md` 3.1), tested against the gap's raw source. */\nconst LINE_TERMINATORS: ReadonlySet<number> = new Set([\n 0x0a, 0x0d, 0x0b, 0x0c, 0x85, 0x2028, 0x2029,\n]);\n\nfunction gapIsLineBoundary(source: string, from: number, to: number): boolean {\n for (let i = from; i < to; i += 1) {\n if (LINE_TERMINATORS.has(source.charCodeAt(i))) return true;\n }\n return false;\n}\n\n/**\n * A processable span, identified by its offsets in the **original source**. Offsets are UTF-16\n * indices into the JS source string, which is what every JS parser reports; they are an\n * implementation detail of this runtime and never reach the rules, which index code points.\n */\nexport interface Span {\n readonly start: number;\n readonly end: number;\n}\n\n/** A span's extent in the concatenated code-point array: `s₀` and `s₁` of modes.md 3.4. */\nexport interface SpanRange {\n readonly first: number;\n readonly last: number;\n}\n\n/**\n * Sort, drop empties, and coalesce spans separated by nothing in the source (modes.md 7.5:\n * a parser that reports one text run as two adjacent nodes must not manufacture a boundary).\n * Overlapping spans are an extractor bug and are rejected rather than silently merged.\n */\nexport function normalizeSpans(spans: readonly Span[]): Span[] {\n const sorted = spans.filter((s) => s.end > s.start).sort((a, b) => a.start - b.start);\n const out: Span[] = [];\n for (const span of sorted) {\n const last = out[out.length - 1];\n if (last === undefined) {\n out.push(span);\n continue;\n }\n if (span.start < last.end) {\n throw new PolytypoError(\n \"POLYTYPO_RULE_CONTRACT\",\n `mode extractor produced overlapping spans (${last.start}, ${last.end}) and (${span.start}, ${span.end})`,\n );\n }\n if (span.start === last.end) {\n out[out.length - 1] = { start: last.start, end: span.end };\n continue;\n }\n out.push(span);\n }\n return out;\n}\n\n/** `S₁ ⌢ [marker] ⌢ S₂ ⌢ … ⌢ Sₘ` (modes.md 3.5 step 2). */\nexport function concatenateSpans(source: string, spans: readonly Span[]): number[] {\n const cp: number[] = [];\n let previous: Span | undefined;\n for (const span of spans) {\n if (previous !== undefined) {\n cp.push(gapIsLineBoundary(source, previous.end, span.start) ? LINE_MARKER : MARKER);\n }\n for (const value of toCodePoints(source.slice(span.start, span.end))) cp.push(value);\n previous = span;\n }\n return cp;\n}\n\n/**\n * The span extents of the array as it stands. Recomputed after every rule, because applying\n * edits shifts every index after the first one — the markers themselves are guaranteed to\n * survive, since no edit may contain one.\n */\nexport function spanRangesOf(cp: readonly number[]): SpanRange[] {\n const ranges: SpanRange[] = [];\n let first = 0;\n for (let i = 0; i < cp.length; i += 1) {\n if (isMarker(cp[i] as number)) {\n ranges.push({ first, last: i - 1 });\n first = i + 1;\n }\n }\n ranges.push({ first, last: cp.length - 1 });\n return ranges;\n}\n\nfunction spanContaining(ranges: readonly SpanRange[], p: number): SpanRange | undefined {\n for (const range of ranges) {\n if (p >= range.first && p <= range.last + 1) return range;\n }\n return undefined;\n}\n\n/**\n * modes.md 3.4, two safety nets, both pure functions of `(p, q, r, s₀, s₁)` — so the verdict is\n * identical on every run, which is what makes redistribution deterministic (modes.md 5, point 3).\n *\n * 1. **No edit may contain a marker.** No rule can produce one; one that does is a bug, and the\n * edit is discarded rather than treated as a redistribution question.\n * 2. **The edge-growth rule.** An edit is discarded if it would place code points at an\n * extremity of its span that were not there before: with `d = q - p + 1` the replaced length\n * and `r` the replacement length, discard when `p = s₀ and r > d`, or `q = s₁ and r > d`.\n *\n * The length test is the whole rule and needs no knowledge of Markdown or HTML syntax. It\n * separates exactly the cases that matter: `\"` → `“` at an edge is 1 → 1 and applies; `--` →\n * `␣–␣` at an edge is 2 → 3 and is discarded, while the same edit interior to a span applies;\n * `(c)` → `©` is 3 → 1 and applies, because shrinking is always safe. An insertion has `d = 0`,\n * so it is discarded exactly when its position coincides with a span edge — the rule this one\n * generalises.\n *\n * **Deletion at an edge is not restricted here**, and must not be: `r > d` is false for a\n * deletion, so this filter never sees one. Deletion at an edge is governed by modes.md 3.3's\n * *Edge tests* clause instead — where a rule asks \"am I at the edge of the text I am allowed to\n * modify\" rather than \"what character is here\", the marker behaves as `NONE`. That clause is the\n * one place a rule may treat a span edge as the end of the text, it exists because `spaces` is\n * the only rule that deletes, and 3.3 states the division: **a rule that deletes must treat a\n * span edge as the end of the text; a rule that replaces or inserts must not, and is governed by\n * this filter.** The single test that claims the clause is `spaces.md` 3.2 step 4.\n */\nexport function filterBoundaryEdits(\n cp: readonly number[],\n edits: readonly Edit[],\n ranges: readonly SpanRange[],\n): Edit[] {\n const out: Edit[] = [];\n for (const edit of edits) {\n let containsMarker = false;\n for (let i = edit.start; i < edit.end; i += 1) {\n if (isMarker(cp[i] as number)) {\n containsMarker = true;\n break;\n }\n }\n if (containsMarker) continue;\n\n // `[start, end)` in the engine's half-open form is `cp[p … q]` with p = start, q = end - 1;\n // an insertion is `q = p - 1`, which falls out of the same expression.\n const p = edit.start;\n const q = edit.end - 1;\n const d = edit.end - edit.start;\n const r = edit.replacement.length;\n const span = spanContaining(ranges, p);\n if (span !== undefined && r > d && (p === span.first || q === span.last)) continue;\n\n out.push(edit);\n }\n return out;\n}\n\n/** Redistribute the transformed array back to one piece per span (modes.md 3.5 step 4). */\nexport function splitOnMarker(cp: readonly number[], expected: number): number[][] {\n const pieces: number[][] = [[]];\n for (const value of cp) {\n if (isMarker(value)) {\n pieces.push([]);\n continue;\n }\n (pieces[pieces.length - 1] as number[]).push(value);\n }\n if (pieces.length !== expected) {\n throw new PolytypoError(\n \"POLYTYPO_RULE_CONTRACT\",\n `boundary markers did not survive the pipeline: expected ${expected} spans, found ${pieces.length}`,\n );\n }\n return pieces;\n}\n","import {\n concatenateSpans,\n filterBoundaryEdits,\n normalizeSpans,\n spanRangesOf,\n splitOnMarker,\n type Span,\n} from \"../modes/spans.js\";\nimport { RULES } from \"../rules/registry.js\";\nimport type { LocaleData, Mode, RuleId } from \"../types.js\";\nimport { applyEdits } from \"./edits.js\";\nimport { fromCodePoints } from \"./codepoints.js\";\n\n/**\n * The same sequence as `runRules` (`./rule-runner.js`), with the two boundary filters of\n * modes.md 3.4 interposed. The span extents are recomputed after every rule, because applying\n * an edit shifts every index after it; the markers themselves always survive, since no edit may\n * contain one.\n */\nfunction runRulesOverSpans(\n cp: readonly number[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n): readonly number[] {\n let current = cp;\n for (const id of planned) {\n const rule = RULES[id];\n if (rule === undefined) continue;\n const edits = rule.apply({ cp: current, locale, mode });\n current = applyEdits(current, filterBoundaryEdits(current, edits, spanRangesOf(current)), id);\n }\n return current;\n}\n\n/**\n * modes.md 3.5. The pipeline runs **once**, over the marker-separated concatenation of every\n * processable span — not per span, which would pair quotation marks in isolation, and not over a\n * naive concatenation, which would manufacture adjacencies the document does not have.\n *\n * The output is the input with a set of disjoint substring replacements applied and nothing else\n * (modes.md 4). A span whose content the rules did not change contributes no replacement, so a\n * document needing no changes comes back byte-identical; the parser located the spans and was\n * then discarded, and the document is never serialised.\n */\nexport function runOverSpans(\n source: string,\n spans: readonly Span[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n): string {\n const normalized = normalizeSpans(spans);\n if (normalized.length === 0) return source;\n\n const transformed = runRulesOverSpans(\n concatenateSpans(source, normalized),\n planned,\n locale,\n mode,\n );\n const pieces = splitOnMarker(transformed, normalized.length);\n\n let out = \"\";\n let cursor = 0;\n for (let i = 0; i < normalized.length; i += 1) {\n const span = normalized[i] as Span;\n const replacement = fromCodePoints(pieces[i] as number[]);\n const original = source.slice(span.start, span.end);\n out += source.slice(cursor, span.start);\n out += replacement === original ? original : replacement;\n cursor = span.end;\n }\n return out + source.slice(cursor);\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-RNFW7474.cjs","../src/modes/html.ts","../src/modes/parse-error.ts","../src/modes/spans.ts","../src/engine/span-runner.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACXA,gCAAqC;ADarC;AACA;AEPA,SAAS,QAAA,CAAS,KAAA,EAAwB;AACxC,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,SAAA,GAAY,MAAA,IAAU,IAAA,EAAM,OAAO,MAAA,CAAO,KAAK,CAAA;AACpE,EAAA,MAAM,WAAA,EAAa,KAAA;AACnB,EAAA,MAAM,OAAA,EACJ,OAAO,UAAA,CAAW,OAAA,IAAW,SAAA,EAAW,UAAA,CAAW,OAAA,EAAU,KAAA,CAAgB,OAAA;AAC/E,EAAA,MAAM,MAAA,EAAQ,UAAA,CAAW,KAAA;AACzB,EAAA,GAAA,CACE,MAAA,IAAU,KAAA,GACV,MAAA,IAAU,KAAA,EAAA,GACV,OAAO,KAAA,CAAM,KAAA,IAAS,SAAA,GACtB,OAAO,KAAA,CAAM,OAAA,IAAW,QAAA,EACx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F,EAAA;AAEE,EAAA;AACJ,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACF,EAAA;AACM,EAAA;AAEI,EAAA;AACN,EAAA;AACK,EAAA;AACD,IAAA;AACA,IAAA;AACA,IAAA;AACC,IAAA;AACA,IAAA;AACP,IAAA;AACF,EAAA;AACO,EAAA;AACT;AJsNY;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-RNFW7474.cjs","sourcesContent":[null,"import { parse, parseFragment } from \"parse5\";\nimport type { DefaultTreeAdapterMap } from \"parse5\";\nimport { wrapParserErrors } from \"./parse-error.js\";\nimport type { Span } from \"./spans.js\";\n\ntype Node = DefaultTreeAdapterMap[\"node\"];\ntype ParentNode = DefaultTreeAdapterMap[\"parentNode\"];\n\n/**\n * spec/rules/modes.md 3.6, exhaustive and **closed**: extending it is a spec change, not an\n * implementation decision. `svg` and `math` are here because in MathML a quotation mark, a\n * hyphen and a prime are operators and identifiers — substituting a curly glyph changes what\n * the expression means. Everything not listed is processable, **including unknown and custom\n * elements**: guessing from a tag name is exactly the heuristic that diverges across runtimes.\n */\nconst SKIPPED_ELEMENTS: ReadonlySet<string> = new Set([\n \"code\",\n \"pre\",\n \"kbd\",\n \"samp\",\n \"var\",\n \"script\",\n \"style\",\n \"textarea\",\n \"svg\",\n \"math\",\n]);\n\nexport function isSkippedElement(tagName: string): boolean {\n return SKIPPED_ELEMENTS.has(tagName);\n}\n\nconst AMPERSAND = 0x26;\nconst SEMICOLON = 0x3b;\nconst HASH = 0x23;\nconst LOWER_X = 0x78;\nconst UPPER_X = 0x58;\n\n/** Longest named reference in the WHATWG table is 32 characters; the guard is a bound, not a rule. */\nconst MAX_REFERENCE_BODY = 34;\n\nfunction isAsciiDigit(unit: number): boolean {\n return unit >= 0x30 && unit <= 0x39;\n}\n\nfunction isAsciiHexDigit(unit: number): boolean {\n return isAsciiDigit(unit) || (unit >= 0x61 && unit <= 0x66) || (unit >= 0x41 && unit <= 0x46);\n}\n\nfunction isAsciiAlphanumeric(unit: number): boolean {\n return isAsciiDigit(unit) || (unit >= 0x61 && unit <= 0x7a) || (unit >= 0x41 && unit <= 0x5a);\n}\n\n/**\n * The end offset of a well-formed character reference starting at `at`, or -1. A bare `&` that a\n * parser would repair is deliberately **not** treated as a reference: it stays inside the span,\n * where no rule can emit or delete it, rather than manufacturing a boundary that suppresses\n * conversions around it.\n */\nfunction characterReferenceEnd(source: string, at: number, limit: number): number {\n if (source.charCodeAt(at) !== AMPERSAND) return -1;\n let i = at + 1;\n if (i >= limit) return -1;\n\n if (source.charCodeAt(i) === HASH) {\n i += 1;\n const unit = i < limit ? source.charCodeAt(i) : -1;\n const hex = unit === LOWER_X || unit === UPPER_X;\n if (hex) i += 1;\n const digitsAt = i;\n while (\n i < limit &&\n (hex ? isAsciiHexDigit(source.charCodeAt(i)) : isAsciiDigit(source.charCodeAt(i)))\n ) {\n i += 1;\n }\n if (i === digitsAt) return -1;\n return i < limit && source.charCodeAt(i) === SEMICOLON ? i + 1 : -1;\n }\n\n const nameAt = i;\n while (\n i < limit &&\n i - nameAt < MAX_REFERENCE_BODY &&\n isAsciiAlphanumeric(source.charCodeAt(i))\n ) {\n i += 1;\n }\n if (i === nameAt) return -1;\n return i < limit && source.charCodeAt(i) === SEMICOLON ? i + 1 : -1;\n}\n\n/**\n * modes.md 3.6: every character reference is skipped as an **opaque unit**, and a text node\n * containing one is split into spans around it. That is the only way `&nbsp;` survives as\n * `&nbsp;` instead of becoming a literal U+00A0 on the way out.\n */\nexport function splitCharacterReferences(source: string, start: number, end: number): Span[] {\n const spans: Span[] = [];\n let cursor = start;\n let i = start;\n while (i < end) {\n if (source.charCodeAt(i) === AMPERSAND) {\n const stop = characterReferenceEnd(source, i, end);\n if (stop > 0) {\n if (i > cursor) spans.push({ start: cursor, end: i });\n cursor = stop;\n i = stop;\n continue;\n }\n }\n i += 1;\n }\n if (end > cursor) spans.push({ start: cursor, end });\n return spans;\n}\n\nfunction isParent(node: Node): node is ParentNode {\n return \"childNodes\" in node;\n}\n\nfunction collect(node: Node, source: string, spans: Span[]): void {\n if (node.nodeName === \"#text\") {\n const location = node.sourceCodeLocation;\n if (location === undefined || location === null) return;\n for (const span of splitCharacterReferences(source, location.startOffset, location.endOffset)) {\n spans.push(span);\n }\n return;\n }\n\n // Comments, doctype and processing instructions never contribute a span (modes.md 3.6).\n if (node.nodeName === \"#comment\" || node.nodeName === \"#documentType\") return;\n\n if (\"tagName\" in node && isSkippedElement(node.tagName)) return;\n\n // A `template`'s children live in a separate document fragment; `template` is not skipped.\n if (node.nodeName === \"template\" && \"content\" in node) {\n collect(node.content, source, spans);\n return;\n }\n\n if (!isParent(node)) return;\n for (const child of node.childNodes) collect(child, source, spans);\n}\n\n/**\n * Locate the processable spans of an HTML document. The tree is used only to find offsets and is\n * then discarded — modes.md 4 forbids reserialisation, which is what makes attribute quoting,\n * self-closing forms, entity spelling, tag case and malformed-input recovery preserved by\n * construction rather than by effort.\n */\nexport function htmlSpans(source: string): Span[] {\n const document = wrapParserErrors(\"HTML\", () => parse(source, { sourceCodeLocationInfo: true }));\n const spans: Span[] = [];\n collect(document, source, spans);\n return spans;\n}\n\n/** The same, for a fragment: used for HTML blocks embedded in markdown (modes.md 3.7). */\nexport function htmlFragmentSpans(source: string, offset: number): Span[] {\n const fragment = wrapParserErrors(\"HTML\", () =>\n parseFragment(source, { sourceCodeLocationInfo: true }),\n );\n const spans: Span[] = [];\n collect(fragment, source, spans);\n return offset === 0\n ? spans\n : spans.map((span) => ({ start: span.start + offset, end: span.end + offset }));\n}\n","import { PolytypoError } from \"../errors.js\";\n\ninterface PositionedError {\n readonly reason?: unknown;\n readonly place?: { readonly line?: unknown; readonly column?: unknown } | null;\n}\n\nfunction describe(error: unknown): string {\n if (typeof error !== \"object\" || error === null) return String(error);\n const positioned = error as PositionedError;\n const reason =\n typeof positioned.reason === \"string\" ? positioned.reason : (error as Error).message;\n const place = positioned.place;\n if (\n place !== null &&\n place !== undefined &&\n typeof place.line === \"number\" &&\n typeof place.column === \"number\"\n ) {\n return `${reason} (line ${place.line}, column ${place.column})`;\n }\n return reason;\n}\n\n/**\n * spec/rules/modes.md 3.7.2. **The parser's own error type must never escape.** A\n * `VFileMessage`, a `Nokogiri::SyntaxError` or a Python exception on the public surface puts a\n * dependency's type into the contract and is unreproducible in the other four runtimes; only the\n * code is contractual (ARCHITECTURE.md 4.6), while the message and the source position are\n * useful and are not.\n *\n * Reachable in exactly one place: `dialect: \"mdx\"`, because MDX embeds JavaScript. HTML parsing\n * is specified with total error recovery and every byte sequence is valid CommonMark, so neither\n * of the other two languages can fail. The wrapper is applied to all of them anyway — the\n * guarantee is that no parser type escapes, not that this particular parser is trusted.\n */\nexport function wrapParserErrors<T>(what: string, run: () => T): T {\n try {\n return run();\n } catch (error) {\n if (error instanceof PolytypoError) throw error;\n throw new PolytypoError(\n \"POLYTYPO_MALFORMED_INPUT\",\n `Input does not parse as ${what}: ${describe(error)}`,\n );\n }\n}\n","import { toCodePoints } from \"../engine/codepoints.js\";\nimport { isMarker, LINE_MARKER, MARKER } from \"../engine/sentinels.js\";\nimport { PolytypoError } from \"../errors.js\";\nimport type { Edit } from \"../types.js\";\n\n/**\n * The boundary markers are defined in the engine (src/engine/sentinels.ts), which is where all\n * three non-code-point sentinels live and where their disjointness is maintained. They are\n * re-exported here because the mode layer is what writes them into the array.\n *\n * Which marker separates two spans is decided by the **raw source bytes of the gap between\n * them**, so it is decidable without asking the parser anything and is identical in five\n * runtimes: a gap containing a line terminator gives `LINE_MARKER`, anything else `MARKER`.\n */\nexport { LINE_MARKER, MARKER, isMarker } from \"../engine/sentinels.js\";\n\n/** `BREAK` as the rules define it (`spaces.md` 3.1), tested against the gap's raw source. */\nconst LINE_TERMINATORS: ReadonlySet<number> = new Set([\n 0x0a, 0x0d, 0x0b, 0x0c, 0x85, 0x2028, 0x2029,\n]);\n\nfunction gapIsLineBoundary(source: string, from: number, to: number): boolean {\n for (let i = from; i < to; i += 1) {\n if (LINE_TERMINATORS.has(source.charCodeAt(i))) return true;\n }\n return false;\n}\n\n/**\n * A processable span, identified by its offsets in the **original source**. Offsets are UTF-16\n * indices into the JS source string, which is what every JS parser reports; they are an\n * implementation detail of this runtime and never reach the rules, which index code points.\n */\nexport interface Span {\n readonly start: number;\n readonly end: number;\n}\n\n/** A span's extent in the concatenated code-point array: `s₀` and `s₁` of modes.md 3.4. */\nexport interface SpanRange {\n readonly first: number;\n readonly last: number;\n}\n\n/**\n * Sort, drop empties, and coalesce spans separated by nothing in the source (modes.md 7.5:\n * a parser that reports one text run as two adjacent nodes must not manufacture a boundary).\n * Overlapping spans are an extractor bug and are rejected rather than silently merged.\n */\nexport function normalizeSpans(spans: readonly Span[]): Span[] {\n const sorted = spans.filter((s) => s.end > s.start).sort((a, b) => a.start - b.start);\n const out: Span[] = [];\n for (const span of sorted) {\n const last = out[out.length - 1];\n if (last === undefined) {\n out.push(span);\n continue;\n }\n if (span.start < last.end) {\n throw new PolytypoError(\n \"POLYTYPO_RULE_CONTRACT\",\n `mode extractor produced overlapping spans (${last.start}, ${last.end}) and (${span.start}, ${span.end})`,\n );\n }\n if (span.start === last.end) {\n out[out.length - 1] = { start: last.start, end: span.end };\n continue;\n }\n out.push(span);\n }\n return out;\n}\n\n/** `S₁ ⌢ [marker] ⌢ S₂ ⌢ … ⌢ Sₘ` (modes.md 3.5 step 2). */\nexport function concatenateSpans(source: string, spans: readonly Span[]): number[] {\n const cp: number[] = [];\n let previous: Span | undefined;\n for (const span of spans) {\n if (previous !== undefined) {\n cp.push(gapIsLineBoundary(source, previous.end, span.start) ? LINE_MARKER : MARKER);\n }\n for (const value of toCodePoints(source.slice(span.start, span.end))) cp.push(value);\n previous = span;\n }\n return cp;\n}\n\n/**\n * The span extents of the array as it stands. Recomputed after every rule, because applying\n * edits shifts every index after the first one — the markers themselves are guaranteed to\n * survive, since no edit may contain one.\n */\nexport function spanRangesOf(cp: readonly number[]): SpanRange[] {\n const ranges: SpanRange[] = [];\n let first = 0;\n for (let i = 0; i < cp.length; i += 1) {\n if (isMarker(cp[i] as number)) {\n ranges.push({ first, last: i - 1 });\n first = i + 1;\n }\n }\n ranges.push({ first, last: cp.length - 1 });\n return ranges;\n}\n\nfunction spanContaining(ranges: readonly SpanRange[], p: number): SpanRange | undefined {\n for (const range of ranges) {\n if (p >= range.first && p <= range.last + 1) return range;\n }\n return undefined;\n}\n\n/**\n * modes.md 3.4, two safety nets, both pure functions of `(p, q, r, s₀, s₁)` — so the verdict is\n * identical on every run, which is what makes redistribution deterministic (modes.md 5, point 3).\n *\n * 1. **No edit may contain a marker.** No rule can produce one; one that does is a bug, and the\n * edit is discarded rather than treated as a redistribution question.\n * 2. **The edge-growth rule.** An edit is discarded if it would place code points at an\n * extremity of its span that were not there before: with `d = q - p + 1` the replaced length\n * and `r` the replacement length, discard when `p = s₀ and r > d`, or `q = s₁ and r > d`.\n *\n * The length test is the whole rule and needs no knowledge of Markdown or HTML syntax. It\n * separates exactly the cases that matter: `\"` → `“` at an edge is 1 → 1 and applies; `--` →\n * `␣–␣` at an edge is 2 → 3 and is discarded, while the same edit interior to a span applies;\n * `(c)` → `©` is 3 → 1 and applies, because shrinking is always safe. An insertion has `d = 0`,\n * so it is discarded exactly when its position coincides with a span edge — the rule this one\n * generalises.\n *\n * **Deletion at an edge is not restricted here**, and must not be: `r > d` is false for a\n * deletion, so this filter never sees one. Deletion at an edge is governed by modes.md 3.3's\n * *Edge tests* clause instead — where a rule asks \"am I at the edge of the text I am allowed to\n * modify\" rather than \"what character is here\", the marker behaves as `NONE`. That clause is the\n * one place a rule may treat a span edge as the end of the text, it exists because `spaces` is\n * the only rule that deletes, and 3.3 states the division: **a rule that deletes must treat a\n * span edge as the end of the text; a rule that replaces or inserts must not, and is governed by\n * this filter.** The single test that claims the clause is `spaces.md` 3.2 step 4.\n */\nexport function filterBoundaryEdits(\n cp: readonly number[],\n edits: readonly Edit[],\n ranges: readonly SpanRange[],\n): Edit[] {\n const out: Edit[] = [];\n for (const edit of edits) {\n let containsMarker = false;\n for (let i = edit.start; i < edit.end; i += 1) {\n if (isMarker(cp[i] as number)) {\n containsMarker = true;\n break;\n }\n }\n if (containsMarker) continue;\n\n // `[start, end)` in the engine's half-open form is `cp[p … q]` with p = start, q = end - 1;\n // an insertion is `q = p - 1`, which falls out of the same expression.\n const p = edit.start;\n const q = edit.end - 1;\n const d = edit.end - edit.start;\n const r = edit.replacement.length;\n const span = spanContaining(ranges, p);\n if (span !== undefined && r > d && (p === span.first || q === span.last)) continue;\n\n out.push(edit);\n }\n return out;\n}\n\n/** Redistribute the transformed array back to one piece per span (modes.md 3.5 step 4). */\nexport function splitOnMarker(cp: readonly number[], expected: number): number[][] {\n const pieces: number[][] = [[]];\n for (const value of cp) {\n if (isMarker(value)) {\n pieces.push([]);\n continue;\n }\n (pieces[pieces.length - 1] as number[]).push(value);\n }\n if (pieces.length !== expected) {\n throw new PolytypoError(\n \"POLYTYPO_RULE_CONTRACT\",\n `boundary markers did not survive the pipeline: expected ${expected} spans, found ${pieces.length}`,\n );\n }\n return pieces;\n}\n","import {\n concatenateSpans,\n filterBoundaryEdits,\n normalizeSpans,\n spanRangesOf,\n splitOnMarker,\n type Span,\n} from \"../modes/spans.js\";\nimport { RULES } from \"../rules/registry.js\";\nimport type { LocaleData, Mode, RuleId } from \"../types.js\";\nimport { applyEdits } from \"./edits.js\";\nimport { fromCodePoints } from \"./codepoints.js\";\n\n/**\n * The same sequence as `runRules` (`./rule-runner.js`), with the two boundary filters of\n * modes.md 3.4 interposed. The span extents are recomputed after every rule, because applying\n * an edit shifts every index after it; the markers themselves always survive, since no edit may\n * contain one.\n */\nfunction runRulesOverSpans(\n cp: readonly number[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n): readonly number[] {\n let current = cp;\n for (const id of planned) {\n const rule = RULES[id];\n if (rule === undefined) continue;\n const edits = rule.apply({ cp: current, locale, mode });\n current = applyEdits(current, filterBoundaryEdits(current, edits, spanRangesOf(current)), id);\n }\n return current;\n}\n\n/**\n * modes.md 3.5. The pipeline runs **once**, over the marker-separated concatenation of every\n * processable span — not per span, which would pair quotation marks in isolation, and not over a\n * naive concatenation, which would manufacture adjacencies the document does not have.\n *\n * The output is the input with a set of disjoint substring replacements applied and nothing else\n * (modes.md 4). A span whose content the rules did not change contributes no replacement, so a\n * document needing no changes comes back byte-identical; the parser located the spans and was\n * then discarded, and the document is never serialised.\n */\nexport function runOverSpans(\n source: string,\n spans: readonly Span[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n): string {\n const normalized = normalizeSpans(spans);\n if (normalized.length === 0) return source;\n\n const transformed = runRulesOverSpans(\n concatenateSpans(source, normalized),\n planned,\n locale,\n mode,\n );\n const pieces = splitOnMarker(transformed, normalized.length);\n\n let out = \"\";\n let cursor = 0;\n for (let i = 0; i < normalized.length; i += 1) {\n const span = normalized[i] as Span;\n const replacement = fromCodePoints(pieces[i] as number[]);\n const original = source.slice(span.start, span.end);\n out += source.slice(cursor, span.start);\n out += replacement === original ? original : replacement;\n cursor = span.end;\n }\n return out + source.slice(cursor);\n}\n"]}
@@ -3,12 +3,12 @@ import {
3
3
  isSkippedElement,
4
4
  runOverSpans,
5
5
  wrapParserErrors
6
- } from "./chunk-E63PQ3N7.js";
6
+ } from "./chunk-ZBLCAVSM.js";
7
7
  import {
8
8
  PolytypoError,
9
9
  getLocaleData,
10
10
  planRules
11
- } from "./chunk-47XAYIKV.js";
11
+ } from "./chunk-3XRMEZDM.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-X2B4LIW3.js.map
@@ -7,7 +7,7 @@ import {
7
7
  fromCodePoints,
8
8
  isMarker,
9
9
  toCodePoints
10
- } from "./chunk-47XAYIKV.js";
10
+ } from "./chunk-3XRMEZDM.js";
11
11
 
12
12
  // src/modes/html.ts
13
13
  import { parse, parseFragment } from "parse5";
@@ -294,4 +294,4 @@ export {
294
294
  htmlFragmentSpans,
295
295
  runOverSpans
296
296
  };
297
- //# sourceMappingURL=chunk-E63PQ3N7.js.map
297
+ //# sourceMappingURL=chunk-ZBLCAVSM.js.map
package/dist/html.cjs CHANGED
@@ -1,22 +1,22 @@
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 _chunkF3BDCZSGcjs = require('./chunk-F3BDCZSG.cjs');
4
- require('./chunk-YS3FXB5V.cjs');
3
+ var _chunkIS7WKMGAcjs = require('./chunk-IS7WKMGA.cjs');
4
+ require('./chunk-RNFW7474.cjs');
5
5
 
6
6
 
7
- var _chunk7IZAODBBcjs = require('./chunk-7IZAODBB.cjs');
7
+ var _chunkCZRTSOOBcjs = require('./chunk-CZRTSOOB.cjs');
8
8
 
9
9
 
10
- var _chunkMOVY7OL2cjs = require('./chunk-MOVY7OL2.cjs');
10
+ var _chunkADRRRKLBcjs = require('./chunk-ADRRRKLB.cjs');
11
11
 
12
12
  // src/index.html.ts
13
13
  function transform(input, options) {
14
14
  const given = _nullishCoalesce(options, () => ( {}));
15
- _chunk7IZAODBBcjs.assertFixedMode.call(void 0, given.mode, "html", "polytypo/html");
16
- return _chunkF3BDCZSGcjs.runHtmlPipeline.call(void 0, input, given);
15
+ _chunkCZRTSOOBcjs.assertFixedMode.call(void 0, given.mode, "html", "polytypo/html");
16
+ return _chunkIS7WKMGAcjs.runHtmlPipeline.call(void 0, input, given);
17
17
  }
18
18
 
19
19
 
20
20
 
21
- exports.PolytypoError = _chunkMOVY7OL2cjs.PolytypoError; exports.transform = transform;
21
+ exports.PolytypoError = _chunkADRRRKLBcjs.PolytypoError; exports.transform = transform;
22
22
  //# sourceMappingURL=html.cjs.map
package/dist/html.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  runHtmlPipeline
3
- } from "./chunk-UKWVAQMR.js";
4
- import "./chunk-E63PQ3N7.js";
3
+ } from "./chunk-EWZWHW3B.js";
4
+ import "./chunk-ZBLCAVSM.js";
5
5
  import {
6
6
  assertFixedMode
7
- } from "./chunk-MMU4UU46.js";
7
+ } from "./chunk-4FZZJB7Y.js";
8
8
  import {
9
9
  PolytypoError
10
- } from "./chunk-47XAYIKV.js";
10
+ } from "./chunk-3XRMEZDM.js";
11
11
 
12
12
  // src/index.html.ts
13
13
  function transform(input, options) {
package/dist/index.cjs CHANGED
@@ -1,22 +1,22 @@
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 _chunkDZ72ITYVcjs = require('./chunk-DZ72ITYV.cjs');
3
+ var _chunkA4HNRHBVcjs = require('./chunk-A4HNRHBV.cjs');
4
4
 
5
5
 
6
- var _chunkF3BDCZSGcjs = require('./chunk-F3BDCZSG.cjs');
6
+ var _chunkIS7WKMGAcjs = require('./chunk-IS7WKMGA.cjs');
7
7
 
8
8
 
9
- var _chunkM2UGLSIBcjs = require('./chunk-M2UGLSIB.cjs');
10
- require('./chunk-YS3FXB5V.cjs');
9
+ var _chunk5BVKKURTcjs = require('./chunk-5BVKKURT.cjs');
10
+ require('./chunk-RNFW7474.cjs');
11
11
 
12
12
 
13
- var _chunkMOVY7OL2cjs = require('./chunk-MOVY7OL2.cjs');
13
+ var _chunkADRRRKLBcjs = require('./chunk-ADRRRKLB.cjs');
14
14
 
15
15
  // src/engine/pipeline.ts
16
16
  function resolveMode(mode) {
17
17
  if (mode === void 0 || mode === "text") return "text";
18
18
  if (mode === "html" || mode === "markdown") return mode;
19
- throw new (0, _chunkMOVY7OL2cjs.PolytypoError)(
19
+ throw new (0, _chunkADRRRKLBcjs.PolytypoError)(
20
20
  "POLYTYPO_INVALID_MODE",
21
21
  `Unknown mode "${String(mode)}". Expected "text", "html" or "markdown".`
22
22
  );
@@ -24,9 +24,9 @@ function resolveMode(mode) {
24
24
  function runPipeline(input, options) {
25
25
  const given = _nullishCoalesce(options, () => ( {}));
26
26
  const mode = resolveMode(given.mode);
27
- if (mode === "text") return _chunkDZ72ITYVcjs.runTextPipeline.call(void 0, input, given);
28
- if (mode === "html") return _chunkF3BDCZSGcjs.runHtmlPipeline.call(void 0, input, given);
29
- return _chunkM2UGLSIBcjs.runMarkdownPipeline.call(void 0, input, given);
27
+ if (mode === "text") return _chunkA4HNRHBVcjs.runTextPipeline.call(void 0, input, given);
28
+ if (mode === "html") return _chunkIS7WKMGAcjs.runHtmlPipeline.call(void 0, input, given);
29
+ return _chunk5BVKKURTcjs.runMarkdownPipeline.call(void 0, input, given);
30
30
  }
31
31
 
32
32
  // src/index.ts
@@ -36,5 +36,5 @@ function transform(input, options) {
36
36
 
37
37
 
38
38
 
39
- exports.PolytypoError = _chunkMOVY7OL2cjs.PolytypoError; exports.transform = transform;
39
+ exports.PolytypoError = _chunkADRRRKLBcjs.PolytypoError; exports.transform = transform;
40
40
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  runTextPipeline
3
- } from "./chunk-7L4ECXDJ.js";
3
+ } from "./chunk-ILWDO7FZ.js";
4
4
  import {
5
5
  runHtmlPipeline
6
- } from "./chunk-UKWVAQMR.js";
6
+ } from "./chunk-EWZWHW3B.js";
7
7
  import {
8
8
  runMarkdownPipeline
9
- } from "./chunk-HZPDGNOO.js";
10
- import "./chunk-E63PQ3N7.js";
9
+ } from "./chunk-X2B4LIW3.js";
10
+ import "./chunk-ZBLCAVSM.js";
11
11
  import {
12
12
  PolytypoError
13
- } from "./chunk-47XAYIKV.js";
13
+ } from "./chunk-3XRMEZDM.js";
14
14
 
15
15
  // src/engine/pipeline.ts
16
16
  function resolveMode(mode) {
package/dist/markdown.cjs CHANGED
@@ -1,22 +1,22 @@
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 _chunkM2UGLSIBcjs = require('./chunk-M2UGLSIB.cjs');
4
- require('./chunk-YS3FXB5V.cjs');
3
+ var _chunk5BVKKURTcjs = require('./chunk-5BVKKURT.cjs');
4
+ require('./chunk-RNFW7474.cjs');
5
5
 
6
6
 
7
- var _chunk7IZAODBBcjs = require('./chunk-7IZAODBB.cjs');
7
+ var _chunkCZRTSOOBcjs = require('./chunk-CZRTSOOB.cjs');
8
8
 
9
9
 
10
- var _chunkMOVY7OL2cjs = require('./chunk-MOVY7OL2.cjs');
10
+ var _chunkADRRRKLBcjs = require('./chunk-ADRRRKLB.cjs');
11
11
 
12
12
  // src/index.markdown.ts
13
13
  function transform(input, options) {
14
14
  const given = _nullishCoalesce(options, () => ( {}));
15
- _chunk7IZAODBBcjs.assertFixedMode.call(void 0, given.mode, "markdown", "polytypo/markdown");
16
- return _chunkM2UGLSIBcjs.runMarkdownPipeline.call(void 0, input, given);
15
+ _chunkCZRTSOOBcjs.assertFixedMode.call(void 0, given.mode, "markdown", "polytypo/markdown");
16
+ return _chunk5BVKKURTcjs.runMarkdownPipeline.call(void 0, input, given);
17
17
  }
18
18
 
19
19
 
20
20
 
21
- exports.PolytypoError = _chunkMOVY7OL2cjs.PolytypoError; exports.transform = transform;
21
+ exports.PolytypoError = _chunkADRRRKLBcjs.PolytypoError; exports.transform = transform;
22
22
  //# sourceMappingURL=markdown.cjs.map
package/dist/markdown.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  runMarkdownPipeline
3
- } from "./chunk-HZPDGNOO.js";
4
- import "./chunk-E63PQ3N7.js";
3
+ } from "./chunk-X2B4LIW3.js";
4
+ import "./chunk-ZBLCAVSM.js";
5
5
  import {
6
6
  assertFixedMode
7
- } from "./chunk-MMU4UU46.js";
7
+ } from "./chunk-4FZZJB7Y.js";
8
8
  import {
9
9
  PolytypoError
10
- } from "./chunk-47XAYIKV.js";
10
+ } from "./chunk-3XRMEZDM.js";
11
11
 
12
12
  // src/index.markdown.ts
13
13
  function transform(input, options) {
package/dist/text.cjs CHANGED
@@ -1,21 +1,21 @@
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 _chunkDZ72ITYVcjs = require('./chunk-DZ72ITYV.cjs');
3
+ var _chunkA4HNRHBVcjs = require('./chunk-A4HNRHBV.cjs');
4
4
 
5
5
 
6
- var _chunk7IZAODBBcjs = require('./chunk-7IZAODBB.cjs');
6
+ var _chunkCZRTSOOBcjs = require('./chunk-CZRTSOOB.cjs');
7
7
 
8
8
 
9
- var _chunkMOVY7OL2cjs = require('./chunk-MOVY7OL2.cjs');
9
+ var _chunkADRRRKLBcjs = require('./chunk-ADRRRKLB.cjs');
10
10
 
11
11
  // src/index.text.ts
12
12
  function transform(input, options) {
13
13
  const given = _nullishCoalesce(options, () => ( {}));
14
- _chunk7IZAODBBcjs.assertFixedMode.call(void 0, given.mode, "text", "polytypo/text");
15
- return _chunkDZ72ITYVcjs.runTextPipeline.call(void 0, input, given);
14
+ _chunkCZRTSOOBcjs.assertFixedMode.call(void 0, given.mode, "text", "polytypo/text");
15
+ return _chunkA4HNRHBVcjs.runTextPipeline.call(void 0, input, given);
16
16
  }
17
17
 
18
18
 
19
19
 
20
- exports.PolytypoError = _chunkMOVY7OL2cjs.PolytypoError; exports.transform = transform;
20
+ exports.PolytypoError = _chunkADRRRKLBcjs.PolytypoError; exports.transform = transform;
21
21
  //# sourceMappingURL=text.cjs.map
package/dist/text.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  runTextPipeline
3
- } from "./chunk-7L4ECXDJ.js";
3
+ } from "./chunk-ILWDO7FZ.js";
4
4
  import {
5
5
  assertFixedMode
6
- } from "./chunk-MMU4UU46.js";
6
+ } from "./chunk-4FZZJB7Y.js";
7
7
  import {
8
8
  PolytypoError
9
- } from "./chunk-47XAYIKV.js";
9
+ } from "./chunk-3XRMEZDM.js";
10
10
 
11
11
  // src/index.text.ts
12
12
  function transform(input, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polytypo",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Normalize typography across languages: locale-correct quotes, dashes, ellipses and no-break spaces.",
5
5
  "keywords": [
6
6
  "typography",
@@ -1,19 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
-
7
- var _chunkMOVY7OL2cjs = require('./chunk-MOVY7OL2.cjs');
8
-
9
- // src/engine/text-pipeline.ts
10
- function runTextPipeline(input, options) {
11
- const planned = _chunkMOVY7OL2cjs.planRules.call(void 0, options.rules);
12
- const locale = _chunkMOVY7OL2cjs.getLocaleData.call(void 0, options.locale);
13
- return _chunkMOVY7OL2cjs.fromCodePoints.call(void 0, _chunkMOVY7OL2cjs.runRules.call(void 0, _chunkMOVY7OL2cjs.toCodePoints.call(void 0, input), planned, locale, "text"));
14
- }
15
-
16
-
17
-
18
- exports.runTextPipeline = runTextPipeline;
19
- //# sourceMappingURL=chunk-DZ72ITYV.cjs.map
@@ -1,21 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
- var _chunkYS3FXB5Vcjs = require('./chunk-YS3FXB5V.cjs');
5
-
6
-
7
-
8
- var _chunkMOVY7OL2cjs = require('./chunk-MOVY7OL2.cjs');
9
-
10
- // src/engine/html-pipeline.ts
11
- function runHtmlPipeline(input, options) {
12
- const planned = _chunkMOVY7OL2cjs.planRules.call(void 0, options.rules);
13
- const locale = _chunkMOVY7OL2cjs.getLocaleData.call(void 0, options.locale);
14
- const spans = _chunkYS3FXB5Vcjs.htmlSpans.call(void 0, input);
15
- return _chunkYS3FXB5Vcjs.runOverSpans.call(void 0, input, spans, planned, locale, "html");
16
- }
17
-
18
-
19
-
20
- exports.runHtmlPipeline = runHtmlPipeline;
21
- //# sourceMappingURL=chunk-F3BDCZSG.cjs.map