polytypo 1.9.0 → 1.10.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 (54) hide show
  1. package/dist/{chunk-THBEZ5VW.cjs → chunk-7AC2JBQG.cjs} +4 -4
  2. package/dist/{chunk-THBEZ5VW.cjs.map → chunk-7AC2JBQG.cjs.map} +1 -1
  3. package/dist/{chunk-5Q7KXC4O.js → chunk-7AGGQEWJ.js} +4 -4
  4. package/dist/{chunk-AU3NCVAE.js → chunk-BGA6QQBY.js} +8 -3
  5. package/dist/chunk-BGA6QQBY.js.map +1 -0
  6. package/dist/{chunk-N7BD7WTA.js → chunk-CVPCIIOT.js} +2 -2
  7. package/dist/{chunk-XPVOE23B.js → chunk-EROJVHMJ.js} +2 -2
  8. package/dist/{chunk-RRGKEG6E.cjs → chunk-FFIR7BWQ.cjs} +1 -1
  9. package/dist/chunk-FFIR7BWQ.cjs.map +1 -0
  10. package/dist/chunk-FR2MCL5K.cjs +33 -0
  11. package/dist/{chunk-NZ55L5GB.cjs.map → chunk-FR2MCL5K.cjs.map} +1 -1
  12. package/dist/chunk-H26TGFP7.cjs +31 -0
  13. package/dist/{chunk-GAK57EOC.cjs.map → chunk-H26TGFP7.cjs.map} +1 -1
  14. package/dist/{chunk-ZYSNCPJG.cjs → chunk-HB4TT6IE.cjs} +21 -21
  15. package/dist/{chunk-ZYSNCPJG.cjs.map → chunk-HB4TT6IE.cjs.map} +1 -1
  16. package/dist/{chunk-I6G3ZOZR.cjs → chunk-IH26NEJ6.cjs} +12 -7
  17. package/dist/chunk-IH26NEJ6.cjs.map +1 -0
  18. package/dist/{chunk-V2UZZU7M.js → chunk-IMLOL2TH.js} +2 -2
  19. package/dist/chunk-KSW5EOAP.cjs +35 -0
  20. package/dist/{chunk-777UZMD2.cjs.map → chunk-KSW5EOAP.cjs.map} +1 -1
  21. package/dist/{chunk-56X7JKY3.js → chunk-NSVC7XZG.js} +4 -4
  22. package/dist/{chunk-OR7GGYEA.cjs → chunk-QPIQMX2S.cjs} +16 -16
  23. package/dist/{chunk-OR7GGYEA.cjs.map → chunk-QPIQMX2S.cjs.map} +1 -1
  24. package/dist/{chunk-P27DD76M.js → chunk-TRUHKCDB.js} +1 -1
  25. package/dist/chunk-TRUHKCDB.js.map +1 -0
  26. package/dist/{chunk-UV3Y2RCW.js → chunk-X3RDLKUA.js} +2 -2
  27. package/dist/{chunk-2BAESRH6.cjs → chunk-XK7NZDVI.cjs} +3 -3
  28. package/dist/{chunk-2BAESRH6.cjs.map → chunk-XK7NZDVI.cjs.map} +1 -1
  29. package/dist/{chunk-DJF2GHW3.js → chunk-ZMIMLHKI.js} +5 -5
  30. package/dist/html.cjs +10 -10
  31. package/dist/html.js +5 -5
  32. package/dist/index.cjs +18 -18
  33. package/dist/index.js +8 -8
  34. package/dist/markdown.cjs +11 -11
  35. package/dist/markdown.js +6 -6
  36. package/dist/text.cjs +8 -8
  37. package/dist/text.js +3 -3
  38. package/dist/yaml.cjs +10 -10
  39. package/dist/yaml.js +5 -5
  40. package/package.json +1 -1
  41. package/dist/chunk-777UZMD2.cjs +0 -35
  42. package/dist/chunk-AU3NCVAE.js.map +0 -1
  43. package/dist/chunk-GAK57EOC.cjs +0 -31
  44. package/dist/chunk-I6G3ZOZR.cjs.map +0 -1
  45. package/dist/chunk-NZ55L5GB.cjs +0 -33
  46. package/dist/chunk-P27DD76M.js.map +0 -1
  47. package/dist/chunk-RRGKEG6E.cjs.map +0 -1
  48. /package/dist/{chunk-5Q7KXC4O.js.map → chunk-7AGGQEWJ.js.map} +0 -0
  49. /package/dist/{chunk-N7BD7WTA.js.map → chunk-CVPCIIOT.js.map} +0 -0
  50. /package/dist/{chunk-XPVOE23B.js.map → chunk-EROJVHMJ.js.map} +0 -0
  51. /package/dist/{chunk-V2UZZU7M.js.map → chunk-IMLOL2TH.js.map} +0 -0
  52. /package/dist/{chunk-56X7JKY3.js.map → chunk-NSVC7XZG.js.map} +0 -0
  53. /package/dist/{chunk-UV3Y2RCW.js.map → chunk-X3RDLKUA.js.map} +0 -0
  54. /package/dist/{chunk-DJF2GHW3.js.map → chunk-ZMIMLHKI.js.map} +0 -0
@@ -0,0 +1,33 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk7AC2JBQGcjs = require('./chunk-7AC2JBQG.cjs');
4
+
5
+
6
+
7
+ var _chunkQPIQMX2Scjs = require('./chunk-QPIQMX2S.cjs');
8
+
9
+
10
+
11
+
12
+ var _chunkFFIR7BWQcjs = require('./chunk-FFIR7BWQ.cjs');
13
+
14
+ // src/engine/html-pipeline.ts
15
+ function runHtmlPipeline(input, options) {
16
+ const narrowTarget = _chunkFFIR7BWQcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
17
+ const planned = _chunkFFIR7BWQcjs.planRules.call(void 0, options.rules);
18
+ const locale = _chunkFFIR7BWQcjs.getLocaleData.call(void 0, options.locale);
19
+ const spans = _chunk7AC2JBQGcjs.htmlSpans.call(void 0, input);
20
+ return _chunkQPIQMX2Scjs.runOverSpans.call(void 0, input, spans, planned, locale, "html", narrowTarget);
21
+ }
22
+ function analyzeHtmlPipeline(input, options) {
23
+ const narrowTarget = _chunkFFIR7BWQcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
24
+ const planned = _chunkFFIR7BWQcjs.planRules.call(void 0, options.rules);
25
+ const locale = _chunkFFIR7BWQcjs.getLocaleData.call(void 0, options.locale);
26
+ return _chunkQPIQMX2Scjs.analyzeOverSpans.call(void 0, input, _chunk7AC2JBQGcjs.htmlSpans.call(void 0, input), planned, locale, "html", narrowTarget);
27
+ }
28
+
29
+
30
+
31
+
32
+ exports.runHtmlPipeline = runHtmlPipeline; exports.analyzeHtmlPipeline = analyzeHtmlPipeline;
33
+ //# sourceMappingURL=chunk-FR2MCL5K.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-NZ55L5GB.cjs","../src/engine/html-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACIO,SAAS,eAAA,CAAgB,KAAA,EAAe,OAAA,EAAmC;AAChF,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,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,MAAA,EAAQ,YAAY,CAAA;AACzE;AAGO,SAAS,mBAAA,CAAoB,KAAA,EAAe,OAAA,EAAqC;AACtF,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,EAAA,MAAM,QAAA,EAAU,yCAAA,OAAU,CAAQ,KAAK,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,6CAAA,OAAc,CAAQ,MAAM,CAAA;AAC3C,EAAA,OAAO,gDAAA,KAAiB,EAAO,yCAAA,KAAe,CAAA,EAAG,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,YAAY,CAAA;AACxF;ADJA;AACA;AACE;AACA;AACF,6FAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-NZ55L5GB.cjs","sourcesContent":[null,"import { htmlSpans } from \"../modes/html.js\";\nimport type { Options } from \"../types.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { resolveNarrowTarget } from \"./narrow-target.js\";\nimport { planRules } from \"./rule-runner.js\";\nimport { analyzeOverSpans, runOverSpans } from \"./span-runner.js\";\nimport type { Change } from \"./origin.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 narrowTarget = resolveNarrowTarget(options.narrowNbsp);\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\", narrowTarget);\n}\n\n/** analyze.md §1, `html` mode: offsets are into the document, not into a span (analyze.md §6). */\nexport function analyzeHtmlPipeline(input: string, options: Partial<Options>): Change[] {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n return analyzeOverSpans(input, htmlSpans(input), planned, locale, \"html\", narrowTarget);\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-FR2MCL5K.cjs","../src/engine/html-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACIO,SAAS,eAAA,CAAgB,KAAA,EAAe,OAAA,EAAmC;AAChF,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,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,MAAA,EAAQ,YAAY,CAAA;AACzE;AAGO,SAAS,mBAAA,CAAoB,KAAA,EAAe,OAAA,EAAqC;AACtF,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,EAAA,MAAM,QAAA,EAAU,yCAAA,OAAU,CAAQ,KAAK,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,6CAAA,OAAc,CAAQ,MAAM,CAAA;AAC3C,EAAA,OAAO,gDAAA,KAAiB,EAAO,yCAAA,KAAe,CAAA,EAAG,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,YAAY,CAAA;AACxF;ADJA;AACA;AACE;AACA;AACF,6FAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-FR2MCL5K.cjs","sourcesContent":[null,"import { htmlSpans } from \"../modes/html.js\";\nimport type { Options } from \"../types.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { resolveNarrowTarget } from \"./narrow-target.js\";\nimport { planRules } from \"./rule-runner.js\";\nimport { analyzeOverSpans, runOverSpans } from \"./span-runner.js\";\nimport type { Change } from \"./origin.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 narrowTarget = resolveNarrowTarget(options.narrowNbsp);\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\", narrowTarget);\n}\n\n/** analyze.md §1, `html` mode: offsets are into the document, not into a span (analyze.md §6). */\nexport function analyzeHtmlPipeline(input: string, options: Partial<Options>): Change[] {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n return analyzeOverSpans(input, htmlSpans(input), planned, locale, \"html\", narrowTarget);\n}\n"]}
@@ -0,0 +1,31 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+ var _chunkFFIR7BWQcjs = require('./chunk-FFIR7BWQ.cjs');
10
+
11
+ // src/engine/text-pipeline.ts
12
+ function runTextPipeline(input, options) {
13
+ const narrowTarget = _chunkFFIR7BWQcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
14
+ const planned = _chunkFFIR7BWQcjs.planRules.call(void 0, options.rules);
15
+ const locale = _chunkFFIR7BWQcjs.getLocaleData.call(void 0, options.locale);
16
+ return _chunkFFIR7BWQcjs.fromCodePoints.call(void 0, _chunkFFIR7BWQcjs.runRules.call(void 0, _chunkFFIR7BWQcjs.toCodePoints.call(void 0, input), planned, locale, "text", narrowTarget));
17
+ }
18
+ function analyzeTextPipeline(input, options) {
19
+ const narrowTarget = _chunkFFIR7BWQcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
20
+ const planned = _chunkFFIR7BWQcjs.planRules.call(void 0, options.rules);
21
+ const locale = _chunkFFIR7BWQcjs.getLocaleData.call(void 0, options.locale);
22
+ const cp = _chunkFFIR7BWQcjs.toCodePoints.call(void 0, input);
23
+ const origin = cp.map((_value, index) => index);
24
+ return _chunkFFIR7BWQcjs.runRulesRecording.call(void 0, cp, planned, locale, "text", narrowTarget, origin, cp.length);
25
+ }
26
+
27
+
28
+
29
+
30
+ exports.runTextPipeline = runTextPipeline; exports.analyzeTextPipeline = analyzeTextPipeline;
31
+ //# sourceMappingURL=chunk-H26TGFP7.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-GAK57EOC.cjs","../src/engine/text-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACQO,SAAS,eAAA,CAAgB,KAAA,EAAe,OAAA,EAAmC;AAChF,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,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,MAAA,EAAQ,YAAY,CAAC,CAAA;AAC5F;AAGO,SAAS,mBAAA,CAAoB,KAAA,EAAe,OAAA,EAAqC;AACtF,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,EAAA,MAAM,QAAA,EAAU,yCAAA,OAAU,CAAQ,KAAK,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,6CAAA,OAAc,CAAQ,MAAM,CAAA;AAC3C,EAAA,MAAM,GAAA,EAAK,4CAAA,KAAkB,CAAA;AAC7B,EAAA,MAAM,OAAA,EAAS,EAAA,CAAG,GAAA,CAAI,CAAC,MAAA,EAAQ,KAAA,EAAA,GAAU,KAAK,CAAA;AAC9C,EAAA,OAAO,iDAAA,EAAkB,EAAI,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,YAAA,EAAc,MAAA,EAAQ,EAAA,CAAG,MAAM,CAAA;AACvF;ADRA;AACA;AACE;AACA;AACF,6FAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-GAK57EOC.cjs","sourcesContent":[null,"import type { Options } from \"../types.js\";\nimport { fromCodePoints, toCodePoints } from \"./codepoints.js\";\nimport type { Change } from \"./origin.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { resolveNarrowTarget } from \"./narrow-target.js\";\nimport { planRules, runRules, runRulesRecording } 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 narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n return fromCodePoints(runRules(toCodePoints(input), planned, locale, \"text\", narrowTarget));\n}\n\n/** analyze.md §1: the same pipeline as `runTextPipeline`, reporting instead of applying. */\nexport function analyzeTextPipeline(input: string, options: Partial<Options>): Change[] {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const cp = toCodePoints(input);\n const origin = cp.map((_value, index) => index);\n return runRulesRecording(cp, planned, locale, \"text\", narrowTarget, origin, cp.length);\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-H26TGFP7.cjs","../src/engine/text-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACQO,SAAS,eAAA,CAAgB,KAAA,EAAe,OAAA,EAAmC;AAChF,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,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,MAAA,EAAQ,YAAY,CAAC,CAAA;AAC5F;AAGO,SAAS,mBAAA,CAAoB,KAAA,EAAe,OAAA,EAAqC;AACtF,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,EAAA,MAAM,QAAA,EAAU,yCAAA,OAAU,CAAQ,KAAK,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,6CAAA,OAAc,CAAQ,MAAM,CAAA;AAC3C,EAAA,MAAM,GAAA,EAAK,4CAAA,KAAkB,CAAA;AAC7B,EAAA,MAAM,OAAA,EAAS,EAAA,CAAG,GAAA,CAAI,CAAC,MAAA,EAAQ,KAAA,EAAA,GAAU,KAAK,CAAA;AAC9C,EAAA,OAAO,iDAAA,EAAkB,EAAI,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,YAAA,EAAc,MAAA,EAAQ,EAAA,CAAG,MAAM,CAAA;AACvF;ADRA;AACA;AACE;AACA;AACF,6FAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-H26TGFP7.cjs","sourcesContent":[null,"import type { Options } from \"../types.js\";\nimport { fromCodePoints, toCodePoints } from \"./codepoints.js\";\nimport type { Change } from \"./origin.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { resolveNarrowTarget } from \"./narrow-target.js\";\nimport { planRules, runRules, runRulesRecording } 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 narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n return fromCodePoints(runRules(toCodePoints(input), planned, locale, \"text\", narrowTarget));\n}\n\n/** analyze.md §1: the same pipeline as `runTextPipeline`, reporting instead of applying. */\nexport function analyzeTextPipeline(input: string, options: Partial<Options>): Change[] {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const cp = toCodePoints(input);\n const origin = cp.map((_value, index) => index);\n return runRulesRecording(cp, planned, locale, \"text\", narrowTarget, origin, cp.length);\n}\n"]}
@@ -2,21 +2,21 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkTHBEZ5VWcjs = require('./chunk-THBEZ5VW.cjs');
5
+ var _chunk7AC2JBQGcjs = require('./chunk-7AC2JBQG.cjs');
6
6
 
7
7
 
8
8
 
9
- var _chunkI6G3ZOZRcjs = require('./chunk-I6G3ZOZR.cjs');
9
+ var _chunkIH26NEJ6cjs = require('./chunk-IH26NEJ6.cjs');
10
10
 
11
11
 
12
12
 
13
- var _chunkOR7GGYEAcjs = require('./chunk-OR7GGYEA.cjs');
13
+ var _chunkQPIQMX2Scjs = require('./chunk-QPIQMX2S.cjs');
14
14
 
15
15
 
16
16
 
17
17
 
18
18
 
19
- var _chunkRRGKEG6Ecjs = require('./chunk-RRGKEG6E.cjs');
19
+ var _chunkFFIR7BWQcjs = require('./chunk-FFIR7BWQ.cjs');
20
20
 
21
21
  // src/modes/markdown.ts
22
22
  var _micromark = require('micromark');
@@ -107,7 +107,7 @@ function updateElementStack(stack, tag, caseSensitive) {
107
107
  if (stack[stack.length - 1] === name) stack.pop();
108
108
  return;
109
109
  }
110
- if (!parsed.selfClosing && _chunkTHBEZ5VWcjs.isSkippedElement.call(void 0, name)) stack.push(name);
110
+ if (!parsed.selfClosing && _chunk7AC2JBQGcjs.isSkippedElement.call(void 0, name)) stack.push(name);
111
111
  }
112
112
  function tokenize(source, extensions) {
113
113
  return _micromark.postprocess.call(void 0,
@@ -117,12 +117,12 @@ function tokenize(source, extensions) {
117
117
  function resolveDialect(dialect) {
118
118
  if (dialect === "commonmark" || dialect === "mdx") return dialect;
119
119
  if (dialect === void 0) {
120
- throw new (0, _chunkRRGKEG6Ecjs.PolytypoError)(
120
+ throw new (0, _chunkFFIR7BWQcjs.PolytypoError)(
121
121
  "POLYTYPO_INVALID_DIALECT",
122
122
  'Mode "markdown" requires a dialect. Expected "commonmark" or "mdx"; there is no default.'
123
123
  );
124
124
  }
125
- throw new (0, _chunkRRGKEG6Ecjs.PolytypoError)(
125
+ throw new (0, _chunkFFIR7BWQcjs.PolytypoError)(
126
126
  "POLYTYPO_INVALID_DIALECT",
127
127
  `Unknown dialect "${String(dialect)}". Expected "commonmark" or "mdx".`
128
128
  );
@@ -188,7 +188,7 @@ function markdownSpans(source, dialect) {
188
188
  const masked = maskFrontmatter(source, block);
189
189
  const shift = masked.charCodeAt(0) === BOM ? 1 : 0;
190
190
  const text = shift === 0 ? masked : masked.slice(shift);
191
- const events = _chunkTHBEZ5VWcjs.wrapParserErrors.call(void 0, dialect, () => tokenize(text, extensionsFor(dialect)));
191
+ const events = _chunk7AC2JBQGcjs.wrapParserErrors.call(void 0, dialect, () => tokenize(text, extensionsFor(dialect)));
192
192
  const spans = [];
193
193
  const elementStack = [];
194
194
  let skipDepth = 0;
@@ -211,7 +211,7 @@ function markdownSpans(source, dialect) {
211
211
  }
212
212
  if (type === "htmlFlow") {
213
213
  if (kind === "enter" && skipDepth === 0 && elementStack.length === 0) {
214
- for (const span of _chunkTHBEZ5VWcjs.htmlFragmentSpans.call(void 0,
214
+ for (const span of _chunk7AC2JBQGcjs.htmlFragmentSpans.call(void 0,
215
215
  text.slice(token.start.offset, token.end.offset),
216
216
  token.start.offset + shift
217
217
  )) {
@@ -255,18 +255,18 @@ function frontmatterSpans(source, frontmatterKeys) {
255
255
  const { contentStart, contentEnd } = block;
256
256
  const content = source.slice(contentStart, contentEnd);
257
257
  const declined = declinedContentRanges(content);
258
- return _chunkI6G3ZOZRcjs.yamlSpans.call(void 0, content, frontmatterKeys).filter((span) => !declined.some((range) => span.start < range.end && range.start < span.end)).map((span) => ({ start: span.start + contentStart, end: span.end + contentStart }));
258
+ return _chunkIH26NEJ6cjs.yamlSpans.call(void 0, content, frontmatterKeys).filter((span) => !declined.some((range) => span.start < range.end && range.start < span.end)).map((span) => ({ start: span.start + contentStart, end: span.end + contentStart }));
259
259
  }
260
260
 
261
261
  // src/engine/markdown-pipeline.ts
262
262
  function runMarkdownPipeline(input, options) {
263
- const narrowTarget = _chunkRRGKEG6Ecjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
264
- const planned = _chunkRRGKEG6Ecjs.planRules.call(void 0, options.rules);
265
- const locale = _chunkRRGKEG6Ecjs.getLocaleData.call(void 0, options.locale);
263
+ const narrowTarget = _chunkFFIR7BWQcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
264
+ const planned = _chunkFFIR7BWQcjs.planRules.call(void 0, options.rules);
265
+ const locale = _chunkFFIR7BWQcjs.getLocaleData.call(void 0, options.locale);
266
266
  const dialect = resolveDialect(options.dialect);
267
- const frontmatterKeys = _chunkI6G3ZOZRcjs.resolveFrontmatterKeys.call(void 0, options.frontmatterKeys);
267
+ const frontmatterKeys = _chunkIH26NEJ6cjs.resolveFrontmatterKeys.call(void 0, options.frontmatterKeys);
268
268
  const units = unitsOf(input, dialect, frontmatterKeys);
269
- return _chunkOR7GGYEAcjs.runOverUnits.call(void 0, input, units, planned, locale, "markdown", narrowTarget);
269
+ return _chunkQPIQMX2Scjs.runOverUnits.call(void 0, input, units, planned, locale, "markdown", narrowTarget);
270
270
  }
271
271
  function unitsOf(input, dialect, frontmatterKeys) {
272
272
  const body = markdownSpans(input, dialect);
@@ -274,12 +274,12 @@ function unitsOf(input, dialect, frontmatterKeys) {
274
274
  return [frontmatterSpans(input, frontmatterKeys), body];
275
275
  }
276
276
  function analyzeMarkdownPipeline(input, options) {
277
- const narrowTarget = _chunkRRGKEG6Ecjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
278
- const planned = _chunkRRGKEG6Ecjs.planRules.call(void 0, options.rules);
279
- const locale = _chunkRRGKEG6Ecjs.getLocaleData.call(void 0, options.locale);
277
+ const narrowTarget = _chunkFFIR7BWQcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
278
+ const planned = _chunkFFIR7BWQcjs.planRules.call(void 0, options.rules);
279
+ const locale = _chunkFFIR7BWQcjs.getLocaleData.call(void 0, options.locale);
280
280
  const dialect = resolveDialect(options.dialect);
281
- const frontmatterKeys = _chunkI6G3ZOZRcjs.resolveFrontmatterKeys.call(void 0, options.frontmatterKeys);
282
- return _chunkOR7GGYEAcjs.analyzeOverUnits.call(void 0,
281
+ const frontmatterKeys = _chunkIH26NEJ6cjs.resolveFrontmatterKeys.call(void 0, options.frontmatterKeys);
282
+ return _chunkQPIQMX2Scjs.analyzeOverUnits.call(void 0,
283
283
  input,
284
284
  unitsOf(input, dialect, frontmatterKeys),
285
285
  planned,
@@ -293,4 +293,4 @@ function analyzeMarkdownPipeline(input, options) {
293
293
 
294
294
 
295
295
  exports.runMarkdownPipeline = runMarkdownPipeline; exports.analyzeMarkdownPipeline = analyzeMarkdownPipeline;
296
- //# sourceMappingURL=chunk-ZYSNCPJG.cjs.map
296
+ //# sourceMappingURL=chunk-HB4TT6IE.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-ZYSNCPJG.cjs","../src/modes/markdown.ts","../src/engine/markdown-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACpBA,sCAA+C;AAC/C,gFAA4B;AAC5B,gEAAoB;AACpB,oEAAsB;AAiBtB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A,CAAc,KAAA,EAAO,OAAO,CAAA;AACzC,EAAA,GAAA,CAAI,gBAAA,IAAoB,KAAA,CAAA,EAAW,OAAO,CAAC,IAAI,CAAA;AAC/C,EAAA,OAAO,CAAC,gBAAA,CAAiB,KAAA,EAAO,eAAe,CAAA,EAAG,IAAI,CAAA;AACxD;AAKO,SAAS,uBAAA,CAAwB,KAAA,EAAe,OAAA,EAAqC;AAC1F,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,EAAA,MAAM,QAAA,EAAU,yCAAA,OAAU,CAAQ,KAAK,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,6CAAA,OAAc,CAAQ,MAAM,CAAA;AAC3C,EAAA,MAAM,QAAA,EAAU,cAAA,CAAe,OAAA,CAAQ,OAAO,CAAA;AAC9C,EAAA,MAAM,gBAAA,EAAkB,sDAAA,OAAuB,CAAQ,eAAe,CAAA;AACtE,EAAA,OAAO,gDAAA;AAAA,IACL,KAAA;AAAA,IACA,OAAA,CAAQ,KAAA,EAAO,OAAA,EAAS,eAAe,CAAA;AAAA,IACvC,OAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF;AF+NA;AACA;AACE;AACA;AACF,6GAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-ZYSNCPJG.cjs","sourcesContent":[null,"import { parse, postprocess, preprocess } from \"micromark\";\nimport { frontmatter } from \"micromark-extension-frontmatter\";\nimport { gfm } from \"micromark-extension-gfm\";\nimport { mdxjs } from \"micromark-extension-mdxjs\";\nimport type { Event, Extension } from \"micromark-util-types\";\nimport { PolytypoError } from \"../errors.js\";\nimport type { Dialect } from \"../types.js\";\nimport { htmlFragmentSpans, isSkippedElement } from \"./html.js\";\nimport { yamlSpans } from \"./yaml.js\";\nimport { wrapParserErrors } from \"./parse-error.js\";\nimport type { Span } from \"./spans.js\";\n\n/**\n * spec/rules/modes.md 3.7. Each entry is skipped **whole**, including anything that looks\n * processable inside it. The complement is not enumerated: a span is emitted only for a\n * micromark `data` token, which is the tokenizer's own name for \"literal content\", so list\n * markers, emphasis delimiters, heading sequences, table padding, line endings, hard-break\n * spaces, character escapes and character references are outside every span by construction\n * rather than by a second list that could drift from the first.\n */\nconst SKIPPED_TOKEN_TYPES: ReadonlySet<string> = new Set([\n // fenced code blocks (including the info string and the fences) and indented code blocks\n \"codeFenced\",\n \"codeIndented\",\n // inline code spans, including the backticks\n \"codeText\",\n // autolinks `<https://…>`, and GFM's bare-URL form\n \"autolink\",\n \"literalAutolink\",\n // link and image destinations and titles; the definition line of a reference link. The link\n // *text* is a `labelText`, which is not skipped.\n \"resource\",\n \"reference\",\n \"definition\",\n // MDX: expression containers in full, and every JSX attribute — the whole tag is skipped, so\n // attributes never surface. JSX element *children* sit outside the tag tokens and are\n // processable.\n \"mdxFlowExpression\",\n \"mdxTextExpression\",\n \"mdxjsEsm\",\n // modes.md 3.7.3, and it matters: without it the second `---` of a YAML block reads as a setext\n // underline, `title: Une note` becomes a paragraph, and `fr` puts a narrow no-break space in\n // front of the colon of a machine-read metadata field. Covered by conformance fixtures\n // en-us-markdown-{commonmark,mdx}-frontmatter, fr-markdown-{commonmark,mdx}-frontmatter-nbsp,\n // en-us-markdown-commonmark-frontmatter-toml and -frontmatter-unterminated.\n //\n // These are `micromark-extension-frontmatter`'s own token types, one per matter. An earlier\n // revision listed `\"frontmatter\"`, which the extension never emits: the block was skipped only\n // because its content arrives as `yamlValue`/`tomlValue` rather than `data`, so the entry that\n // was supposed to do the work did none.\n //\n // Since spec 1.8.0 the skip is 3.7.3a's mask, not this: a located block reaches the parser as\n // blanks, so the extension cannot see one. The extension stays because it is measured inert —\n // `tests/modes/frontmatter-keys.test.ts` asserts over every edge document that it never finds\n // a block the scan denies — and because removing a working locator that costs nothing would be\n // a change with no problem behind it. What the test would catch is the case that would matter:\n // the two disagreeing about whether a document has a block at all.\n \"yaml\",\n \"toml\",\n]);\n\n/** Token types whose enter/exit also maintains the skipped-element stack. */\nconst RAW_TAG_TOKEN_TYPES: ReadonlySet<string> = new Set([\n \"htmlText\",\n \"mdxJsxTextTag\",\n \"mdxJsxFlowTag\",\n]);\n\nconst LESS_THAN = 0x3c;\nconst GREATER_THAN = 0x3e;\nconst SLASH = 0x2f;\nconst EXCLAMATION = 0x21;\nconst QUESTION = 0x3f;\n\nfunction isAsciiLetter(unit: number): boolean {\n return (unit >= 0x61 && unit <= 0x7a) || (unit >= 0x41 && unit <= 0x5a);\n}\n\nfunction isTagNameUnit(unit: number): boolean {\n // Deliberately permissive: anything that is not a delimiter belongs to the name. Custom\n // elements (`my-callout`) and member expressions (`Foo.Bar`) must come out whole so that they\n // fail the skip-list membership test rather than being truncated into something that passes.\n return (\n unit !== GREATER_THAN &&\n unit !== SLASH &&\n unit !== 0x20 &&\n unit !== 0x09 &&\n unit !== 0x0a &&\n unit !== 0x0d\n );\n}\n\n/** ASCII-only, because HTML tag names are ASCII case-insensitive and `toLowerCase()` is not. */\nfunction asciiLower(value: string): string {\n let out = \"\";\n for (let i = 0; i < value.length; i += 1) {\n const unit = value.charCodeAt(i);\n out += unit >= 0x41 && unit <= 0x5a ? String.fromCharCode(unit + 0x20) : value[i];\n }\n return out;\n}\n\ninterface RawTag {\n readonly name: string;\n readonly closing: boolean;\n readonly selfClosing: boolean;\n}\n\nfunction readTag(tag: string): RawTag | null {\n if (tag.charCodeAt(0) !== LESS_THAN) return null;\n let i = 1;\n const closing = tag.charCodeAt(i) === SLASH;\n if (closing) i += 1;\n // Comments, declarations and processing instructions carry no element name.\n if (tag.charCodeAt(i) === EXCLAMATION || tag.charCodeAt(i) === QUESTION) return null;\n if (!isAsciiLetter(tag.charCodeAt(i))) return null;\n const nameAt = i;\n while (i < tag.length && isTagNameUnit(tag.charCodeAt(i))) i += 1;\n const selfClosing = tag.charCodeAt(tag.length - 2) === SLASH;\n return { name: tag.slice(nameAt, i), closing, selfClosing };\n}\n\n/**\n * modes.md 3.7: raw HTML is \"handed to the html skip list of 3.6\". Inline raw HTML reaches the\n * tokenizer as isolated tags with ordinary markdown content between them, so honouring the\n * subtree rule means tracking which skipped element is currently open. JSX names are compared\n * case-sensitively (`<Code>` is a component, `<code>` is an element); HTML names are not.\n */\nfunction updateElementStack(stack: string[], tag: string, caseSensitive: boolean): void {\n const parsed = readTag(tag);\n if (parsed === null) return;\n const name = caseSensitive ? parsed.name : asciiLower(parsed.name);\n if (parsed.closing) {\n if (stack[stack.length - 1] === name) stack.pop();\n return;\n }\n if (!parsed.selfClosing && isSkippedElement(name)) stack.push(name);\n}\n\nfunction tokenize(source: string, extensions: readonly Extension[]): Event[] {\n return postprocess(\n parse({ extensions: [...extensions] })\n .document()\n .write(preprocess()(source, null, true)),\n );\n}\n\n/**\n * modes.md 3.7.1. The dialect is the caller's, never detected: `\"commonmark\"` is CommonMark 0.31\n * plus GFM, `\"mdx\"` is the same minus indented code blocks and `<…>` autolinks, plus JSX and\n * `{…}` expression containers. Both enable frontmatter and GFM, which 3.7.2 makes normative —\n * §4's promise that table alignment rows survive is empty unless tables are recognised at all.\n */\nexport function resolveDialect(dialect: Dialect | undefined): Dialect {\n if (dialect === \"commonmark\" || dialect === \"mdx\") return dialect;\n if (dialect === undefined) {\n throw new PolytypoError(\n \"POLYTYPO_INVALID_DIALECT\",\n 'Mode \"markdown\" requires a dialect. Expected \"commonmark\" or \"mdx\"; there is no default.',\n );\n }\n throw new PolytypoError(\n \"POLYTYPO_INVALID_DIALECT\",\n `Unknown dialect \"${String(dialect)}\". Expected \"commonmark\" or \"mdx\".`,\n );\n}\n\n// modes.md 3.7.3 names both frontmatter delimiters, `---` (YAML) and `+++` (TOML), and skips\n// either whole. micromark's default matter is YAML alone, so both must be asked for by name: with\n// the default, a `+++` block parses as prose and the machine-read fields inside it get typeset.\nconst FRONTMATTER_MATTERS = [\"yaml\", \"toml\"] as const;\n\nexport function extensionsFor(dialect: Dialect): Extension[] {\n const fm = frontmatter([...FRONTMATTER_MATTERS]);\n return dialect === \"mdx\" ? [fm, gfm(), mdxjs()] : [fm, gfm()];\n}\n\n// modes.md 3.7.3a, spec 1.8.0: where the frontmatter block begins and ends, decided by the scan\n// below and by nothing else. Four runtimes reached the construct through four parsers and got four\n// answers — two of them typeset `date: \"2026-09-26\"` over one trailing space on a fence — so the\n// section makes this scan normative and a parser's opinion a thing measured against it. Locating\n// the block here is also what lets `frontmatterSpans` stop parsing the document a second time\n// (polytypo/polytypo#59).\nconst YAML_DELIMITER = \"---\";\nconst TOML_DELIMITER = \"+++\";\n\nconst TAB = 0x09;\nconst LF = 0x0a;\nconst CR = 0x0d;\nconst SPACE = 0x20;\nconst BOM = 0xfeff;\n\ninterface SourceLine {\n /** Index just past the line's content: the terminator, or the end of the source. */\n readonly end: number;\n /** Index the next line starts at, or the end of the source when this line is the last. */\n readonly next: number;\n}\n\n/**\n * 3.7.3a step 5: **CommonMark's** line, not 3.8.4's. A line ends at U+000A, at a U+000D that is\n * not followed by U+000A, or at the end of input, and the terminator is never part of the line.\n * The block is a Markdown construct and ends its lines the way the language around it does; the\n * YAML inside it keeps 3.8.4's LF-only model (`./yaml.js`), and the two are different on purpose —\n * harmonising them silently changes one of them.\n */\nfunction markdownLineFrom(source: string, start: number): SourceLine {\n for (let i = start; i < source.length; i += 1) {\n const unit = source.charCodeAt(i);\n if (unit === LF) return { end: i, next: i + 1 };\n if (unit === CR) return { end: i, next: source.charCodeAt(i + 1) === LF ? i + 2 : i + 1 };\n }\n return { end: source.length, next: source.length };\n}\n\n/** 3.7.3a steps 2 and 3: what a delimiter line may carry after the delimiter, and nothing else. */\nfunction isBlankRun(source: string, from: number, to: number): boolean {\n for (let i = from; i < to; i += 1) {\n const unit = source.charCodeAt(i);\n if (unit !== SPACE && unit !== TAB) return false;\n }\n return true;\n}\n\n/**\n * A delimiter line: the delimiter at the line's first code point — indentation disqualifies it —\n * then U+0020 and U+0009 to the end of the line. A fourth delimiter character is not whitespace,\n * so `----` is neither an opener nor a closer.\n */\nfunction isDelimiterLine(\n source: string,\n start: number,\n line: SourceLine,\n delimiter: string,\n): boolean {\n return (\n source.startsWith(delimiter, start) && isBlankRun(source, start + delimiter.length, line.end)\n );\n}\n\n/** modes.md 3.7.3a. The frontmatter block's extent, in source offsets. */\nexport interface FrontmatterBlock {\n /** Which matter the delimiter names. TOML yields no spans either way (3.7.4). */\n readonly matter: \"yaml\" | \"toml\";\n /** First code point of the opening delimiter: 0, or 1 past a single leading U+FEFF (step 1). */\n readonly start: number;\n /**\n * End of the closing delimiter line's content — its trailing whitespace included, its terminator\n * excluded.\n */\n readonly end: number;\n /** 3.7.4: the code point after the opening delimiter line's terminator. */\n readonly contentStart: number;\n /** 3.7.4: the code point that begins the closing delimiter line. */\n readonly contentEnd: number;\n}\n\n/**\n * modes.md 3.7.3a, the whole of it. Offsets are UTF-16 indices, like every other mode in this\n * runtime; every code point the scan tests is ASCII or U+FEFF, so indexing by code unit and\n * indexing by code point agree on all of them.\n */\nexport function locateFrontmatter(source: string): FrontmatterBlock | null {\n // Step 1: the document must begin with the delimiter, with a single leading U+FEFF stepped over\n // first — it is a byte-order mark, not content, and reading it as content would deny the block\n // to every file some Windows editors produce.\n const start = source.charCodeAt(0) === BOM ? 1 : 0;\n const matter = source.startsWith(YAML_DELIMITER, start)\n ? \"yaml\"\n : source.startsWith(TOML_DELIMITER, start)\n ? \"toml\"\n : null;\n if (matter === null) return null;\n const delimiter = matter === \"yaml\" ? YAML_DELIMITER : TOML_DELIMITER;\n\n // Step 2: the rest of the opening line may be U+0020 and U+0009 and nothing else.\n const opener = markdownLineFrom(source, start);\n if (!isBlankRun(source, start + delimiter.length, opener.end)) return null;\n\n // Step 3: the closing line is the first LATER line of the same delimiter. Step 4: with none,\n // there is no block, and the opening delimiter is whatever the dialect makes of it.\n const contentStart = opener.next;\n for (let at = contentStart; at < source.length;) {\n const line = markdownLineFrom(source, at);\n if (isDelimiterLine(source, at, line, delimiter)) {\n return { matter, start, end: line.end, contentStart, contentEnd: at };\n }\n at = line.next;\n }\n return null;\n}\n\n/**\n * modes.md 3.7.3a: **the parser is handed the block masked out** — the located block, both\n * delimiter lines included and step 1's leading U+FEFF with them, replaced by U+0020, with line\n * terminators kept as they are. The mark is in that list because without it the first line is not\n * blank: no parser is required to strip it, and a runtime masking the block alone emits a span\n * for it.\n *\n * The invariant is that the masked source stay **positionally aligned with the original in the unit\n * this runtime maps parser offsets back through**, which here is UTF-16 code units: micromark's\n * offsets are handed straight to `Span`, so one U+0020 per code unit is what JS owes. An astral\n * character therefore masks to two spaces, not one. It is deliberately not stated as a count of\n * code points — a runtime that converts offsets against the masked source first owes code-point\n * alignment instead, and both are conformant.\n *\n * Suppressing spans inside the block's range instead is not equivalent, and the runtime that did\n * that is measured in 3.7.3a: a fence inside a metadata value pairs with the body's own, and the\n * body's code block and its prose swap roles — or, with nothing to pair with, swallows the rest of\n * the document. The damage is in what the parser concluded, so no span-level check can see it.\n *\n * Masking is also what keeps 3.7.4's two text units disjoint now that the extent is the scan's and\n * not the parser's: the body cannot emit a span inside a block the parser was never shown.\n */\nfunction maskFrontmatter(source: string, block: FrontmatterBlock | null): string {\n if (block === null) return source;\n let masked = \"\";\n for (let i = 0; i < block.end; i += 1) {\n const unit = source.charCodeAt(i);\n masked += unit === LF || unit === CR ? source[i] : \" \";\n }\n return masked + source.slice(block.end);\n}\n\n/**\n * modes.md 3.7. The body's spans. The document reaches the parser with its frontmatter block\n * masked out (3.7.3a), so the block is skipped because the scan located it, not because an\n * extension recognised it — and `text` below is what the token offsets refer to.\n *\n * Two corrections sit between `text` and the spans this returns:\n *\n * - **`shift`**: micromark's `preprocess` drops a leading U+FEFF and then reports offsets against\n * the shortened string, so every span in a document carrying one lands a code unit to the left —\n * which ate the last code point of every span and left\n * `en-us-markdown-commonmark-byte-order-mark-no-block` unconverted in full. The mark is removed\n * here instead, and the difference added back. A document whose block was located needs no such\n * correction, because 3.7.3a masks the mark along with the block;\n * - **the no-span rule** (3.7.3a): no span may lie inside the block whatever the parser made of the\n * masked text. A span straddling the block's end is **clipped** to the part outside it, and\n * dropped only when nothing is left, so body prose past the block cannot be lost to a parser's\n * mistake\n * about where the block ended. Masking is what makes this inert for micromark — measured over\n * nineteen block shapes in both dialects, it emits nothing inside a masked block — and the spec\n * states the rule separately because it is not true of every parser.\n */\nexport function markdownSpans(source: string, dialect: Dialect): Span[] {\n const block = locateFrontmatter(source);\n const masked = maskFrontmatter(source, block);\n const shift = masked.charCodeAt(0) === BOM ? 1 : 0;\n const text = shift === 0 ? masked : masked.slice(shift);\n const events = wrapParserErrors(dialect, () => tokenize(text, extensionsFor(dialect)));\n const spans: Span[] = [];\n const elementStack: string[] = [];\n let skipDepth = 0;\n\n for (const [kind, token] of events) {\n const type = token.type;\n\n if (SKIPPED_TOKEN_TYPES.has(type)) {\n skipDepth += kind === \"enter\" ? 1 : -1;\n continue;\n }\n\n if (RAW_TAG_TOKEN_TYPES.has(type)) {\n if (kind === \"enter\") {\n updateElementStack(\n elementStack,\n text.slice(token.start.offset, token.end.offset),\n type !== \"htmlText\",\n );\n }\n skipDepth += kind === \"enter\" ? 1 : -1;\n continue;\n }\n\n // An HTML block is handed to the `html` extractor rather than skipped whole, so that the\n // prose inside `<div>…</div>` is typeset while the markup is not.\n if (type === \"htmlFlow\") {\n if (kind === \"enter\" && skipDepth === 0 && elementStack.length === 0) {\n for (const span of htmlFragmentSpans(\n text.slice(token.start.offset, token.end.offset),\n token.start.offset + shift,\n )) {\n spans.push(span);\n }\n }\n skipDepth += kind === \"enter\" ? 1 : -1;\n continue;\n }\n\n if (kind === \"enter\" && type === \"data\" && skipDepth === 0 && elementStack.length === 0) {\n spans.push({ start: token.start.offset + shift, end: token.end.offset + shift });\n }\n }\n\n if (block === null) return spans;\n return spans.flatMap((span) => {\n if (span.start >= block.end) return [span];\n if (span.end <= block.end) return [];\n return [{ start: block.end, end: span.end }];\n });\n}\n\n/**\n * modes.md 3.7.4: **a content line containing a U+000D not followed by U+000A yields no spans**,\n * \"exactly as 3.8.4 step 1 already declines a line containing U+0009\". The two line models meet in\n * the block content and do not compose — 3.7.3a step 5 finds a block in a lone-U+000D document, and\n * 3.8.4's LF-only scan then reads the whole of it as one line. Measured, letting it through is not\n * merely inert: marks pair across what were two mapping lines, an unlisted line inside the listed\n * key's scalar takes `fr`'s spacing, and the U+000D itself lands inside a span — which 3.8.4\n * forbids.\n *\n * The decline **drops the spans the content scan produced for that line and does not alter the\n * content the scan is given**. Substituting each lone U+000D for a character 3.8.4 already\n * declines is the shortcut three ports reached for, this one included, and it is measured not\n * equivalent: the substitution moves the character onto a line of its own and can end a value run.\n * Both shapes are pinned as fixtures, and both are decided by what `yaml` mode does with the same\n * characters, since 3.7.4 claims 3.8's scan applies verbatim:\n *\n * - `title: a \"b\"\\nslug: c \"d\"\\n\\r` — the content-final U+000D is a blank line joining `slug`'s\n * value run, so 3.8.6's continuation bail declines `slug`. As a U+0009 it is a line with a tab\n * in it, not a blank one, the run ends and `slug` converts. `yaml` mode converts `title` only,\n * in both shipped runtimes measured;\n * - `summary: a\\rb\\n title: c -- d\\n` — the indented line is inside `summary`'s value run, so\n * `title` is not a key at all. Substitution ends the run and invents one.\n *\n * **The window runs to the start of the next line, not to the end of this one**, because 3.8.4's\n * own splitter treats a trailing U+000D as a terminator without a U+000A after it — so a block\n * whose single line ends in one looks clean if the terminator is excluded.\n */\nfunction declinedContentRanges(content: string): readonly Span[] {\n const declined: Span[] = [];\n let start = 0;\n while (start < content.length) {\n const lf = content.indexOf(\"\\n\", start);\n const next = lf === -1 ? content.length : lf + 1;\n for (let i = start; i < next; i += 1) {\n if (content.charCodeAt(i) === CR && content.charCodeAt(i + 1) !== LF) {\n declined.push({ start, end: next });\n break;\n }\n }\n start = next;\n }\n return declined;\n}\n\n/**\n * modes.md 3.7.4, spec 1.7.0. The frontmatter block's own spans, which form a **second text\n * unit**: the pipeline runs over them separately from the body's, so an unbalanced mark in a\n * metadata field can never pair with one in the first paragraph and this option cannot change a\n * byte outside the block.\n *\n * The block is located by `locateFrontmatter` (3.7.3a, spec 1.8.0) rather than by a second parse\n * of the document, which is both what polytypo/polytypo#59 reported and, since 1.8.0, the wrong\n * authority: the scan owns the extent and a parser is measured against it.\n *\n * Spans inside it are taken by the scan of modes.md 3.8 — frontmatter *is* YAML, and specifying it\n * twice is how two implementations of one grammar drift — with `frontmatterKeys` as step 8's key\n * predicate.\n *\n * A TOML block yields nothing, with the option or without it: TOML's quoting is a second grammar\n * this scan does not claim (modes.md §7.13). So does any content line carrying a lone U+000D — see\n * `declinedContentRanges`, which filters what the scan produced rather than changing what it reads.\n */\nexport function frontmatterSpans(source: string, frontmatterKeys: readonly string[]): Span[] {\n if (frontmatterKeys.length === 0) return [];\n const block = locateFrontmatter(source);\n if (block === null || block.matter === \"toml\") return [];\n\n const { contentStart, contentEnd } = block;\n const content = source.slice(contentStart, contentEnd);\n const declined = declinedContentRanges(content);\n\n return (\n yamlSpans(content, frontmatterKeys)\n // 3.7.4: a span reaching a declined position is dropped whole rather than trimmed.\n .filter((span) => !declined.some((range) => span.start < range.end && range.start < span.end))\n .map((span) => ({ start: span.start + contentStart, end: span.end + contentStart }))\n );\n}\n","import { frontmatterSpans, markdownSpans, resolveDialect } from \"../modes/markdown.js\";\nimport type { Dialect, Options } from \"../types.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { resolveNarrowTarget } from \"./narrow-target.js\";\nimport { planRules } from \"./rule-runner.js\";\nimport { resolveFrontmatterKeys } from \"./yaml-keys.js\";\nimport { analyzeOverUnits, runOverUnits } from \"./span-runner.js\";\nimport type { Change } from \"./origin.js\";\nimport type { Span } from \"../modes/spans.js\";\n\n/**\n * `markdown` mode only. Imports the Micromark/MDX stack and `parse5` (via `../modes/markdown.js`\n * importing `../modes/html.js` for normative embedded-HTML handling, modes.md 3.7) — both are\n * legitimately reachable from `polytypo/markdown` (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1).\n *\n * Validation order — `planRules`, then `getLocaleData`, then `resolveDialect`/parsing — mirrors\n * the pre-Stage-5 aggregate `runPipeline` exactly: an unknown-rule error wins over an\n * unknown-locale error, which wins over a missing/invalid dialect, which wins over a parse\n * failure. All four are public, tested behaviour this refactor was not authorised to change.\n */\nexport function runMarkdownPipeline(input: string, options: Partial<Options>): string {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const dialect = resolveDialect(options.dialect);\n const frontmatterKeys = resolveFrontmatterKeys(options.frontmatterKeys);\n const units = unitsOf(input, dialect, frontmatterKeys);\n return runOverUnits(input, units, planned, locale, \"markdown\", narrowTarget);\n}\n\n/**\n * modes.md 3.7.4: the body, and — only when the caller named frontmatter keys — the frontmatter\n * block as a second text unit. Without the option this is exactly the single unit every document\n * had before spec 1.7.0, which is why no released output can move.\n *\n * The two units must be **disjoint** — 3.7.4: \"no source position can belong to both units\". Since\n * spec 1.8.0 that is 3.7.3a's masking rule doing the work rather than a shared parser: the body is\n * read from a document whose block is blanked out, so it cannot emit a span the frontmatter unit\n * also claims, whatever the parser would have made of the block's characters.\n */\nfunction unitsOf(\n input: string,\n dialect: Dialect,\n frontmatterKeys: readonly string[] | undefined,\n): Span[][] {\n const body = markdownSpans(input, dialect);\n if (frontmatterKeys === undefined) return [body];\n return [frontmatterSpans(input, frontmatterKeys), body];\n}\n\n/** analyze.md §1, `markdown` mode. Dialect validation happens here exactly as it does for\n * `runMarkdownPipeline`, so an absent dialect throws POLYTYPO_INVALID_DIALECT from `analyze`\n * too (analyze.md §4 A1). */\nexport function analyzeMarkdownPipeline(input: string, options: Partial<Options>): Change[] {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const dialect = resolveDialect(options.dialect);\n const frontmatterKeys = resolveFrontmatterKeys(options.frontmatterKeys);\n return analyzeOverUnits(\n input,\n unitsOf(input, dialect, frontmatterKeys),\n planned,\n locale,\n \"markdown\",\n narrowTarget,\n );\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-HB4TT6IE.cjs","../src/modes/markdown.ts","../src/engine/markdown-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACpBA,sCAA+C;AAC/C,gFAA4B;AAC5B,gEAAoB;AACpB,oEAAsB;AAiBtB,IAAM,oBAAA,kBAA2C,IAAI,GAAA,CAAI;AAAA;AAAA,EAEvD,YAAA;AAAA,EACA,cAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,UAAA;AAAA,EACA,iBAAA;AAAA;AAAA;AAAA,EAGA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA;AAAA;AAAA;AAAA,EAIA,mBAAA;AAAA,EACA,mBAAA;AAAA,EACA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,MAAA;AAAA,EACA;AACF,CAAC,CAAA;AAGD,IAAM,oBAAA,kBAA2C,IAAI,GAAA,CAAI;AAAA,EACvD,UAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,UAAA,EAAY,EAAA;AAClB,IAAM,aAAA,EAAe,EAAA;AACrB,IAAM,MAAA,EAAQ,EAAA;AACd,IAAM,YAAA,EAAc,EAAA;AACpB,IAAM,SAAA,EAAW,EAAA;AAEjB,SAAS,aAAA,CAAc,IAAA,EAAuB;AAC5C,EAAA,OAAQ,KAAA,GAAQ,GAAA,GAAQ,KAAA,GAAQ,IAAA,GAAU,KAAA,GAAQ,GAAA,GAAQ,KAAA,GAAQ,EAAA;AACpE;AAEA,SAAS,aAAA,CAAc,IAAA,EAAuB;AAI5C,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port { frontmatter } from \"micromark-extension-frontmatter\";\nimport { gfm } from \"micromark-extension-gfm\";\nimport { mdxjs } from \"micromark-extension-mdxjs\";\nimport type { Event, Extension } from \"micromark-util-types\";\nimport { PolytypoError } from \"../errors.js\";\nimport type { Dialect } from \"../types.js\";\nimport { htmlFragmentSpans, isSkippedElement } from \"./html.js\";\nimport { yamlSpans } from \"./yaml.js\";\nimport { wrapParserErrors } from \"./parse-error.js\";\nimport type { Span } from \"./spans.js\";\n\n/**\n * spec/rules/modes.md 3.7. Each entry is skipped **whole**, including anything that looks\n * processable inside it. The complement is not enumerated: a span is emitted only for a\n * micromark `data` token, which is the tokenizer's own name for \"literal content\", so list\n * markers, emphasis delimiters, heading sequences, table padding, line endings, hard-break\n * spaces, character escapes and character references are outside every span by construction\n * rather than by a second list that could drift from the first.\n */\nconst SKIPPED_TOKEN_TYPES: ReadonlySet<string> = new Set([\n // fenced code blocks (including the info string and the fences) and indented code blocks\n \"codeFenced\",\n \"codeIndented\",\n // inline code spans, including the backticks\n \"codeText\",\n // autolinks `<https://…>`, and GFM's bare-URL form\n \"autolink\",\n \"literalAutolink\",\n // link and image destinations and titles; the definition line of a reference link. The link\n // *text* is a `labelText`, which is not skipped.\n \"resource\",\n \"reference\",\n \"definition\",\n // MDX: expression containers in full, and every JSX attribute — the whole tag is skipped, so\n // attributes never surface. JSX element *children* sit outside the tag tokens and are\n // processable.\n \"mdxFlowExpression\",\n \"mdxTextExpression\",\n \"mdxjsEsm\",\n // modes.md 3.7.3, and it matters: without it the second `---` of a YAML block reads as a setext\n // underline, `title: Une note` becomes a paragraph, and `fr` puts a narrow no-break space in\n // front of the colon of a machine-read metadata field. Covered by conformance fixtures\n // en-us-markdown-{commonmark,mdx}-frontmatter, fr-markdown-{commonmark,mdx}-frontmatter-nbsp,\n // en-us-markdown-commonmark-frontmatter-toml and -frontmatter-unterminated.\n //\n // These are `micromark-extension-frontmatter`'s own token types, one per matter. An earlier\n // revision listed `\"frontmatter\"`, which the extension never emits: the block was skipped only\n // because its content arrives as `yamlValue`/`tomlValue` rather than `data`, so the entry that\n // was supposed to do the work did none.\n //\n // Since spec 1.8.0 the skip is 3.7.3a's mask, not this: a located block reaches the parser as\n // blanks, so the extension cannot see one. The extension stays because it is measured inert —\n // `tests/modes/frontmatter-keys.test.ts` asserts over every edge document that it never finds\n // a block the scan denies — and because removing a working locator that costs nothing would be\n // a change with no problem behind it. What the test would catch is the case that would matter:\n // the two disagreeing about whether a document has a block at all.\n \"yaml\",\n \"toml\",\n]);\n\n/** Token types whose enter/exit also maintains the skipped-element stack. */\nconst RAW_TAG_TOKEN_TYPES: ReadonlySet<string> = new Set([\n \"htmlText\",\n \"mdxJsxTextTag\",\n \"mdxJsxFlowTag\",\n]);\n\nconst LESS_THAN = 0x3c;\nconst GREATER_THAN = 0x3e;\nconst SLASH = 0x2f;\nconst EXCLAMATION = 0x21;\nconst QUESTION = 0x3f;\n\nfunction isAsciiLetter(unit: number): boolean {\n return (unit >= 0x61 && unit <= 0x7a) || (unit >= 0x41 && unit <= 0x5a);\n}\n\nfunction isTagNameUnit(unit: number): boolean {\n // Deliberately permissive: anything that is not a delimiter belongs to the name. Custom\n // elements (`my-callout`) and member expressions (`Foo.Bar`) must come out whole so that they\n // fail the skip-list membership test rather than being truncated into something that passes.\n return (\n unit !== GREATER_THAN &&\n unit !== SLASH &&\n unit !== 0x20 &&\n unit !== 0x09 &&\n unit !== 0x0a &&\n unit !== 0x0d\n );\n}\n\n/** ASCII-only, because HTML tag names are ASCII case-insensitive and `toLowerCase()` is not. */\nfunction asciiLower(value: string): string {\n let out = \"\";\n for (let i = 0; i < value.length; i += 1) {\n const unit = value.charCodeAt(i);\n out += unit >= 0x41 && unit <= 0x5a ? String.fromCharCode(unit + 0x20) : value[i];\n }\n return out;\n}\n\ninterface RawTag {\n readonly name: string;\n readonly closing: boolean;\n readonly selfClosing: boolean;\n}\n\nfunction readTag(tag: string): RawTag | null {\n if (tag.charCodeAt(0) !== LESS_THAN) return null;\n let i = 1;\n const closing = tag.charCodeAt(i) === SLASH;\n if (closing) i += 1;\n // Comments, declarations and processing instructions carry no element name.\n if (tag.charCodeAt(i) === EXCLAMATION || tag.charCodeAt(i) === QUESTION) return null;\n if (!isAsciiLetter(tag.charCodeAt(i))) return null;\n const nameAt = i;\n while (i < tag.length && isTagNameUnit(tag.charCodeAt(i))) i += 1;\n const selfClosing = tag.charCodeAt(tag.length - 2) === SLASH;\n return { name: tag.slice(nameAt, i), closing, selfClosing };\n}\n\n/**\n * modes.md 3.7: raw HTML is \"handed to the html skip list of 3.6\". Inline raw HTML reaches the\n * tokenizer as isolated tags with ordinary markdown content between them, so honouring the\n * subtree rule means tracking which skipped element is currently open. JSX names are compared\n * case-sensitively (`<Code>` is a component, `<code>` is an element); HTML names are not.\n */\nfunction updateElementStack(stack: string[], tag: string, caseSensitive: boolean): void {\n const parsed = readTag(tag);\n if (parsed === null) return;\n const name = caseSensitive ? parsed.name : asciiLower(parsed.name);\n if (parsed.closing) {\n if (stack[stack.length - 1] === name) stack.pop();\n return;\n }\n if (!parsed.selfClosing && isSkippedElement(name)) stack.push(name);\n}\n\nfunction tokenize(source: string, extensions: readonly Extension[]): Event[] {\n return postprocess(\n parse({ extensions: [...extensions] })\n .document()\n .write(preprocess()(source, null, true)),\n );\n}\n\n/**\n * modes.md 3.7.1. The dialect is the caller's, never detected: `\"commonmark\"` is CommonMark 0.31\n * plus GFM, `\"mdx\"` is the same minus indented code blocks and `<…>` autolinks, plus JSX and\n * `{…}` expression containers. Both enable frontmatter and GFM, which 3.7.2 makes normative —\n * §4's promise that table alignment rows survive is empty unless tables are recognised at all.\n */\nexport function resolveDialect(dialect: Dialect | undefined): Dialect {\n if (dialect === \"commonmark\" || dialect === \"mdx\") return dialect;\n if (dialect === undefined) {\n throw new PolytypoError(\n \"POLYTYPO_INVALID_DIALECT\",\n 'Mode \"markdown\" requires a dialect. Expected \"commonmark\" or \"mdx\"; there is no default.',\n );\n }\n throw new PolytypoError(\n \"POLYTYPO_INVALID_DIALECT\",\n `Unknown dialect \"${String(dialect)}\". Expected \"commonmark\" or \"mdx\".`,\n );\n}\n\n// modes.md 3.7.3 names both frontmatter delimiters, `---` (YAML) and `+++` (TOML), and skips\n// either whole. micromark's default matter is YAML alone, so both must be asked for by name: with\n// the default, a `+++` block parses as prose and the machine-read fields inside it get typeset.\nconst FRONTMATTER_MATTERS = [\"yaml\", \"toml\"] as const;\n\nexport function extensionsFor(dialect: Dialect): Extension[] {\n const fm = frontmatter([...FRONTMATTER_MATTERS]);\n return dialect === \"mdx\" ? [fm, gfm(), mdxjs()] : [fm, gfm()];\n}\n\n// modes.md 3.7.3a, spec 1.8.0: where the frontmatter block begins and ends, decided by the scan\n// below and by nothing else. Four runtimes reached the construct through four parsers and got four\n// answers — two of them typeset `date: \"2026-09-26\"` over one trailing space on a fence — so the\n// section makes this scan normative and a parser's opinion a thing measured against it. Locating\n// the block here is also what lets `frontmatterSpans` stop parsing the document a second time\n// (polytypo/polytypo#59).\nconst YAML_DELIMITER = \"---\";\nconst TOML_DELIMITER = \"+++\";\n\nconst TAB = 0x09;\nconst LF = 0x0a;\nconst CR = 0x0d;\nconst SPACE = 0x20;\nconst BOM = 0xfeff;\n\ninterface SourceLine {\n /** Index just past the line's content: the terminator, or the end of the source. */\n readonly end: number;\n /** Index the next line starts at, or the end of the source when this line is the last. */\n readonly next: number;\n}\n\n/**\n * 3.7.3a step 5: **CommonMark's** line, not 3.8.4's. A line ends at U+000A, at a U+000D that is\n * not followed by U+000A, or at the end of input, and the terminator is never part of the line.\n * The block is a Markdown construct and ends its lines the way the language around it does; the\n * YAML inside it keeps 3.8.4's LF-only model (`./yaml.js`), and the two are different on purpose —\n * harmonising them silently changes one of them.\n */\nfunction markdownLineFrom(source: string, start: number): SourceLine {\n for (let i = start; i < source.length; i += 1) {\n const unit = source.charCodeAt(i);\n if (unit === LF) return { end: i, next: i + 1 };\n if (unit === CR) return { end: i, next: source.charCodeAt(i + 1) === LF ? i + 2 : i + 1 };\n }\n return { end: source.length, next: source.length };\n}\n\n/** 3.7.3a steps 2 and 3: what a delimiter line may carry after the delimiter, and nothing else. */\nfunction isBlankRun(source: string, from: number, to: number): boolean {\n for (let i = from; i < to; i += 1) {\n const unit = source.charCodeAt(i);\n if (unit !== SPACE && unit !== TAB) return false;\n }\n return true;\n}\n\n/**\n * A delimiter line: the delimiter at the line's first code point — indentation disqualifies it —\n * then U+0020 and U+0009 to the end of the line. A fourth delimiter character is not whitespace,\n * so `----` is neither an opener nor a closer.\n */\nfunction isDelimiterLine(\n source: string,\n start: number,\n line: SourceLine,\n delimiter: string,\n): boolean {\n return (\n source.startsWith(delimiter, start) && isBlankRun(source, start + delimiter.length, line.end)\n );\n}\n\n/** modes.md 3.7.3a. The frontmatter block's extent, in source offsets. */\nexport interface FrontmatterBlock {\n /** Which matter the delimiter names. TOML yields no spans either way (3.7.4). */\n readonly matter: \"yaml\" | \"toml\";\n /** First code point of the opening delimiter: 0, or 1 past a single leading U+FEFF (step 1). */\n readonly start: number;\n /**\n * End of the closing delimiter line's content — its trailing whitespace included, its terminator\n * excluded.\n */\n readonly end: number;\n /** 3.7.4: the code point after the opening delimiter line's terminator. */\n readonly contentStart: number;\n /** 3.7.4: the code point that begins the closing delimiter line. */\n readonly contentEnd: number;\n}\n\n/**\n * modes.md 3.7.3a, the whole of it. Offsets are UTF-16 indices, like every other mode in this\n * runtime; every code point the scan tests is ASCII or U+FEFF, so indexing by code unit and\n * indexing by code point agree on all of them.\n */\nexport function locateFrontmatter(source: string): FrontmatterBlock | null {\n // Step 1: the document must begin with the delimiter, with a single leading U+FEFF stepped over\n // first — it is a byte-order mark, not content, and reading it as content would deny the block\n // to every file some Windows editors produce.\n const start = source.charCodeAt(0) === BOM ? 1 : 0;\n const matter = source.startsWith(YAML_DELIMITER, start)\n ? \"yaml\"\n : source.startsWith(TOML_DELIMITER, start)\n ? \"toml\"\n : null;\n if (matter === null) return null;\n const delimiter = matter === \"yaml\" ? YAML_DELIMITER : TOML_DELIMITER;\n\n // Step 2: the rest of the opening line may be U+0020 and U+0009 and nothing else.\n const opener = markdownLineFrom(source, start);\n if (!isBlankRun(source, start + delimiter.length, opener.end)) return null;\n\n // Step 3: the closing line is the first LATER line of the same delimiter. Step 4: with none,\n // there is no block, and the opening delimiter is whatever the dialect makes of it.\n const contentStart = opener.next;\n for (let at = contentStart; at < source.length;) {\n const line = markdownLineFrom(source, at);\n if (isDelimiterLine(source, at, line, delimiter)) {\n return { matter, start, end: line.end, contentStart, contentEnd: at };\n }\n at = line.next;\n }\n return null;\n}\n\n/**\n * modes.md 3.7.3a: **the parser is handed the block masked out** — the located block, both\n * delimiter lines included and step 1's leading U+FEFF with them, replaced by U+0020, with line\n * terminators kept as they are. The mark is in that list because without it the first line is not\n * blank: no parser is required to strip it, and a runtime masking the block alone emits a span\n * for it.\n *\n * The invariant is that the masked source stay **positionally aligned with the original in the unit\n * this runtime maps parser offsets back through**, which here is UTF-16 code units: micromark's\n * offsets are handed straight to `Span`, so one U+0020 per code unit is what JS owes. An astral\n * character therefore masks to two spaces, not one. It is deliberately not stated as a count of\n * code points — a runtime that converts offsets against the masked source first owes code-point\n * alignment instead, and both are conformant.\n *\n * Suppressing spans inside the block's range instead is not equivalent, and the runtime that did\n * that is measured in 3.7.3a: a fence inside a metadata value pairs with the body's own, and the\n * body's code block and its prose swap roles — or, with nothing to pair with, swallows the rest of\n * the document. The damage is in what the parser concluded, so no span-level check can see it.\n *\n * Masking is also what keeps 3.7.4's two text units disjoint now that the extent is the scan's and\n * not the parser's: the body cannot emit a span inside a block the parser was never shown.\n */\nfunction maskFrontmatter(source: string, block: FrontmatterBlock | null): string {\n if (block === null) return source;\n let masked = \"\";\n for (let i = 0; i < block.end; i += 1) {\n const unit = source.charCodeAt(i);\n masked += unit === LF || unit === CR ? source[i] : \" \";\n }\n return masked + source.slice(block.end);\n}\n\n/**\n * modes.md 3.7. The body's spans. The document reaches the parser with its frontmatter block\n * masked out (3.7.3a), so the block is skipped because the scan located it, not because an\n * extension recognised it — and `text` below is what the token offsets refer to.\n *\n * Two corrections sit between `text` and the spans this returns:\n *\n * - **`shift`**: micromark's `preprocess` drops a leading U+FEFF and then reports offsets against\n * the shortened string, so every span in a document carrying one lands a code unit to the left —\n * which ate the last code point of every span and left\n * `en-us-markdown-commonmark-byte-order-mark-no-block` unconverted in full. The mark is removed\n * here instead, and the difference added back. A document whose block was located needs no such\n * correction, because 3.7.3a masks the mark along with the block;\n * - **the no-span rule** (3.7.3a): no span may lie inside the block whatever the parser made of the\n * masked text. A span straddling the block's end is **clipped** to the part outside it, and\n * dropped only when nothing is left, so body prose past the block cannot be lost to a parser's\n * mistake\n * about where the block ended. Masking is what makes this inert for micromark — measured over\n * nineteen block shapes in both dialects, it emits nothing inside a masked block — and the spec\n * states the rule separately because it is not true of every parser.\n */\nexport function markdownSpans(source: string, dialect: Dialect): Span[] {\n const block = locateFrontmatter(source);\n const masked = maskFrontmatter(source, block);\n const shift = masked.charCodeAt(0) === BOM ? 1 : 0;\n const text = shift === 0 ? masked : masked.slice(shift);\n const events = wrapParserErrors(dialect, () => tokenize(text, extensionsFor(dialect)));\n const spans: Span[] = [];\n const elementStack: string[] = [];\n let skipDepth = 0;\n\n for (const [kind, token] of events) {\n const type = token.type;\n\n if (SKIPPED_TOKEN_TYPES.has(type)) {\n skipDepth += kind === \"enter\" ? 1 : -1;\n continue;\n }\n\n if (RAW_TAG_TOKEN_TYPES.has(type)) {\n if (kind === \"enter\") {\n updateElementStack(\n elementStack,\n text.slice(token.start.offset, token.end.offset),\n type !== \"htmlText\",\n );\n }\n skipDepth += kind === \"enter\" ? 1 : -1;\n continue;\n }\n\n // An HTML block is handed to the `html` extractor rather than skipped whole, so that the\n // prose inside `<div>…</div>` is typeset while the markup is not.\n if (type === \"htmlFlow\") {\n if (kind === \"enter\" && skipDepth === 0 && elementStack.length === 0) {\n for (const span of htmlFragmentSpans(\n text.slice(token.start.offset, token.end.offset),\n token.start.offset + shift,\n )) {\n spans.push(span);\n }\n }\n skipDepth += kind === \"enter\" ? 1 : -1;\n continue;\n }\n\n if (kind === \"enter\" && type === \"data\" && skipDepth === 0 && elementStack.length === 0) {\n spans.push({ start: token.start.offset + shift, end: token.end.offset + shift });\n }\n }\n\n if (block === null) return spans;\n return spans.flatMap((span) => {\n if (span.start >= block.end) return [span];\n if (span.end <= block.end) return [];\n return [{ start: block.end, end: span.end }];\n });\n}\n\n/**\n * modes.md 3.7.4: **a content line containing a U+000D not followed by U+000A yields no spans**,\n * \"exactly as 3.8.4 step 1 already declines a line containing U+0009\". The two line models meet in\n * the block content and do not compose — 3.7.3a step 5 finds a block in a lone-U+000D document, and\n * 3.8.4's LF-only scan then reads the whole of it as one line. Measured, letting it through is not\n * merely inert: marks pair across what were two mapping lines, an unlisted line inside the listed\n * key's scalar takes `fr`'s spacing, and the U+000D itself lands inside a span — which 3.8.4\n * forbids.\n *\n * The decline **drops the spans the content scan produced for that line and does not alter the\n * content the scan is given**. Substituting each lone U+000D for a character 3.8.4 already\n * declines is the shortcut three ports reached for, this one included, and it is measured not\n * equivalent: the substitution moves the character onto a line of its own and can end a value run.\n * Both shapes are pinned as fixtures, and both are decided by what `yaml` mode does with the same\n * characters, since 3.7.4 claims 3.8's scan applies verbatim:\n *\n * - `title: a \"b\"\\nslug: c \"d\"\\n\\r` — the content-final U+000D is a blank line joining `slug`'s\n * value run, so 3.8.6's continuation bail declines `slug`. As a U+0009 it is a line with a tab\n * in it, not a blank one, the run ends and `slug` converts. `yaml` mode converts `title` only,\n * in both shipped runtimes measured;\n * - `summary: a\\rb\\n title: c -- d\\n` — the indented line is inside `summary`'s value run, so\n * `title` is not a key at all. Substitution ends the run and invents one.\n *\n * **The window runs to the start of the next line, not to the end of this one**, because 3.8.4's\n * own splitter treats a trailing U+000D as a terminator without a U+000A after it — so a block\n * whose single line ends in one looks clean if the terminator is excluded.\n */\nfunction declinedContentRanges(content: string): readonly Span[] {\n const declined: Span[] = [];\n let start = 0;\n while (start < content.length) {\n const lf = content.indexOf(\"\\n\", start);\n const next = lf === -1 ? content.length : lf + 1;\n for (let i = start; i < next; i += 1) {\n if (content.charCodeAt(i) === CR && content.charCodeAt(i + 1) !== LF) {\n declined.push({ start, end: next });\n break;\n }\n }\n start = next;\n }\n return declined;\n}\n\n/**\n * modes.md 3.7.4, spec 1.7.0. The frontmatter block's own spans, which form a **second text\n * unit**: the pipeline runs over them separately from the body's, so an unbalanced mark in a\n * metadata field can never pair with one in the first paragraph and this option cannot change a\n * byte outside the block.\n *\n * The block is located by `locateFrontmatter` (3.7.3a, spec 1.8.0) rather than by a second parse\n * of the document, which is both what polytypo/polytypo#59 reported and, since 1.8.0, the wrong\n * authority: the scan owns the extent and a parser is measured against it.\n *\n * Spans inside it are taken by the scan of modes.md 3.8 — frontmatter *is* YAML, and specifying it\n * twice is how two implementations of one grammar drift — with `frontmatterKeys` as step 8's key\n * predicate.\n *\n * A TOML block yields nothing, with the option or without it: TOML's quoting is a second grammar\n * this scan does not claim (modes.md §7.13). So does any content line carrying a lone U+000D — see\n * `declinedContentRanges`, which filters what the scan produced rather than changing what it reads.\n */\nexport function frontmatterSpans(source: string, frontmatterKeys: readonly string[]): Span[] {\n if (frontmatterKeys.length === 0) return [];\n const block = locateFrontmatter(source);\n if (block === null || block.matter === \"toml\") return [];\n\n const { contentStart, contentEnd } = block;\n const content = source.slice(contentStart, contentEnd);\n const declined = declinedContentRanges(content);\n\n return (\n yamlSpans(content, frontmatterKeys)\n // 3.7.4: a span reaching a declined position is dropped whole rather than trimmed.\n .filter((span) => !declined.some((range) => span.start < range.end && range.start < span.end))\n .map((span) => ({ start: span.start + contentStart, end: span.end + contentStart }))\n );\n}\n","import { frontmatterSpans, markdownSpans, resolveDialect } from \"../modes/markdown.js\";\nimport type { Dialect, Options } from \"../types.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { resolveNarrowTarget } from \"./narrow-target.js\";\nimport { planRules } from \"./rule-runner.js\";\nimport { resolveFrontmatterKeys } from \"./yaml-keys.js\";\nimport { analyzeOverUnits, runOverUnits } from \"./span-runner.js\";\nimport type { Change } from \"./origin.js\";\nimport type { Span } from \"../modes/spans.js\";\n\n/**\n * `markdown` mode only. Imports the Micromark/MDX stack and `parse5` (via `../modes/markdown.js`\n * importing `../modes/html.js` for normative embedded-HTML handling, modes.md 3.7) — both are\n * legitimately reachable from `polytypo/markdown` (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1).\n *\n * Validation order — `planRules`, then `getLocaleData`, then `resolveDialect`/parsing — mirrors\n * the pre-Stage-5 aggregate `runPipeline` exactly: an unknown-rule error wins over an\n * unknown-locale error, which wins over a missing/invalid dialect, which wins over a parse\n * failure. All four are public, tested behaviour this refactor was not authorised to change.\n */\nexport function runMarkdownPipeline(input: string, options: Partial<Options>): string {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const dialect = resolveDialect(options.dialect);\n const frontmatterKeys = resolveFrontmatterKeys(options.frontmatterKeys);\n const units = unitsOf(input, dialect, frontmatterKeys);\n return runOverUnits(input, units, planned, locale, \"markdown\", narrowTarget);\n}\n\n/**\n * modes.md 3.7.4: the body, and — only when the caller named frontmatter keys — the frontmatter\n * block as a second text unit. Without the option this is exactly the single unit every document\n * had before spec 1.7.0, which is why no released output can move.\n *\n * The two units must be **disjoint** — 3.7.4: \"no source position can belong to both units\". Since\n * spec 1.8.0 that is 3.7.3a's masking rule doing the work rather than a shared parser: the body is\n * read from a document whose block is blanked out, so it cannot emit a span the frontmatter unit\n * also claims, whatever the parser would have made of the block's characters.\n */\nfunction unitsOf(\n input: string,\n dialect: Dialect,\n frontmatterKeys: readonly string[] | undefined,\n): Span[][] {\n const body = markdownSpans(input, dialect);\n if (frontmatterKeys === undefined) return [body];\n return [frontmatterSpans(input, frontmatterKeys), body];\n}\n\n/** analyze.md §1, `markdown` mode. Dialect validation happens here exactly as it does for\n * `runMarkdownPipeline`, so an absent dialect throws POLYTYPO_INVALID_DIALECT from `analyze`\n * too (analyze.md §4 A1). */\nexport function analyzeMarkdownPipeline(input: string, options: Partial<Options>): Change[] {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const dialect = resolveDialect(options.dialect);\n const frontmatterKeys = resolveFrontmatterKeys(options.frontmatterKeys);\n return analyzeOverUnits(\n input,\n unitsOf(input, dialect, frontmatterKeys),\n planned,\n locale,\n \"markdown\",\n narrowTarget,\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkRRGKEG6Ecjs = require('./chunk-RRGKEG6E.cjs');
3
+ var _chunkFFIR7BWQcjs = require('./chunk-FFIR7BWQ.cjs');
4
4
 
5
5
  // src/modes/yaml.ts
6
6
  var TAB = 9;
@@ -51,6 +51,10 @@ function hasTab(source, line) {
51
51
  for (let i = line.start; i < line.end; i += 1) if (source.charCodeAt(i) === TAB) return true;
52
52
  return false;
53
53
  }
54
+ function hasLoneCarriageReturn(source, line) {
55
+ for (let i = line.start; i < line.end; i += 1) if (source.charCodeAt(i) === CR) return true;
56
+ return false;
57
+ }
54
58
  function isDocumentMarker(source, from, end) {
55
59
  if (end - from < 3) return false;
56
60
  const c = source.charCodeAt(from);
@@ -119,6 +123,7 @@ function scanLine(source, lines, li, listed, spans) {
119
123
  if (v >= line.end) return skipLine;
120
124
  const next = valueRunEnd(source, lines, li, indent);
121
125
  if (!listed.has(source.slice(keyStart, keyEnd))) return next;
126
+ if (hasLoneCarriageReturn(source, line)) return next;
122
127
  const value = source.charCodeAt(v);
123
128
  if (value === HASH || value === AMPERSAND || value === STAR || value === BANG || value === LBRACE || value === LBRACKET) {
124
129
  return next;
@@ -160,7 +165,7 @@ function blockScalar(source, lines, li, runEnd, indent, v, spans) {
160
165
  for (let k = li + 1; k < runEnd; k += 1) {
161
166
  const next = lines[k];
162
167
  if (isBlank(source, next)) continue;
163
- if (hasTab(source, next)) return;
168
+ if (hasTab(source, next) || hasLoneCarriageReturn(source, next)) return;
164
169
  const nextIndent = firstNonSpace(source, next) - next.start;
165
170
  if (contentIndent < 0) {
166
171
  contentIndent = explicitIndent > 0 ? indent + explicitIndent : nextIndent;
@@ -223,14 +228,14 @@ function plainScalar(source, line, v, spans) {
223
228
  // src/engine/yaml-keys.ts
224
229
  function resolveYamlKeys(value) {
225
230
  if (!Array.isArray(value)) {
226
- throw new (0, _chunkRRGKEG6Ecjs.PolytypoError)(
231
+ throw new (0, _chunkFFIR7BWQcjs.PolytypoError)(
227
232
  "POLYTYPO_INVALID_OPTION",
228
233
  `"keys" is required when mode is "yaml" and must be a list of strings (modes.md \xA73.8.2). Received ${value === void 0 ? "nothing" : JSON.stringify(value)}.`
229
234
  );
230
235
  }
231
236
  for (const key of value) {
232
237
  if (typeof key !== "string") {
233
- throw new (0, _chunkRRGKEG6Ecjs.PolytypoError)(
238
+ throw new (0, _chunkFFIR7BWQcjs.PolytypoError)(
234
239
  "POLYTYPO_INVALID_OPTION",
235
240
  `"keys" must contain only strings; received ${JSON.stringify(key)}.`
236
241
  );
@@ -241,14 +246,14 @@ function resolveYamlKeys(value) {
241
246
  function resolveFrontmatterKeys(value) {
242
247
  if (value === void 0) return void 0;
243
248
  if (!Array.isArray(value)) {
244
- throw new (0, _chunkRRGKEG6Ecjs.PolytypoError)(
249
+ throw new (0, _chunkFFIR7BWQcjs.PolytypoError)(
245
250
  "POLYTYPO_INVALID_OPTION",
246
251
  `"frontmatterKeys" must be a list of strings when given (modes.md \xA73.7.4). Received ${JSON.stringify(value)}.`
247
252
  );
248
253
  }
249
254
  for (const key of value) {
250
255
  if (typeof key !== "string") {
251
- throw new (0, _chunkRRGKEG6Ecjs.PolytypoError)(
256
+ throw new (0, _chunkFFIR7BWQcjs.PolytypoError)(
252
257
  "POLYTYPO_INVALID_OPTION",
253
258
  `"frontmatterKeys" must contain only strings; received ${JSON.stringify(key)}.`
254
259
  );
@@ -262,4 +267,4 @@ function resolveFrontmatterKeys(value) {
262
267
 
263
268
 
264
269
  exports.yamlSpans = yamlSpans; exports.resolveYamlKeys = resolveYamlKeys; exports.resolveFrontmatterKeys = resolveFrontmatterKeys;
265
- //# sourceMappingURL=chunk-I6G3ZOZR.cjs.map
270
+ //# sourceMappingURL=chunk-IH26NEJ6.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-IH26NEJ6.cjs","../src/modes/yaml.ts","../src/engine/yaml-keys.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACkBA,IAAM,IAAA,EAAM,CAAA;AACZ,IAAM,GAAA,EAAK,EAAA;AACX,IAAM,GAAA,EAAK,EAAA;AACX,IAAM,MAAA,EAAQ,EAAA;AACd,IAAM,KAAA,EAAO,EAAA;AACb,IAAM,OAAA,EAAS,EAAA;AACf,IAAM,KAAA,EAAO,EAAA;AACb,IAAM,QAAA,EAAU,EAAA;AAChB,IAAM,UAAA,EAAY,EAAA;AAClB,IAAM,OAAA,EAAS,EAAA;AACf,IAAM,KAAA,EAAO,EAAA;AACb,IAAM,KAAA,EAAO,EAAA;AACb,IAAM,KAAA,EAAO,EAAA;AACb,IAAM,IAAA,EAAM,EAAA;AACZ,IAAM,KAAA,EAAO,EAAA;AACb,IAAM,IAAA,EAAM,EAAA;AACZ,IAAM,KAAA,EAAO,EAAA;AACb,IAAM,MAAA,EAAQ,EAAA;AACd,IAAM,QAAA,EAAU,EAAA;AAChB,IAAM,SAAA,EAAW,EAAA;AACjB,IAAM,UAAA,EAAY,EAAA;AAClB,IAAM,OAAA,EAAS,GAAA;AACf,IAAM,KAAA,EAAO,GAAA;AAgBb,SAAS,UAAA,CAAW,MAAA,EAAwB;AAC1C,EAAA,MAAM,MAAA,EAAgB,CAAC,CAAA;AACvB,EAAA,IAAI,MAAA,EAAQ,CAAA;AACZ,EAAA,MAAM,MAAA,EAAQ,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oCAAA;AAAA,QACR,yBAAA;AAAA,QACA,CAAA,sDAAA,EAAyD,IAAA,CAAK,SAAA,CAAU,GAAG,CAAC,CAAA,CAAA;AAAA,MAC9E,CAAA;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;AF0MA;AACA;AACE;AACA;AACA;AACF,kIAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-IH26NEJ6.cjs","sourcesContent":[null,"import type { Span } from \"./spans.js\";\n\n/**\n * spec/rules/modes.md 3.8. `yaml` differs from the other two document modes twice over.\n *\n * It uses **no parser** (3.8.1): two of the five ecosystems' YAML libraries cannot report the\n * source offsets the round-trip guarantee needs, so the scan below is specified rather than\n * delegated and is written the same way in every runtime.\n *\n * And the caller names the keys (3.8.2). YAML is a data format with islands of prose in it — the\n * inverse of HTML and Markdown — and nothing in its syntax separates `description:` from `run:`.\n * A keyless draft of this file rewrote `if !` as `if!` inside a workflow's shell script; there is\n * no content test that would not, because shell and template expressions are written in words.\n *\n * It also **skips by default** — the inverse of 3.6's closed skip list. A construct this scan\n * does not recognise with certainty yields no spans, so the worst outcome of a gap in it is prose\n * left untypeset, never a changed byte.\n *\n * Offsets are UTF-16 indices, like every other mode in this runtime; every character the scan\n * tests is ASCII, so indexing by code unit and indexing by code point agree on all of them.\n */\n\nconst TAB = 0x09;\nconst LF = 0x0a;\nconst CR = 0x0d;\nconst SPACE = 0x20;\nconst BANG = 0x21;\nconst DQUOTE = 0x22;\nconst HASH = 0x23;\nconst PERCENT = 0x25;\nconst AMPERSAND = 0x26;\nconst SQUOTE = 0x27;\nconst STAR = 0x2a;\nconst PLUS = 0x2b;\nconst DASH = 0x2d;\nconst DOT = 0x2e;\nconst ZERO = 0x30;\nconst ONE = 0x31;\nconst NINE = 0x39;\nconst COLON = 0x3a;\nconst GREATER = 0x3e;\nconst LBRACKET = 0x5b;\nconst BACKSLASH = 0x5c;\nconst LBRACE = 0x7b;\nconst PIPE = 0x7c;\n\ninterface Line {\n readonly start: number;\n /** Index of the line terminator, or of the end of the source — never inside a span. */\n readonly end: number;\n}\n\n/**\n * 3.8.4: a line ends at U+000A, and **a U+000D immediately before it is not part of the line** —\n * it is a terminator like the U+000A itself, so it lies outside every span and comes back\n * untouched. Without that clause a CRLF file behaves differently from the same bytes with LF: the\n * block header reads as `|\\r` and is unrecognised, and a plain scalar carries the carriage return\n * inside its span. Five runtimes split lines with five different standard-library calls, so the\n * treatment has to be stated rather than inherited.\n */\nfunction splitLines(source: string): Line[] {\n const lines: Line[] = [];\n let start = 0;\n const endOf = (i: number): number => (i > start && source.charCodeAt(i - 1) === CR ? i - 1 : i);\n for (let i = 0; i < source.length; i += 1) {\n if (source.charCodeAt(i) === LF) {\n lines.push({ start, end: endOf(i) });\n start = i + 1;\n }\n }\n if (start < source.length) lines.push({ start, end: endOf(source.length) });\n return lines;\n}\n\n/** Index of the first code unit that is not U+0020, or `line.end` for a blank line. */\nfunction firstNonSpace(source: string, line: Line): number {\n let i = line.start;\n while (i < line.end && source.charCodeAt(i) === SPACE) i += 1;\n return i;\n}\n\nfunction isBlank(source: string, line: Line): boolean {\n return firstNonSpace(source, line) === line.end;\n}\n\nfunction hasTab(source: string, line: Line): boolean {\n for (let i = line.start; i < line.end; i += 1) if (source.charCodeAt(i) === TAB) return true;\n return false;\n}\n\n/**\n * 3.8.4 step 9. A U+000D that splitLines did not take for a terminator is a lone one, and YAML\n * 1.2.2 5.4 reads it as a line break the LF-only model of 3.8.4 does not. Declining the line is\n * what keeps \"line terminators are never inside a span\" true.\n */\nfunction hasLoneCarriageReturn(source: string, line: Line): boolean {\n for (let i = line.start; i < line.end; i += 1) if (source.charCodeAt(i) === CR) return true;\n return false;\n}\n\n/**\n * 3.8.4 step 3. `---` and `...` at the head of a line, bare or introducing a node: the\n * trailing-content form is declined too, so `--- key: value` never yields a key of `--- key`.\n */\nfunction isDocumentMarker(source: string, from: number, end: number): boolean {\n if (end - from < 3) return false;\n const c = source.charCodeAt(from);\n if (c !== DASH && c !== DOT) return false;\n if (source.charCodeAt(from + 1) !== c || source.charCodeAt(from + 2) !== c) return false;\n return from + 3 === end || source.charCodeAt(from + 3) === SPACE;\n}\n\n/** A colon that ends the line or is followed by U+0020 — the only colon YAML reads as an indicator. */\nfunction isIndicatorColon(source: string, j: number, end: number): boolean {\n if (source.charCodeAt(j) !== COLON) return false;\n return j + 1 === end || source.charCodeAt(j + 1) === SPACE;\n}\n\n/** A `-` that ends the line or is followed by U+0020 — a block sequence entry marker. */\nfunction isSequenceDash(source: string, j: number, end: number): boolean {\n if (source.charCodeAt(j) !== DASH) return false;\n return j + 1 === end || source.charCodeAt(j + 1) === SPACE;\n}\n\n/**\n * The value run of 3.8.4 step 7: every following line that is blank or indented more than the\n * key line. **Those lines are never scanned again** — without that, a multi-line quoted scalar,\n * a multi-line flow collection and a folded plain scalar all leak their continuation lines back\n * into the scan as if they were mappings, and a span can end up holding a scalar's own closing\n * delimiter.\n */\nfunction valueRunEnd(source: string, lines: readonly Line[], li: number, indent: number): number {\n let k = li + 1;\n while (k < lines.length) {\n const next = lines[k] as Line;\n if (!isBlank(source, next) && firstNonSpace(source, next) - next.start <= indent) break;\n k += 1;\n }\n return k;\n}\n\nexport function yamlSpans(source: string, keys: readonly string[]): Span[] {\n const listed = new Set(keys);\n const lines = splitLines(source);\n const spans: Span[] = [];\n let li = 0;\n while (li < lines.length) li = scanLine(source, lines, li, listed, spans);\n return spans;\n}\n\n/** One step of 3.8.4. Returns the index of the next line to scan. */\nfunction scanLine(\n source: string,\n lines: readonly Line[],\n li: number,\n listed: ReadonlySet<string>,\n spans: Span[],\n): number {\n const line = lines[li] as Line;\n const skipLine = li + 1;\n\n // step 1 — blank, or a tab anywhere, which makes indentation undecidable.\n const start = firstNonSpace(source, line);\n if (start === line.end || hasTab(source, line)) return skipLine;\n const indent = start - line.start;\n\n // steps 2 and 3 — comment, directive, document marker.\n const head = source.charCodeAt(start);\n if (head === HASH || head === PERCENT) return skipLine;\n if (isDocumentMarker(source, start, line.end)) return skipLine;\n\n // step 4 — block sequence entries are consumed, not skipped; `- - key: v` nests.\n let i = start;\n while (i < line.end && isSequenceDash(source, i, line.end)) {\n i += 2;\n while (i < line.end && source.charCodeAt(i) === SPACE) i += 1;\n }\n if (i >= line.end) return skipLine;\n\n // step 5 — find the key. A colon NOT followed by U+0020 or the line end is an ordinary key\n // character, so `a:b: v` has the key `a:b`; stating that is what keeps five scanners agreeing.\n const keyStart = i;\n let colon = -1;\n for (let j = i; j < line.end; j += 1) {\n const c = source.charCodeAt(j);\n if (\n c === DQUOTE ||\n c === SQUOTE ||\n c === LBRACE ||\n c === LBRACKET ||\n c === AMPERSAND ||\n c === STAR ||\n c === BANG ||\n c === HASH\n ) {\n return skipLine;\n }\n if (isIndicatorColon(source, j, line.end)) {\n colon = j;\n break;\n }\n }\n if (colon < 0) return skipLine;\n let keyEnd = colon;\n while (keyEnd > keyStart && source.charCodeAt(keyEnd - 1) === SPACE) keyEnd -= 1;\n if (keyEnd <= keyStart) return skipLine;\n\n // step 6 — an empty value means a nested node, whose lines ARE scanned on their own.\n let v = colon + 1;\n while (v < line.end && source.charCodeAt(v) === SPACE) v += 1;\n if (v >= line.end) return skipLine;\n\n // step 7 — the line carries an inline value, so its continuation lines belong to that value.\n const next = valueRunEnd(source, lines, li, indent);\n\n // step 8 — the key must be listed. Checked before the value's form, so an unlisted key costs\n // nothing to decline: this is what makes `run:`, `if:` and `image:` unreachable.\n if (!listed.has(source.slice(keyStart, keyEnd))) return next;\n\n // step 9 — a line carrying a lone U+000D yields no spans, but its value run is still consumed.\n if (hasLoneCarriageReturn(source, line)) return next;\n\n // step 9 — the scalar form.\n const value = source.charCodeAt(v);\n if (\n value === HASH ||\n value === AMPERSAND ||\n value === STAR ||\n value === BANG ||\n value === LBRACE ||\n value === LBRACKET\n ) {\n return next;\n }\n if (value === PIPE || value === GREATER) {\n blockScalar(source, lines, li, next, indent, v, spans);\n return next;\n }\n if (value === DQUOTE || value === SQUOTE) {\n if (next === li + 1) quotedScalar(source, line, v, spans);\n return next;\n }\n if (next === li + 1) plainScalar(source, line, v, spans);\n return next;\n}\n\n/**\n * 3.8.5. One span per non-blank content line, starting after the block's own indentation. The\n * header, the indentation and every line terminator lie outside every span — including the run\n * of line terminators at the end that the chomping indicator governs, which is why `|`, `|-`,\n * `|+`, `>`, `>-` and `>+` are handled identically here.\n */\nfunction blockScalar(\n source: string,\n lines: readonly Line[],\n li: number,\n runEnd: number,\n indent: number,\n v: number,\n spans: Span[],\n): void {\n const line = lines[li] as Line;\n\n // The header: at most one chomping indicator and at most one indentation indicator, in either\n // order, then optional spaces and an optional comment. Anything else is unrecognised.\n let h = v + 1;\n let explicitIndent = 0;\n let chomping = false;\n while (h < line.end) {\n const c = source.charCodeAt(h);\n if ((c === DASH || c === PLUS) && !chomping) {\n chomping = true;\n h += 1;\n continue;\n }\n if (c >= ONE && c <= NINE && explicitIndent === 0) {\n explicitIndent = c - ZERO;\n h += 1;\n continue;\n }\n break;\n }\n while (h < line.end && source.charCodeAt(h) === SPACE) h += 1;\n if (h < line.end && source.charCodeAt(h) !== HASH) return;\n\n // One definition of the run, and three conditions that make the whole block yield no spans.\n const content: Line[] = [];\n let contentIndent = -1;\n for (let k = li + 1; k < runEnd; k += 1) {\n const next = lines[k] as Line;\n if (isBlank(source, next)) continue; // blank lines belong to the block and yield no span\n if (hasTab(source, next) || hasLoneCarriageReturn(source, next)) return;\n const nextIndent = firstNonSpace(source, next) - next.start;\n if (contentIndent < 0) {\n contentIndent = explicitIndent > 0 ? indent + explicitIndent : nextIndent;\n }\n // An explicit indicator that disagrees with the block as written, or a later line dedented\n // inside it, is ambiguous rather than guessable — bail rather than choose.\n if (nextIndent < contentIndent) return;\n content.push(next);\n }\n if (contentIndent <= 0) return;\n\n for (const c of content) {\n const from = c.start + contentIndent;\n if (c.end > from) spans.push({ start: from, end: c.end });\n }\n}\n\n/**\n * 3.8.6. The span is the content between the quotes. A double-quoted scalar containing a backslash\n * yields no spans: the source spells that content with more characters than it has, which the\n * offset model of 3.1 cannot hold — the same constraint that makes an HTML character reference an\n * opaque unit in 3.6. In a single-quoted scalar `''` is the same kind of construct, and since spec\n * 1.9.0 it is such a unit: the range is split around it, so the apostrophe it spells stays\n * U+0027 and everything on either side converts. No colon test applies here: quoting neutralises\n * the colon, and applying the plain-scalar test would decline `title: \"Chapter 1: the beginning\"`.\n */\nfunction quotedScalar(source: string, line: Line, v: number, spans: Span[]): void {\n const quote = source.charCodeAt(v);\n const found: Span[] = [];\n let close = -1;\n let segment = v + 1;\n for (let j = v + 1; j < line.end; j += 1) {\n const c = source.charCodeAt(j);\n if (quote === DQUOTE && c === BACKSLASH) return;\n if (c !== quote) continue;\n if (quote === SQUOTE && j + 1 < line.end && source.charCodeAt(j + 1) === SQUOTE) {\n if (j > segment) found.push({ start: segment, end: j });\n segment = j + 2;\n j += 1;\n continue;\n }\n close = j;\n break;\n }\n if (close < 0) return;\n\n let after = close + 1;\n while (after < line.end && source.charCodeAt(after) === SPACE) after += 1;\n if (after < line.end && source.charCodeAt(after) !== HASH) return;\n\n if (close > segment) found.push({ start: segment, end: close });\n spans.push(...found);\n}\n\n/**\n * 3.8.6. In a plain scalar `:` and `#` are still live: U+0020 beside either of them is what turns\n * a scalar into a mapping indicator or a comment, and `dashes` emits U+0020 in every `-spaced`\n * locale. Lifting both out as opaque units leaves the dash token against a boundary marker, which\n * `dashes` declines on its own account — the edge-growth rule of 3.4 is the second net, not the\n * first.\n */\nfunction plainScalar(source: string, line: Line, v: number, spans: Span[]): void {\n // The scalar ends before a trailing comment, so a colon inside that comment is not the\n // scalar's and must not decline it.\n let end = line.end;\n for (let j = v; j < line.end; j += 1) {\n if (source.charCodeAt(j) === HASH && j > v && source.charCodeAt(j - 1) === SPACE) {\n end = j - 1;\n break;\n }\n }\n while (end > v && source.charCodeAt(end - 1) === SPACE) end -= 1;\n if (end <= v) return;\n\n // Compact nesting is not a value: `key: - item` opens a sequence, and `key: a .:` is a mapping\n // whose key is `a .` — a plain scalar can never contain a colon in that position.\n if (isSequenceDash(source, v, line.end)) return;\n for (let j = v; j < end; j += 1) if (isIndicatorColon(source, j, line.end)) return;\n\n let segment = v;\n for (let j = v; j <= end; j += 1) {\n if (j === end || source.charCodeAt(j) === COLON || source.charCodeAt(j) === HASH) {\n if (j > segment) spans.push({ start: segment, end: j });\n segment = j + 1;\n }\n }\n}\n","import { PolytypoError } from \"../errors.js\";\n\n/**\n * modes.md §3.8.2: `yaml` mode's `keys` option, resolved once at the call boundary.\n *\n * It has **no default**, for the reason `dialect` has none. YAML is a data format with islands of\n * prose in it, and nothing in its syntax marks them — `description` holds a sentence and `run`\n * holds a shell script, spelled identically — so a default would be a guess about the schema\n * above the document. An **empty list is legal**: \"process nothing\" is a choice a caller may\n * make, not an error.\n *\n * Checked after `locale`, last of the option checks, alongside `dialect` (ARCHITECTURE.md §7).\n * The two never both apply, since each belongs to a different mode.\n */\nexport function resolveYamlKeys(value: unknown): readonly string[] {\n if (!Array.isArray(value)) {\n throw new PolytypoError(\n \"POLYTYPO_INVALID_OPTION\",\n `\"keys\" is required when mode is \"yaml\" and must be a list of strings (modes.md §3.8.2). ` +\n `Received ${value === undefined ? \"nothing\" : JSON.stringify(value)}.`,\n );\n }\n for (const key of value as readonly unknown[]) {\n if (typeof key !== \"string\") {\n throw new PolytypoError(\n \"POLYTYPO_INVALID_OPTION\",\n `\"keys\" must contain only strings; received ${JSON.stringify(key)}.`,\n );\n }\n }\n return value as readonly string[];\n}\n\n/**\n * modes.md 3.7.4: `markdown` mode's `frontmatterKeys`. Optional — absent means the frontmatter\n * block is skipped whole, which is every pre-1.7.0 document's behaviour — and an empty list is\n * legal, exactly as it is for `keys`.\n *\n * Checked **after `dialect` and before the parse** (modes.md 3.7.4), which is what decides that a\n * document failing to parse in its dialect still reports the option error rather than\n * POLYTYPO_MALFORMED_INPUT. It is a separate function from `resolveYamlKeys` because the two\n * differ exactly where a caller would be bitten by sharing one: this option has no requiredness.\n */\nexport function resolveFrontmatterKeys(value: unknown): readonly string[] | undefined {\n if (value === undefined) return undefined;\n if (!Array.isArray(value)) {\n throw new PolytypoError(\n \"POLYTYPO_INVALID_OPTION\",\n `\"frontmatterKeys\" must be a list of strings when given (modes.md §3.7.4). ` +\n `Received ${JSON.stringify(value)}.`,\n );\n }\n for (const key of value as readonly unknown[]) {\n if (typeof key !== \"string\") {\n throw new PolytypoError(\n \"POLYTYPO_INVALID_OPTION\",\n `\"frontmatterKeys\" must contain only strings; received ${JSON.stringify(key)}.`,\n );\n }\n }\n return value as readonly string[];\n}\n"]}
@@ -6,7 +6,7 @@ import {
6
6
  runRules,
7
7
  runRulesRecording,
8
8
  toCodePoints
9
- } from "./chunk-P27DD76M.js";
9
+ } from "./chunk-TRUHKCDB.js";
10
10
 
11
11
  // src/engine/text-pipeline.ts
12
12
  function runTextPipeline(input, options) {
@@ -28,4 +28,4 @@ export {
28
28
  runTextPipeline,
29
29
  analyzeTextPipeline
30
30
  };
31
- //# sourceMappingURL=chunk-V2UZZU7M.js.map
31
+ //# sourceMappingURL=chunk-IMLOL2TH.js.map
@@ -0,0 +1,35 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkIH26NEJ6cjs = require('./chunk-IH26NEJ6.cjs');
5
+
6
+
7
+
8
+ var _chunkQPIQMX2Scjs = require('./chunk-QPIQMX2S.cjs');
9
+
10
+
11
+
12
+
13
+ var _chunkFFIR7BWQcjs = require('./chunk-FFIR7BWQ.cjs');
14
+
15
+ // src/engine/yaml-pipeline.ts
16
+ function runYamlPipeline(input, options) {
17
+ const narrowTarget = _chunkFFIR7BWQcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
18
+ const planned = _chunkFFIR7BWQcjs.planRules.call(void 0, options.rules);
19
+ const locale = _chunkFFIR7BWQcjs.getLocaleData.call(void 0, options.locale);
20
+ const keys = _chunkIH26NEJ6cjs.resolveYamlKeys.call(void 0, options.keys);
21
+ return _chunkQPIQMX2Scjs.runOverSpans.call(void 0, input, _chunkIH26NEJ6cjs.yamlSpans.call(void 0, input, keys), planned, locale, "yaml", narrowTarget);
22
+ }
23
+ function analyzeYamlPipeline(input, options) {
24
+ const narrowTarget = _chunkFFIR7BWQcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
25
+ const planned = _chunkFFIR7BWQcjs.planRules.call(void 0, options.rules);
26
+ const locale = _chunkFFIR7BWQcjs.getLocaleData.call(void 0, options.locale);
27
+ const keys = _chunkIH26NEJ6cjs.resolveYamlKeys.call(void 0, options.keys);
28
+ return _chunkQPIQMX2Scjs.analyzeOverSpans.call(void 0, input, _chunkIH26NEJ6cjs.yamlSpans.call(void 0, input, keys), planned, locale, "yaml", narrowTarget);
29
+ }
30
+
31
+
32
+
33
+
34
+ exports.runYamlPipeline = runYamlPipeline; exports.analyzeYamlPipeline = analyzeYamlPipeline;
35
+ //# sourceMappingURL=chunk-KSW5EOAP.cjs.map