polytypo 1.6.3 → 1.7.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 (77) hide show
  1. package/README.md +27 -0
  2. package/dist/{chunk-VVBJZBXR.js → chunk-25XZKUNP.js} +1 -1
  3. package/dist/{chunk-VVBJZBXR.js.map → chunk-25XZKUNP.js.map} +1 -1
  4. package/dist/chunk-33SLJJSZ.cjs +33 -0
  5. package/dist/{chunk-TV4AZVHZ.cjs.map → chunk-33SLJJSZ.cjs.map} +1 -1
  6. package/dist/{chunk-RNH6KTYZ.cjs → chunk-54TSHDNC.cjs} +68 -20
  7. package/dist/chunk-54TSHDNC.cjs.map +1 -0
  8. package/dist/chunk-74I62TZ2.js +35 -0
  9. package/dist/chunk-74I62TZ2.js.map +1 -0
  10. package/dist/{chunk-ODTH774G.js → chunk-DAIPI5CX.js} +2 -2
  11. package/dist/{chunk-UB7HJ4MX.cjs → chunk-FMU74VA6.cjs} +1 -1
  12. package/dist/{chunk-UB7HJ4MX.cjs.map → chunk-FMU74VA6.cjs.map} +1 -1
  13. package/dist/{chunk-UOPLHOTJ.js → chunk-GUTUSN4K.js} +4 -4
  14. package/dist/{chunk-4ELGGQ7B.js → chunk-HBIIWBB5.js} +23 -27
  15. package/dist/chunk-HBIIWBB5.js.map +1 -0
  16. package/dist/chunk-HTCGXDEG.cjs +31 -0
  17. package/dist/{chunk-GZSUAD6M.cjs.map → chunk-HTCGXDEG.cjs.map} +1 -1
  18. package/dist/{chunk-JT3VGUUU.cjs → chunk-I2QPXPHX.cjs} +3 -3
  19. package/dist/{chunk-JT3VGUUU.cjs.map → chunk-I2QPXPHX.cjs.map} +1 -1
  20. package/dist/{chunk-2XWZW3RU.cjs → chunk-IQHYZG2K.cjs} +23 -27
  21. package/dist/chunk-IQHYZG2K.cjs.map +1 -0
  22. package/dist/{chunk-RZYVLO3Z.js → chunk-ITDTGCLJ.js} +2 -2
  23. package/dist/{chunk-27B32RJQ.js → chunk-JE2MK4CC.js} +59 -11
  24. package/dist/chunk-JE2MK4CC.js.map +1 -0
  25. package/dist/{chunk-UIUJSDBS.js → chunk-JVBK3LG3.js} +2 -2
  26. package/dist/{chunk-BCU7YHWD.cjs → chunk-MMXKQUAS.cjs} +4 -4
  27. package/dist/{chunk-BCU7YHWD.cjs.map → chunk-MMXKQUAS.cjs.map} +1 -1
  28. package/dist/{chunk-OHMN6WPZ.js → chunk-U5Y7C2L4.js} +21 -8
  29. package/dist/{chunk-OHMN6WPZ.js.map → chunk-U5Y7C2L4.js.map} +1 -1
  30. package/dist/{chunk-7DKZNZUD.cjs → chunk-VDLHT5CW.cjs} +35 -22
  31. package/dist/chunk-VDLHT5CW.cjs.map +1 -0
  32. package/dist/chunk-X6CI7GWV.cjs +35 -0
  33. package/dist/chunk-X6CI7GWV.cjs.map +1 -0
  34. package/dist/{errors-C1_sHGgx.d.ts → errors-DeHxbXRn.d.cts} +8 -0
  35. package/dist/{errors-C1_sHGgx.d.cts → errors-DeHxbXRn.d.ts} +8 -0
  36. package/dist/html.cjs +10 -10
  37. package/dist/html.cjs.map +1 -1
  38. package/dist/html.d.cts +3 -3
  39. package/dist/html.d.ts +3 -3
  40. package/dist/html.js +5 -5
  41. package/dist/html.js.map +1 -1
  42. package/dist/index.cjs +18 -17
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.d.cts +2 -2
  45. package/dist/index.d.ts +2 -2
  46. package/dist/index.js +8 -7
  47. package/dist/index.js.map +1 -1
  48. package/dist/markdown.cjs +11 -10
  49. package/dist/markdown.cjs.map +1 -1
  50. package/dist/markdown.d.cts +2 -2
  51. package/dist/markdown.d.ts +2 -2
  52. package/dist/markdown.js +6 -5
  53. package/dist/markdown.js.map +1 -1
  54. package/dist/text.cjs +8 -8
  55. package/dist/text.cjs.map +1 -1
  56. package/dist/text.d.cts +3 -3
  57. package/dist/text.d.ts +3 -3
  58. package/dist/text.js +3 -3
  59. package/dist/text.js.map +1 -1
  60. package/dist/yaml.cjs +10 -9
  61. package/dist/yaml.cjs.map +1 -1
  62. package/dist/yaml.d.cts +3 -3
  63. package/dist/yaml.d.ts +3 -3
  64. package/dist/yaml.js +5 -4
  65. package/dist/yaml.js.map +1 -1
  66. package/package.json +1 -1
  67. package/dist/chunk-27B32RJQ.js.map +0 -1
  68. package/dist/chunk-2XWZW3RU.cjs.map +0 -1
  69. package/dist/chunk-4ELGGQ7B.js.map +0 -1
  70. package/dist/chunk-7DKZNZUD.cjs.map +0 -1
  71. package/dist/chunk-GZSUAD6M.cjs +0 -31
  72. package/dist/chunk-RNH6KTYZ.cjs.map +0 -1
  73. package/dist/chunk-TV4AZVHZ.cjs +0 -33
  74. /package/dist/{chunk-ODTH774G.js.map → chunk-DAIPI5CX.js.map} +0 -0
  75. /package/dist/{chunk-UOPLHOTJ.js.map → chunk-GUTUSN4K.js.map} +0 -0
  76. /package/dist/{chunk-RZYVLO3Z.js.map → chunk-ITDTGCLJ.js.map} +0 -0
  77. /package/dist/{chunk-UIUJSDBS.js.map → chunk-JVBK3LG3.js.map} +0 -0
@@ -0,0 +1,33 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkMMXKQUAScjs = require('./chunk-MMXKQUAS.cjs');
4
+
5
+
6
+
7
+ var _chunkVDLHT5CWcjs = require('./chunk-VDLHT5CW.cjs');
8
+
9
+
10
+
11
+
12
+ var _chunkFMU74VA6cjs = require('./chunk-FMU74VA6.cjs');
13
+
14
+ // src/engine/html-pipeline.ts
15
+ function runHtmlPipeline(input, options) {
16
+ const narrowTarget = _chunkFMU74VA6cjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
17
+ const planned = _chunkFMU74VA6cjs.planRules.call(void 0, options.rules);
18
+ const locale = _chunkFMU74VA6cjs.getLocaleData.call(void 0, options.locale);
19
+ const spans = _chunkMMXKQUAScjs.htmlSpans.call(void 0, input);
20
+ return _chunkVDLHT5CWcjs.runOverSpans.call(void 0, input, spans, planned, locale, "html", narrowTarget);
21
+ }
22
+ function analyzeHtmlPipeline(input, options) {
23
+ const narrowTarget = _chunkFMU74VA6cjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
24
+ const planned = _chunkFMU74VA6cjs.planRules.call(void 0, options.rules);
25
+ const locale = _chunkFMU74VA6cjs.getLocaleData.call(void 0, options.locale);
26
+ return _chunkVDLHT5CWcjs.analyzeOverSpans.call(void 0, input, _chunkMMXKQUAScjs.htmlSpans.call(void 0, input), planned, locale, "html", narrowTarget);
27
+ }
28
+
29
+
30
+
31
+
32
+ exports.runHtmlPipeline = runHtmlPipeline; exports.analyzeHtmlPipeline = analyzeHtmlPipeline;
33
+ //# sourceMappingURL=chunk-33SLJJSZ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-TV4AZVHZ.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-TV4AZVHZ.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-33SLJJSZ.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-33SLJJSZ.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"]}
@@ -2,17 +2,21 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkBCU7YHWDcjs = require('./chunk-BCU7YHWD.cjs');
5
+ var _chunkMMXKQUAScjs = require('./chunk-MMXKQUAS.cjs');
6
6
 
7
7
 
8
8
 
9
- var _chunk7DKZNZUDcjs = require('./chunk-7DKZNZUD.cjs');
9
+ var _chunkIQHYZG2Kcjs = require('./chunk-IQHYZG2K.cjs');
10
10
 
11
11
 
12
12
 
13
+ var _chunkVDLHT5CWcjs = require('./chunk-VDLHT5CW.cjs');
13
14
 
14
15
 
15
- var _chunkUB7HJ4MXcjs = require('./chunk-UB7HJ4MX.cjs');
16
+
17
+
18
+
19
+ var _chunkFMU74VA6cjs = require('./chunk-FMU74VA6.cjs');
16
20
 
17
21
  // src/modes/markdown.ts
18
22
  var _micromark = require('micromark');
@@ -44,7 +48,14 @@ var SKIPPED_TOKEN_TYPES = /* @__PURE__ */ new Set([
44
48
  // front of the colon of a machine-read metadata field. Covered by conformance fixtures
45
49
  // en-us-markdown-{commonmark,mdx}-frontmatter, fr-markdown-{commonmark,mdx}-frontmatter-nbsp,
46
50
  // en-us-markdown-commonmark-frontmatter-toml and -frontmatter-unterminated.
47
- "frontmatter"
51
+ //
52
+ // These are `micromark-extension-frontmatter`'s own token types, one per matter. An earlier
53
+ // revision listed `"frontmatter"`, which the extension never emits: the block was skipped only
54
+ // because its content arrives as `yamlValue`/`tomlValue` rather than `data`, so the entry that
55
+ // was supposed to do the work did none. Naming the real types makes the skip explicit, and
56
+ // spec 1.7.0's `frontmatterKeys` needs the block recognised rather than merely un-emitted.
57
+ "yaml",
58
+ "toml"
48
59
  ]);
49
60
  var RAW_TAG_TOKEN_TYPES = /* @__PURE__ */ new Set([
50
61
  "htmlText",
@@ -90,7 +101,7 @@ function updateElementStack(stack, tag, caseSensitive) {
90
101
  if (stack[stack.length - 1] === name) stack.pop();
91
102
  return;
92
103
  }
93
- if (!parsed.selfClosing && _chunkBCU7YHWDcjs.isSkippedElement.call(void 0, name)) stack.push(name);
104
+ if (!parsed.selfClosing && _chunkMMXKQUAScjs.isSkippedElement.call(void 0, name)) stack.push(name);
94
105
  }
95
106
  function tokenize(source, extensions) {
96
107
  return _micromark.postprocess.call(void 0,
@@ -100,12 +111,12 @@ function tokenize(source, extensions) {
100
111
  function resolveDialect(dialect) {
101
112
  if (dialect === "commonmark" || dialect === "mdx") return dialect;
102
113
  if (dialect === void 0) {
103
- throw new (0, _chunkUB7HJ4MXcjs.PolytypoError)(
114
+ throw new (0, _chunkFMU74VA6cjs.PolytypoError)(
104
115
  "POLYTYPO_INVALID_DIALECT",
105
116
  'Mode "markdown" requires a dialect. Expected "commonmark" or "mdx"; there is no default.'
106
117
  );
107
118
  }
108
- throw new (0, _chunkUB7HJ4MXcjs.PolytypoError)(
119
+ throw new (0, _chunkFMU74VA6cjs.PolytypoError)(
109
120
  "POLYTYPO_INVALID_DIALECT",
110
121
  `Unknown dialect "${String(dialect)}". Expected "commonmark" or "mdx".`
111
122
  );
@@ -116,7 +127,7 @@ function extensionsFor(dialect) {
116
127
  return dialect === "mdx" ? [fm, _micromarkextensiongfm.gfm.call(void 0, ), _micromarkextensionmdxjs.mdxjs.call(void 0, )] : [fm, _micromarkextensiongfm.gfm.call(void 0, )];
117
128
  }
118
129
  function markdownSpans(source, dialect) {
119
- const events = _chunkBCU7YHWDcjs.wrapParserErrors.call(void 0, dialect, () => tokenize(source, extensionsFor(dialect)));
130
+ const events = _chunkMMXKQUAScjs.wrapParserErrors.call(void 0, dialect, () => tokenize(source, extensionsFor(dialect)));
120
131
  const spans = [];
121
132
  const elementStack = [];
122
133
  let skipDepth = 0;
@@ -139,7 +150,7 @@ function markdownSpans(source, dialect) {
139
150
  }
140
151
  if (type === "htmlFlow") {
141
152
  if (kind === "enter" && skipDepth === 0 && elementStack.length === 0) {
142
- for (const span of _chunkBCU7YHWDcjs.htmlFragmentSpans.call(void 0,
153
+ for (const span of _chunkMMXKQUAScjs.htmlFragmentSpans.call(void 0,
143
154
  source.slice(token.start.offset, token.end.offset),
144
155
  token.start.offset
145
156
  )) {
@@ -155,24 +166,61 @@ function markdownSpans(source, dialect) {
155
166
  }
156
167
  return spans;
157
168
  }
169
+ function frontmatterSpans(source, dialect, frontmatterKeys) {
170
+ if (frontmatterKeys.length === 0) return [];
171
+ const events = _chunkMMXKQUAScjs.wrapParserErrors.call(void 0, dialect, () => tokenize(source, extensionsFor(dialect)));
172
+ let inBlock = false;
173
+ let contentStart = -1;
174
+ let contentEnd = -1;
175
+ for (const [kind, token] of events) {
176
+ const type = token.type;
177
+ if (type === "toml") return [];
178
+ if (type === "yaml") {
179
+ if (kind === "enter") {
180
+ inBlock = true;
181
+ continue;
182
+ }
183
+ break;
184
+ }
185
+ if (!inBlock) continue;
186
+ if (kind !== "enter") continue;
187
+ if (type === "yamlFence") {
188
+ if (contentStart >= 0) contentEnd = token.start.offset;
189
+ continue;
190
+ }
191
+ if (type === "lineEnding" && contentStart < 0) contentStart = token.end.offset;
192
+ }
193
+ if (contentStart < 0 || contentEnd < contentStart) return [];
194
+ return _chunkIQHYZG2Kcjs.yamlSpans.call(void 0, source.slice(contentStart, contentEnd), frontmatterKeys).map((span) => ({
195
+ start: span.start + contentStart,
196
+ end: span.end + contentStart
197
+ }));
198
+ }
158
199
 
159
200
  // src/engine/markdown-pipeline.ts
160
201
  function runMarkdownPipeline(input, options) {
161
- const narrowTarget = _chunkUB7HJ4MXcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
162
- const planned = _chunkUB7HJ4MXcjs.planRules.call(void 0, options.rules);
163
- const locale = _chunkUB7HJ4MXcjs.getLocaleData.call(void 0, options.locale);
202
+ const narrowTarget = _chunkFMU74VA6cjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
203
+ const planned = _chunkFMU74VA6cjs.planRules.call(void 0, options.rules);
204
+ const locale = _chunkFMU74VA6cjs.getLocaleData.call(void 0, options.locale);
164
205
  const dialect = resolveDialect(options.dialect);
165
- const spans = markdownSpans(input, dialect);
166
- return _chunk7DKZNZUDcjs.runOverSpans.call(void 0, input, spans, planned, locale, "markdown", narrowTarget);
206
+ const frontmatterKeys = _chunkIQHYZG2Kcjs.resolveFrontmatterKeys.call(void 0, options.frontmatterKeys);
207
+ const units = unitsOf(input, dialect, frontmatterKeys);
208
+ return _chunkVDLHT5CWcjs.runOverUnits.call(void 0, input, units, planned, locale, "markdown", narrowTarget);
209
+ }
210
+ function unitsOf(input, dialect, frontmatterKeys) {
211
+ const body = markdownSpans(input, dialect);
212
+ if (frontmatterKeys === void 0) return [body];
213
+ return [frontmatterSpans(input, dialect, frontmatterKeys), body];
167
214
  }
168
215
  function analyzeMarkdownPipeline(input, options) {
169
- const narrowTarget = _chunkUB7HJ4MXcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
170
- const planned = _chunkUB7HJ4MXcjs.planRules.call(void 0, options.rules);
171
- const locale = _chunkUB7HJ4MXcjs.getLocaleData.call(void 0, options.locale);
216
+ const narrowTarget = _chunkFMU74VA6cjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
217
+ const planned = _chunkFMU74VA6cjs.planRules.call(void 0, options.rules);
218
+ const locale = _chunkFMU74VA6cjs.getLocaleData.call(void 0, options.locale);
172
219
  const dialect = resolveDialect(options.dialect);
173
- return _chunk7DKZNZUDcjs.analyzeOverSpans.call(void 0,
220
+ const frontmatterKeys = _chunkIQHYZG2Kcjs.resolveFrontmatterKeys.call(void 0, options.frontmatterKeys);
221
+ return _chunkVDLHT5CWcjs.analyzeOverUnits.call(void 0,
174
222
  input,
175
- markdownSpans(input, dialect),
223
+ unitsOf(input, dialect, frontmatterKeys),
176
224
  planned,
177
225
  locale,
178
226
  "markdown",
@@ -184,4 +232,4 @@ function analyzeMarkdownPipeline(input, options) {
184
232
 
185
233
 
186
234
  exports.runMarkdownPipeline = runMarkdownPipeline; exports.analyzeMarkdownPipeline = analyzeMarkdownPipeline;
187
- //# sourceMappingURL=chunk-RNH6KTYZ.cjs.map
235
+ //# sourceMappingURL=chunk-54TSHDNC.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-54TSHDNC.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;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CAAA;AAAA,IACvC,OAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF;AFuKA;AACA;AACE;AACA;AACF,6GAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-54TSHDNC.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. Naming the real types makes the skip explicit, and\n // spec 1.7.0's `frontmatterKeys` needs the block recognised rather than merely un-emitted.\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\nfunction extensionsFor(dialect: Dialect): Extension[] {\n const fm = frontmatter([...FRONTMATTER_MATTERS]);\n return dialect === \"mdx\" ? [fm, gfm(), mdxjs()] : [fm, gfm()];\n}\n\nexport function markdownSpans(source: string, dialect: Dialect): Span[] {\n const events = wrapParserErrors(dialect, () => tokenize(source, 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 source.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 source.slice(token.start.offset, token.end.offset),\n token.start.offset,\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, end: token.end.offset });\n }\n }\n\n return spans;\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 * Spans are taken by the scan of modes.md 3.8 — frontmatter *is* YAML, and specifying it twice is\n * how two implementations of one grammar drift — with `frontmatterKeys` as step 8's key predicate.\n * The block itself is the construct `markdownSpans` skips (3.7.3), so the option can only ever add\n * spans where the skip removed them: no source position belongs to both units, whatever a given\n * parser's frontmatter support decides the construct's edges are (recorded in 3.7.4 and §7.13).\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).\n */\nexport function frontmatterSpans(\n source: string,\n dialect: Dialect,\n frontmatterKeys: readonly string[],\n): Span[] {\n if (frontmatterKeys.length === 0) return [];\n const events = wrapParserErrors(dialect, () => tokenize(source, extensionsFor(dialect)));\n\n // 3.7.4: the content runs from after the opening delimiter line's terminator to the code point\n // that begins the closing delimiter line, and both delimiters stay outside every span. Taken\n // from the fence tokens rather than by searching the text, so a CRLF document, a trailing space\n // on either delimiter and a `---` inside a scalar all behave without a second rule each.\n let inBlock = false;\n let contentStart = -1;\n let contentEnd = -1;\n for (const [kind, token] of events) {\n const type = token.type as string;\n if (type === \"toml\") return []; // a second grammar this scan does not claim (§7.13)\n if (type === \"yaml\") {\n if (kind === \"enter\") {\n inBlock = true;\n continue;\n }\n break;\n }\n if (!inBlock) continue;\n if (kind !== \"enter\") continue;\n if (type === \"yamlFence\") {\n if (contentStart >= 0) contentEnd = token.start.offset;\n continue;\n }\n if (type === \"lineEnding\" && contentStart < 0) contentStart = token.end.offset;\n }\n if (contentStart < 0 || contentEnd < contentStart) return [];\n\n return yamlSpans(source.slice(contentStart, contentEnd), frontmatterKeys).map((span) => ({\n start: span.start + contentStart,\n 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 */\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, dialect, 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"]}
@@ -0,0 +1,35 @@
1
+ import {
2
+ resolveYamlKeys,
3
+ yamlSpans
4
+ } from "./chunk-HBIIWBB5.js";
5
+ import {
6
+ analyzeOverSpans,
7
+ runOverSpans
8
+ } from "./chunk-U5Y7C2L4.js";
9
+ import {
10
+ getLocaleData,
11
+ planRules,
12
+ resolveNarrowTarget
13
+ } from "./chunk-25XZKUNP.js";
14
+
15
+ // src/engine/yaml-pipeline.ts
16
+ function runYamlPipeline(input, options) {
17
+ const narrowTarget = resolveNarrowTarget(options.narrowNbsp);
18
+ const planned = planRules(options.rules);
19
+ const locale = getLocaleData(options.locale);
20
+ const keys = resolveYamlKeys(options.keys);
21
+ return runOverSpans(input, yamlSpans(input, keys), planned, locale, "yaml", narrowTarget);
22
+ }
23
+ function analyzeYamlPipeline(input, options) {
24
+ const narrowTarget = resolveNarrowTarget(options.narrowNbsp);
25
+ const planned = planRules(options.rules);
26
+ const locale = getLocaleData(options.locale);
27
+ const keys = resolveYamlKeys(options.keys);
28
+ return analyzeOverSpans(input, yamlSpans(input, keys), planned, locale, "yaml", narrowTarget);
29
+ }
30
+
31
+ export {
32
+ runYamlPipeline,
33
+ analyzeYamlPipeline
34
+ };
35
+ //# sourceMappingURL=chunk-74I62TZ2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/engine/yaml-pipeline.ts"],"sourcesContent":["import { yamlSpans } from \"../modes/yaml.js\";\nimport type { Options } from \"../types.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { resolveNarrowTarget } from \"./narrow-target.js\";\nimport { resolveYamlKeys } from \"./yaml-keys.js\";\nimport { planRules } from \"./rule-runner.js\";\nimport { analyzeOverSpans, runOverSpans } from \"./span-runner.js\";\nimport type { Change } from \"./origin.js\";\n\n/**\n * `yaml` mode only, and the only mode pipeline with **no parser dependency at all** — span\n * selection is the specified scan of modes.md 3.8, not a library. There is likewise no\n * `POLYTYPO_MALFORMED_INPUT` counterpart here: with no declared grammar to violate, a file that\n * is not YAML yields few spans or none and comes back byte for byte (modes.md 3.8.3). The only\n * throw this mode adds is `keys`, which is about the call and not the input.\n */\nexport function runYamlPipeline(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 keys = resolveYamlKeys(options.keys);\n return runOverSpans(input, yamlSpans(input, keys), planned, locale, \"yaml\", narrowTarget);\n}\n\n/** analyze.md §1, `yaml` mode: offsets are into the document, not into a span (analyze.md §6). */\nexport function analyzeYamlPipeline(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 keys = resolveYamlKeys(options.keys);\n return analyzeOverSpans(input, yamlSpans(input, keys), planned, locale, \"yaml\", narrowTarget);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBO,SAAS,gBAAgB,OAAe,SAAmC;AAChF,QAAM,eAAe,oBAAoB,QAAQ,UAAU;AAC3D,QAAM,UAAU,UAAU,QAAQ,KAAK;AACvC,QAAM,SAAS,cAAc,QAAQ,MAAM;AAC3C,QAAM,OAAO,gBAAgB,QAAQ,IAAI;AACzC,SAAO,aAAa,OAAO,UAAU,OAAO,IAAI,GAAG,SAAS,QAAQ,QAAQ,YAAY;AAC1F;AAGO,SAAS,oBAAoB,OAAe,SAAqC;AACtF,QAAM,eAAe,oBAAoB,QAAQ,UAAU;AAC3D,QAAM,UAAU,UAAU,QAAQ,KAAK;AACvC,QAAM,SAAS,cAAc,QAAQ,MAAM;AAC3C,QAAM,OAAO,gBAAgB,QAAQ,IAAI;AACzC,SAAO,iBAAiB,OAAO,UAAU,OAAO,IAAI,GAAG,SAAS,QAAQ,QAAQ,YAAY;AAC9F;","names":[]}
@@ -6,7 +6,7 @@ import {
6
6
  runRules,
7
7
  runRulesRecording,
8
8
  toCodePoints
9
- } from "./chunk-VVBJZBXR.js";
9
+ } from "./chunk-25XZKUNP.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-ODTH774G.js.map
31
+ //# sourceMappingURL=chunk-DAIPI5CX.js.map
@@ -5837,4 +5837,4 @@ function runRulesRecording(cp, planned, locale, mode, narrowTarget, origin, inpu
5837
5837
 
5838
5838
 
5839
5839
  exports.PolytypoError = PolytypoError; exports.toCodePoints = toCodePoints; exports.fromCodePoints = fromCodePoints; exports.getLocaleData = getLocaleData; exports.resolveNarrowTarget = resolveNarrowTarget; exports.MARKER = MARKER; exports.LINE_MARKER = LINE_MARKER; exports.isMarker = isMarker; exports.RULES = RULES; exports.applyEdits = applyEdits; exports.NO_ORIGIN = NO_ORIGIN; exports.planRules = planRules; exports.runRules = runRules; exports.runRulesRecording = runRulesRecording;
5840
- //# sourceMappingURL=chunk-UB7HJ4MX.cjs.map
5840
+ //# sourceMappingURL=chunk-FMU74VA6.cjs.map