polytypo 1.6.3 → 1.8.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 (78) hide show
  1. package/README.md +27 -0
  2. package/dist/{chunk-UOPLHOTJ.js → chunk-4RAZ2EDS.js} +4 -4
  3. package/dist/chunk-6UQAKZ7L.js +35 -0
  4. package/dist/chunk-6UQAKZ7L.js.map +1 -0
  5. package/dist/{chunk-UIUJSDBS.js → chunk-EH542ZE4.js} +2 -2
  6. package/dist/{chunk-VVBJZBXR.js → chunk-EQ2JTKYF.js} +1 -1
  7. package/dist/{chunk-VVBJZBXR.js.map → chunk-EQ2JTKYF.js.map} +1 -1
  8. package/dist/{chunk-OHMN6WPZ.js → chunk-F6HVIPLF.js} +21 -8
  9. package/dist/{chunk-OHMN6WPZ.js.map → chunk-F6HVIPLF.js.map} +1 -1
  10. package/dist/{chunk-JT3VGUUU.cjs → chunk-GK5P55K5.cjs} +3 -3
  11. package/dist/{chunk-JT3VGUUU.cjs.map → chunk-GK5P55K5.cjs.map} +1 -1
  12. package/dist/{chunk-UB7HJ4MX.cjs → chunk-GUROIWJY.cjs} +1 -1
  13. package/dist/{chunk-UB7HJ4MX.cjs.map → chunk-GUROIWJY.cjs.map} +1 -1
  14. package/dist/{chunk-2XWZW3RU.cjs → chunk-KAJ3GVK2.cjs} +23 -27
  15. package/dist/chunk-KAJ3GVK2.cjs.map +1 -0
  16. package/dist/{chunk-4ELGGQ7B.js → chunk-KCKZHLI5.js} +23 -27
  17. package/dist/chunk-KCKZHLI5.js.map +1 -0
  18. package/dist/chunk-KFDDI4LH.cjs +35 -0
  19. package/dist/chunk-KFDDI4LH.cjs.map +1 -0
  20. package/dist/{chunk-BCU7YHWD.cjs → chunk-M3TVDUGX.cjs} +4 -4
  21. package/dist/{chunk-BCU7YHWD.cjs.map → chunk-M3TVDUGX.cjs.map} +1 -1
  22. package/dist/{chunk-RZYVLO3Z.js → chunk-PEBD5XTD.js} +2 -2
  23. package/dist/chunk-UJ3D4DYP.cjs +33 -0
  24. package/dist/{chunk-TV4AZVHZ.cjs.map → chunk-UJ3D4DYP.cjs.map} +1 -1
  25. package/dist/{chunk-7DKZNZUD.cjs → chunk-UWFI3XV7.cjs} +35 -22
  26. package/dist/chunk-UWFI3XV7.cjs.map +1 -0
  27. package/dist/chunk-VBHUVDW4.cjs +296 -0
  28. package/dist/chunk-VBHUVDW4.cjs.map +1 -0
  29. package/dist/{chunk-ODTH774G.js → chunk-XLTVLET5.js} +2 -2
  30. package/dist/chunk-YA64BEKC.cjs +31 -0
  31. package/dist/{chunk-GZSUAD6M.cjs.map → chunk-YA64BEKC.cjs.map} +1 -1
  32. package/dist/{chunk-27B32RJQ.js → chunk-YH77XVJB.js} +126 -17
  33. package/dist/chunk-YH77XVJB.js.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 +0 -187
  73. package/dist/chunk-RNH6KTYZ.cjs.map +0 -1
  74. package/dist/chunk-TV4AZVHZ.cjs +0 -33
  75. /package/dist/{chunk-UOPLHOTJ.js.map → chunk-4RAZ2EDS.js.map} +0 -0
  76. /package/dist/{chunk-UIUJSDBS.js.map → chunk-EH542ZE4.js.map} +0 -0
  77. /package/dist/{chunk-RZYVLO3Z.js.map → chunk-PEBD5XTD.js.map} +0 -0
  78. /package/dist/{chunk-ODTH774G.js.map → chunk-XLTVLET5.js.map} +0 -0
@@ -2,17 +2,21 @@ import {
2
2
  htmlFragmentSpans,
3
3
  isSkippedElement,
4
4
  wrapParserErrors
5
- } from "./chunk-RZYVLO3Z.js";
5
+ } from "./chunk-PEBD5XTD.js";
6
6
  import {
7
- analyzeOverSpans,
8
- runOverSpans
9
- } from "./chunk-OHMN6WPZ.js";
7
+ resolveFrontmatterKeys,
8
+ yamlSpans
9
+ } from "./chunk-KCKZHLI5.js";
10
+ import {
11
+ analyzeOverUnits,
12
+ runOverUnits
13
+ } from "./chunk-F6HVIPLF.js";
10
14
  import {
11
15
  PolytypoError,
12
16
  getLocaleData,
13
17
  planRules,
14
18
  resolveNarrowTarget
15
- } from "./chunk-VVBJZBXR.js";
19
+ } from "./chunk-EQ2JTKYF.js";
16
20
 
17
21
  // src/modes/markdown.ts
18
22
  import { parse, postprocess, preprocess } from "micromark";
@@ -44,7 +48,20 @@ 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.
56
+ //
57
+ // Since spec 1.8.0 the skip is 3.7.3a's mask, not this: a located block reaches the parser as
58
+ // blanks, so the extension cannot see one. The extension stays because it is measured inert —
59
+ // `tests/modes/frontmatter-keys.test.ts` asserts over every edge document that it never finds
60
+ // a block the scan denies — and because removing a working locator that costs nothing would be
61
+ // a change with no problem behind it. What the test would catch is the case that would matter:
62
+ // the two disagreeing about whether a document has a block at all.
63
+ "yaml",
64
+ "toml"
48
65
  ]);
49
66
  var RAW_TAG_TOKEN_TYPES = /* @__PURE__ */ new Set([
50
67
  "htmlText",
@@ -115,8 +132,63 @@ function extensionsFor(dialect) {
115
132
  const fm = frontmatter([...FRONTMATTER_MATTERS]);
116
133
  return dialect === "mdx" ? [fm, gfm(), mdxjs()] : [fm, gfm()];
117
134
  }
135
+ var YAML_DELIMITER = "---";
136
+ var TOML_DELIMITER = "+++";
137
+ var TAB = 9;
138
+ var LF = 10;
139
+ var CR = 13;
140
+ var SPACE = 32;
141
+ var BOM = 65279;
142
+ function markdownLineFrom(source, start) {
143
+ for (let i = start; i < source.length; i += 1) {
144
+ const unit = source.charCodeAt(i);
145
+ if (unit === LF) return { end: i, next: i + 1 };
146
+ if (unit === CR) return { end: i, next: source.charCodeAt(i + 1) === LF ? i + 2 : i + 1 };
147
+ }
148
+ return { end: source.length, next: source.length };
149
+ }
150
+ function isBlankRun(source, from, to) {
151
+ for (let i = from; i < to; i += 1) {
152
+ const unit = source.charCodeAt(i);
153
+ if (unit !== SPACE && unit !== TAB) return false;
154
+ }
155
+ return true;
156
+ }
157
+ function isDelimiterLine(source, start, line, delimiter) {
158
+ return source.startsWith(delimiter, start) && isBlankRun(source, start + delimiter.length, line.end);
159
+ }
160
+ function locateFrontmatter(source) {
161
+ const start = source.charCodeAt(0) === BOM ? 1 : 0;
162
+ const matter = source.startsWith(YAML_DELIMITER, start) ? "yaml" : source.startsWith(TOML_DELIMITER, start) ? "toml" : null;
163
+ if (matter === null) return null;
164
+ const delimiter = matter === "yaml" ? YAML_DELIMITER : TOML_DELIMITER;
165
+ const opener = markdownLineFrom(source, start);
166
+ if (!isBlankRun(source, start + delimiter.length, opener.end)) return null;
167
+ const contentStart = opener.next;
168
+ for (let at = contentStart; at < source.length; ) {
169
+ const line = markdownLineFrom(source, at);
170
+ if (isDelimiterLine(source, at, line, delimiter)) {
171
+ return { matter, start, end: line.end, contentStart, contentEnd: at };
172
+ }
173
+ at = line.next;
174
+ }
175
+ return null;
176
+ }
177
+ function maskFrontmatter(source, block) {
178
+ if (block === null) return source;
179
+ let masked = "";
180
+ for (let i = 0; i < block.end; i += 1) {
181
+ const unit = source.charCodeAt(i);
182
+ masked += unit === LF || unit === CR ? source[i] : " ";
183
+ }
184
+ return masked + source.slice(block.end);
185
+ }
118
186
  function markdownSpans(source, dialect) {
119
- const events = wrapParserErrors(dialect, () => tokenize(source, extensionsFor(dialect)));
187
+ const block = locateFrontmatter(source);
188
+ const masked = maskFrontmatter(source, block);
189
+ const shift = masked.charCodeAt(0) === BOM ? 1 : 0;
190
+ const text = shift === 0 ? masked : masked.slice(shift);
191
+ const events = wrapParserErrors(dialect, () => tokenize(text, extensionsFor(dialect)));
120
192
  const spans = [];
121
193
  const elementStack = [];
122
194
  let skipDepth = 0;
@@ -130,7 +202,7 @@ function markdownSpans(source, dialect) {
130
202
  if (kind === "enter") {
131
203
  updateElementStack(
132
204
  elementStack,
133
- source.slice(token.start.offset, token.end.offset),
205
+ text.slice(token.start.offset, token.end.offset),
134
206
  type !== "htmlText"
135
207
  );
136
208
  }
@@ -140,8 +212,8 @@ function markdownSpans(source, dialect) {
140
212
  if (type === "htmlFlow") {
141
213
  if (kind === "enter" && skipDepth === 0 && elementStack.length === 0) {
142
214
  for (const span of htmlFragmentSpans(
143
- source.slice(token.start.offset, token.end.offset),
144
- token.start.offset
215
+ text.slice(token.start.offset, token.end.offset),
216
+ token.start.offset + shift
145
217
  )) {
146
218
  spans.push(span);
147
219
  }
@@ -150,10 +222,40 @@ function markdownSpans(source, dialect) {
150
222
  continue;
151
223
  }
152
224
  if (kind === "enter" && type === "data" && skipDepth === 0 && elementStack.length === 0) {
153
- spans.push({ start: token.start.offset, end: token.end.offset });
225
+ spans.push({ start: token.start.offset + shift, end: token.end.offset + shift });
226
+ }
227
+ }
228
+ if (block === null) return spans;
229
+ return spans.flatMap((span) => {
230
+ if (span.start >= block.end) return [span];
231
+ if (span.end <= block.end) return [];
232
+ return [{ start: block.end, end: span.end }];
233
+ });
234
+ }
235
+ function declinedContentRanges(content) {
236
+ const declined = [];
237
+ let start = 0;
238
+ while (start < content.length) {
239
+ const lf = content.indexOf("\n", start);
240
+ const next = lf === -1 ? content.length : lf + 1;
241
+ for (let i = start; i < next; i += 1) {
242
+ if (content.charCodeAt(i) === CR && content.charCodeAt(i + 1) !== LF) {
243
+ declined.push({ start, end: next });
244
+ break;
245
+ }
154
246
  }
247
+ start = next;
155
248
  }
156
- return spans;
249
+ return declined;
250
+ }
251
+ function frontmatterSpans(source, frontmatterKeys) {
252
+ if (frontmatterKeys.length === 0) return [];
253
+ const block = locateFrontmatter(source);
254
+ if (block === null || block.matter === "toml") return [];
255
+ const { contentStart, contentEnd } = block;
256
+ const content = source.slice(contentStart, contentEnd);
257
+ const declined = declinedContentRanges(content);
258
+ return yamlSpans(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 }));
157
259
  }
158
260
 
159
261
  // src/engine/markdown-pipeline.ts
@@ -162,17 +264,24 @@ function runMarkdownPipeline(input, options) {
162
264
  const planned = planRules(options.rules);
163
265
  const locale = getLocaleData(options.locale);
164
266
  const dialect = resolveDialect(options.dialect);
165
- const spans = markdownSpans(input, dialect);
166
- return runOverSpans(input, spans, planned, locale, "markdown", narrowTarget);
267
+ const frontmatterKeys = resolveFrontmatterKeys(options.frontmatterKeys);
268
+ const units = unitsOf(input, dialect, frontmatterKeys);
269
+ return runOverUnits(input, units, planned, locale, "markdown", narrowTarget);
270
+ }
271
+ function unitsOf(input, dialect, frontmatterKeys) {
272
+ const body = markdownSpans(input, dialect);
273
+ if (frontmatterKeys === void 0) return [body];
274
+ return [frontmatterSpans(input, frontmatterKeys), body];
167
275
  }
168
276
  function analyzeMarkdownPipeline(input, options) {
169
277
  const narrowTarget = resolveNarrowTarget(options.narrowNbsp);
170
278
  const planned = planRules(options.rules);
171
279
  const locale = getLocaleData(options.locale);
172
280
  const dialect = resolveDialect(options.dialect);
173
- return analyzeOverSpans(
281
+ const frontmatterKeys = resolveFrontmatterKeys(options.frontmatterKeys);
282
+ return analyzeOverUnits(
174
283
  input,
175
- markdownSpans(input, dialect),
284
+ unitsOf(input, dialect, frontmatterKeys),
176
285
  planned,
177
286
  locale,
178
287
  "markdown",
@@ -184,4 +293,4 @@ export {
184
293
  runMarkdownPipeline,
185
294
  analyzeMarkdownPipeline
186
295
  };
187
- //# sourceMappingURL=chunk-27B32RJQ.js.map
296
+ //# sourceMappingURL=chunk-YH77XVJB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/modes/markdown.ts","../src/engine/markdown-pipeline.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,OAAO,aAAa,kBAAkB;AAC/C,SAAS,mBAAmB;AAC5B,SAAS,WAAW;AACpB,SAAS,aAAa;AAiBtB,IAAM,sBAA2C,oBAAI,IAAI;AAAA;AAAA,EAEvD;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA;AAAA,EACA;AACF,CAAC;AAGD,IAAM,sBAA2C,oBAAI,IAAI;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,YAAY;AAClB,IAAM,eAAe;AACrB,IAAM,QAAQ;AACd,IAAM,cAAc;AACpB,IAAM,WAAW;AAEjB,SAAS,cAAc,MAAuB;AAC5C,SAAQ,QAAQ,MAAQ,QAAQ,OAAU,QAAQ,MAAQ,QAAQ;AACpE;AAEA,SAAS,cAAc,MAAuB;AAI5C,SACE,SAAS,gBACT,SAAS,SACT,SAAS,MACT,SAAS,KACT,SAAS,MACT,SAAS;AAEb;AAGA,SAAS,WAAW,OAAuB;AACzC,MAAI,MAAM;AACV,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;AACxC,UAAM,OAAO,MAAM,WAAW,CAAC;AAC/B,WAAO,QAAQ,MAAQ,QAAQ,KAAO,OAAO,aAAa,OAAO,EA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O,cAAc,OAAO,OAAO;AACzC,MAAI,oBAAoB,OAAW,QAAO,CAAC,IAAI;AAC/C,SAAO,CAAC,iBAAiB,OAAO,eAAe,GAAG,IAAI;AACxD;AAKO,SAAS,wBAAwB,OAAe,SAAqC;AAC1F,QAAM,eAAe,oBAAoB,QAAQ,UAAU;AAC3D,QAAM,UAAU,UAAU,QAAQ,KAAK;AACvC,QAAM,SAAS,cAAc,QAAQ,MAAM;AAC3C,QAAM,UAAU,eAAe,QAAQ,OAAO;AAC9C,QAAM,kBAAkB,uBAAuB,QAAQ,eAAe;AACtE,SAAO;AAAA,IACL;AAAA,IACA,QAAQ,OAAO,SAAS,eAAe;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -20,6 +20,14 @@ interface Options {
20
20
  * guesses. An empty list is legal and processes nothing.
21
21
  */
22
22
  keys?: readonly string[];
23
+ /**
24
+ * Optional, and only meaningful when `mode` is `"markdown"` (spec/rules/modes.md §3.7.4, spec
25
+ * 1.7.0). The keys in the document's YAML frontmatter block whose scalar values are
26
+ * processable, scanned by the same scan `yaml` mode uses. Absent means the block is skipped
27
+ * whole, as it was before 1.7.0; an empty list is legal and yields no spans. The block is its
28
+ * own text unit, so this option can never change a byte outside it.
29
+ */
30
+ frontmatterKeys?: readonly string[];
23
31
  /**
24
32
  * Per-rule override, keyed by `RuleId`. For a default-on rule (every rule except `ranges`),
25
33
  * `false` disables it and `true` is a no-op. For `ranges` — off by default (spec 0.5.0) —
@@ -20,6 +20,14 @@ interface Options {
20
20
  * guesses. An empty list is legal and processes nothing.
21
21
  */
22
22
  keys?: readonly string[];
23
+ /**
24
+ * Optional, and only meaningful when `mode` is `"markdown"` (spec/rules/modes.md §3.7.4, spec
25
+ * 1.7.0). The keys in the document's YAML frontmatter block whose scalar values are
26
+ * processable, scanned by the same scan `yaml` mode uses. Absent means the block is skipped
27
+ * whole, as it was before 1.7.0; an empty list is legal and yields no spans. The block is its
28
+ * own text unit, so this option can never change a byte outside it.
29
+ */
30
+ frontmatterKeys?: readonly string[];
23
31
  /**
24
32
  * Per-rule override, keyed by `RuleId`. For a default-on rule (every rule except `ranges`),
25
33
  * `false` disables it and `true` is a no-op. For `ranges` — off by default (spec 0.5.0) —
package/dist/html.cjs CHANGED
@@ -1,30 +1,30 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
3
 
4
- var _chunkTV4AZVHZcjs = require('./chunk-TV4AZVHZ.cjs');
5
- require('./chunk-BCU7YHWD.cjs');
6
- require('./chunk-7DKZNZUD.cjs');
4
+ var _chunkUJ3D4DYPcjs = require('./chunk-UJ3D4DYP.cjs');
5
+ require('./chunk-M3TVDUGX.cjs');
6
+ require('./chunk-UWFI3XV7.cjs');
7
7
 
8
8
 
9
- var _chunkJT3VGUUUcjs = require('./chunk-JT3VGUUU.cjs');
9
+ var _chunkGK5P55K5cjs = require('./chunk-GK5P55K5.cjs');
10
10
 
11
11
 
12
- var _chunkUB7HJ4MXcjs = require('./chunk-UB7HJ4MX.cjs');
12
+ var _chunkGUROIWJYcjs = require('./chunk-GUROIWJY.cjs');
13
13
 
14
14
  // src/index.html.ts
15
15
  function transform(input, options) {
16
16
  const given = _nullishCoalesce(options, () => ( {}));
17
- _chunkJT3VGUUUcjs.assertFixedMode.call(void 0, given.mode, "html", "polytypo/html");
18
- return _chunkTV4AZVHZcjs.runHtmlPipeline.call(void 0, input, given);
17
+ _chunkGK5P55K5cjs.assertFixedMode.call(void 0, given.mode, "html", "polytypo/html");
18
+ return _chunkUJ3D4DYPcjs.runHtmlPipeline.call(void 0, input, given);
19
19
  }
20
20
  function analyze(input, options) {
21
21
  const given = _nullishCoalesce(options, () => ( {}));
22
- _chunkJT3VGUUUcjs.assertFixedMode.call(void 0, given.mode, "html", "polytypo/html");
23
- return _chunkTV4AZVHZcjs.analyzeHtmlPipeline.call(void 0, input, given);
22
+ _chunkGK5P55K5cjs.assertFixedMode.call(void 0, given.mode, "html", "polytypo/html");
23
+ return _chunkUJ3D4DYPcjs.analyzeHtmlPipeline.call(void 0, input, given);
24
24
  }
25
25
 
26
26
 
27
27
 
28
28
 
29
- exports.PolytypoError = _chunkUB7HJ4MXcjs.PolytypoError; exports.analyze = analyze; exports.transform = transform;
29
+ exports.PolytypoError = _chunkGUROIWJYcjs.PolytypoError; exports.analyze = analyze; exports.transform = transform;
30
30
  //# sourceMappingURL=html.cjs.map
package/dist/html.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/html.cjs","../src/index.html.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACGO,SAAS,SAAA,CAAU,KAAA,EAAe,OAAA,EAA8B;AACrE,EAAA,MAAM,MAAA,mBAAS,OAAA,UAAW,CAAC,GAAA;AAC3B,EAAA,+CAAA,KAAgB,CAAM,IAAA,EAAM,MAAA,EAAQ,eAAe,CAAA;AACnD,EAAA,OAAO,+CAAA,KAAgB,EAAO,KAAK,CAAA;AACrC;AAOO,SAAS,OAAA,CAAQ,KAAA,EAAe,OAAA,EAAgC;AACrE,EAAA,MAAM,MAAA,mBAAS,OAAA,UAAW,CAAC,GAAA;AAC3B,EAAA,+CAAA,KAAgB,CAAM,IAAA,EAAM,MAAA,EAAQ,eAAe,CAAA;AACnD,EAAA,OAAO,mDAAA,KAAoB,EAAO,KAAK,CAAA;AACzC;ADPA;AACE;AACA;AACA;AACF,kHAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/html.cjs","sourcesContent":[null,"import { assertFixedMode } from \"./engine/assert-fixed-mode.js\";\nimport { analyzeHtmlPipeline, runHtmlPipeline } from \"./engine/html-pipeline.js\";\nimport type { Change } from \"./engine/origin.js\";\nimport type { Options } from \"./types.js\";\n\n/**\n * `polytypo/html` — HTML-only entry point. Its module graph includes `parse5` but excludes the\n * Micromark/MDX stack (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1): it imports\n * `./engine/html-pipeline.js` directly and never `./engine/pipeline.js` or `./modes/markdown.js`.\n *\n * `mode` is absent from `HtmlOptions`, since this entry only ever runs `html` mode. `dialect` is\n * likewise absent — it has no effect in `html` mode even in the aggregate entry (types.ts), so\n * there is nothing for it to conflict with here.\n */\nexport type HtmlOptions = Omit<Options, \"mode\" | \"dialect\">;\n\nexport function transform(input: string, options: HtmlOptions): string {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return runHtmlPipeline(input, given);\n}\n\n/**\n * The same pipeline as this entry's `transform`, reporting instead of applying\n * (spec/rules/analyze.md). Offsets are code-point offsets into `input` — into the document,\n * not into a span (analyze.md §6).\n */\nexport function analyze(input: string, options: HtmlOptions): Change[] {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return analyzeHtmlPipeline(input, given);\n}\n\nexport { PolytypoError } from \"./errors.js\";\nexport type { PolytypoErrorCode } from \"./errors.js\";\nexport type { Change } from \"./engine/origin.js\";\nexport type { NarrowNbsp } from \"./types.js\";\nexport type { LocaleData, LocaleSource, QuotePair, Rule, RuleContext, RuleId } from \"./types.js\";\n"]}
1
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/html.cjs","../src/index.html.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACGO,SAAS,SAAA,CAAU,KAAA,EAAe,OAAA,EAA8B;AACrE,EAAA,MAAM,MAAA,mBAAS,OAAA,UAAW,CAAC,GAAA;AAC3B,EAAA,+CAAA,KAAgB,CAAM,IAAA,EAAM,MAAA,EAAQ,eAAe,CAAA;AACnD,EAAA,OAAO,+CAAA,KAAgB,EAAO,KAAK,CAAA;AACrC;AAOO,SAAS,OAAA,CAAQ,KAAA,EAAe,OAAA,EAAgC;AACrE,EAAA,MAAM,MAAA,mBAAS,OAAA,UAAW,CAAC,GAAA;AAC3B,EAAA,+CAAA,KAAgB,CAAM,IAAA,EAAM,MAAA,EAAQ,eAAe,CAAA;AACnD,EAAA,OAAO,mDAAA,KAAoB,EAAO,KAAK,CAAA;AACzC;ADPA;AACE;AACA;AACA;AACF,kHAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/html.cjs","sourcesContent":[null,"import { assertFixedMode } from \"./engine/assert-fixed-mode.js\";\nimport { analyzeHtmlPipeline, runHtmlPipeline } from \"./engine/html-pipeline.js\";\nimport type { Change } from \"./engine/origin.js\";\nimport type { Options } from \"./types.js\";\n\n/**\n * `polytypo/html` — HTML-only entry point. Its module graph includes `parse5` but excludes the\n * Micromark/MDX stack (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1): it imports\n * `./engine/html-pipeline.js` directly and never `./engine/pipeline.js` or `./modes/markdown.js`.\n *\n * `mode` is absent from `HtmlOptions`, since this entry only ever runs `html` mode. `dialect` is\n * likewise absent — it has no effect in `html` mode even in the aggregate entry (types.ts), so\n * there is nothing for it to conflict with here.\n */\nexport type HtmlOptions = Omit<Options, \"mode\" | \"dialect\" | \"frontmatterKeys\">;\n\nexport function transform(input: string, options: HtmlOptions): string {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return runHtmlPipeline(input, given);\n}\n\n/**\n * The same pipeline as this entry's `transform`, reporting instead of applying\n * (spec/rules/analyze.md). Offsets are code-point offsets into `input` — into the document,\n * not into a span (analyze.md §6).\n */\nexport function analyze(input: string, options: HtmlOptions): Change[] {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return analyzeHtmlPipeline(input, given);\n}\n\nexport { PolytypoError } from \"./errors.js\";\nexport type { PolytypoErrorCode } from \"./errors.js\";\nexport type { Change } from \"./engine/origin.js\";\nexport type { NarrowNbsp } from \"./types.js\";\nexport type { LocaleData, LocaleSource, QuotePair, Rule, RuleContext, RuleId } from \"./types.js\";\n"]}
package/dist/html.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as Options, C as Change } from './errors-C1_sHGgx.cjs';
2
- export { L as LocaleData, a as LocaleSource, N as NarrowNbsp, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-C1_sHGgx.cjs';
1
+ import { O as Options, C as Change } from './errors-DeHxbXRn.cjs';
2
+ export { L as LocaleData, a as LocaleSource, N as NarrowNbsp, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-DeHxbXRn.cjs';
3
3
 
4
4
  /**
5
5
  * `polytypo/html` — HTML-only entry point. Its module graph includes `parse5` but excludes the
@@ -10,7 +10,7 @@ export { L as LocaleData, a as LocaleSource, N as NarrowNbsp, P as PolytypoError
10
10
  * likewise absent — it has no effect in `html` mode even in the aggregate entry (types.ts), so
11
11
  * there is nothing for it to conflict with here.
12
12
  */
13
- type HtmlOptions = Omit<Options, "mode" | "dialect">;
13
+ type HtmlOptions = Omit<Options, "mode" | "dialect" | "frontmatterKeys">;
14
14
  declare function transform(input: string, options: HtmlOptions): string;
15
15
  /**
16
16
  * The same pipeline as this entry's `transform`, reporting instead of applying
package/dist/html.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as Options, C as Change } from './errors-C1_sHGgx.js';
2
- export { L as LocaleData, a as LocaleSource, N as NarrowNbsp, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-C1_sHGgx.js';
1
+ import { O as Options, C as Change } from './errors-DeHxbXRn.js';
2
+ export { L as LocaleData, a as LocaleSource, N as NarrowNbsp, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-DeHxbXRn.js';
3
3
 
4
4
  /**
5
5
  * `polytypo/html` — HTML-only entry point. Its module graph includes `parse5` but excludes the
@@ -10,7 +10,7 @@ export { L as LocaleData, a as LocaleSource, N as NarrowNbsp, P as PolytypoError
10
10
  * likewise absent — it has no effect in `html` mode even in the aggregate entry (types.ts), so
11
11
  * there is nothing for it to conflict with here.
12
12
  */
13
- type HtmlOptions = Omit<Options, "mode" | "dialect">;
13
+ type HtmlOptions = Omit<Options, "mode" | "dialect" | "frontmatterKeys">;
14
14
  declare function transform(input: string, options: HtmlOptions): string;
15
15
  /**
16
16
  * The same pipeline as this entry's `transform`, reporting instead of applying
package/dist/html.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  analyzeHtmlPipeline,
3
3
  runHtmlPipeline
4
- } from "./chunk-UOPLHOTJ.js";
5
- import "./chunk-RZYVLO3Z.js";
6
- import "./chunk-OHMN6WPZ.js";
4
+ } from "./chunk-4RAZ2EDS.js";
5
+ import "./chunk-PEBD5XTD.js";
6
+ import "./chunk-F6HVIPLF.js";
7
7
  import {
8
8
  assertFixedMode
9
- } from "./chunk-UIUJSDBS.js";
9
+ } from "./chunk-EH542ZE4.js";
10
10
  import {
11
11
  PolytypoError
12
- } from "./chunk-VVBJZBXR.js";
12
+ } from "./chunk-EQ2JTKYF.js";
13
13
 
14
14
  // src/index.html.ts
15
15
  function transform(input, options) {
package/dist/html.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.html.ts"],"sourcesContent":["import { assertFixedMode } from \"./engine/assert-fixed-mode.js\";\nimport { analyzeHtmlPipeline, runHtmlPipeline } from \"./engine/html-pipeline.js\";\nimport type { Change } from \"./engine/origin.js\";\nimport type { Options } from \"./types.js\";\n\n/**\n * `polytypo/html` — HTML-only entry point. Its module graph includes `parse5` but excludes the\n * Micromark/MDX stack (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1): it imports\n * `./engine/html-pipeline.js` directly and never `./engine/pipeline.js` or `./modes/markdown.js`.\n *\n * `mode` is absent from `HtmlOptions`, since this entry only ever runs `html` mode. `dialect` is\n * likewise absent — it has no effect in `html` mode even in the aggregate entry (types.ts), so\n * there is nothing for it to conflict with here.\n */\nexport type HtmlOptions = Omit<Options, \"mode\" | \"dialect\">;\n\nexport function transform(input: string, options: HtmlOptions): string {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return runHtmlPipeline(input, given);\n}\n\n/**\n * The same pipeline as this entry's `transform`, reporting instead of applying\n * (spec/rules/analyze.md). Offsets are code-point offsets into `input` — into the document,\n * not into a span (analyze.md §6).\n */\nexport function analyze(input: string, options: HtmlOptions): Change[] {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return analyzeHtmlPipeline(input, given);\n}\n\nexport { PolytypoError } from \"./errors.js\";\nexport type { PolytypoErrorCode } from \"./errors.js\";\nexport type { Change } from \"./engine/origin.js\";\nexport type { NarrowNbsp } from \"./types.js\";\nexport type { LocaleData, LocaleSource, QuotePair, Rule, RuleContext, RuleId } from \"./types.js\";\n"],"mappings":";;;;;;;;;;;;;;AAgBO,SAAS,UAAU,OAAe,SAA8B;AACrE,QAAM,QAAS,WAAW,CAAC;AAC3B,kBAAgB,MAAM,MAAM,QAAQ,eAAe;AACnD,SAAO,gBAAgB,OAAO,KAAK;AACrC;AAOO,SAAS,QAAQ,OAAe,SAAgC;AACrE,QAAM,QAAS,WAAW,CAAC;AAC3B,kBAAgB,MAAM,MAAM,QAAQ,eAAe;AACnD,SAAO,oBAAoB,OAAO,KAAK;AACzC;","names":[]}
1
+ {"version":3,"sources":["../src/index.html.ts"],"sourcesContent":["import { assertFixedMode } from \"./engine/assert-fixed-mode.js\";\nimport { analyzeHtmlPipeline, runHtmlPipeline } from \"./engine/html-pipeline.js\";\nimport type { Change } from \"./engine/origin.js\";\nimport type { Options } from \"./types.js\";\n\n/**\n * `polytypo/html` — HTML-only entry point. Its module graph includes `parse5` but excludes the\n * Micromark/MDX stack (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1): it imports\n * `./engine/html-pipeline.js` directly and never `./engine/pipeline.js` or `./modes/markdown.js`.\n *\n * `mode` is absent from `HtmlOptions`, since this entry only ever runs `html` mode. `dialect` is\n * likewise absent — it has no effect in `html` mode even in the aggregate entry (types.ts), so\n * there is nothing for it to conflict with here.\n */\nexport type HtmlOptions = Omit<Options, \"mode\" | \"dialect\" | \"frontmatterKeys\">;\n\nexport function transform(input: string, options: HtmlOptions): string {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return runHtmlPipeline(input, given);\n}\n\n/**\n * The same pipeline as this entry's `transform`, reporting instead of applying\n * (spec/rules/analyze.md). Offsets are code-point offsets into `input` — into the document,\n * not into a span (analyze.md §6).\n */\nexport function analyze(input: string, options: HtmlOptions): Change[] {\n const given = (options ?? {}) as Partial<Options>;\n assertFixedMode(given.mode, \"html\", \"polytypo/html\");\n return analyzeHtmlPipeline(input, given);\n}\n\nexport { PolytypoError } from \"./errors.js\";\nexport type { PolytypoErrorCode } from \"./errors.js\";\nexport type { Change } from \"./engine/origin.js\";\nexport type { NarrowNbsp } from \"./types.js\";\nexport type { LocaleData, LocaleSource, QuotePair, Rule, RuleContext, RuleId } from \"./types.js\";\n"],"mappings":";;;;;;;;;;;;;;AAgBO,SAAS,UAAU,OAAe,SAA8B;AACrE,QAAM,QAAS,WAAW,CAAC;AAC3B,kBAAgB,MAAM,MAAM,QAAQ,eAAe;AACnD,SAAO,gBAAgB,OAAO,KAAK;AACrC;AAOO,SAAS,QAAQ,OAAe,SAAgC;AACrE,QAAM,QAAS,WAAW,CAAC;AAC3B,kBAAgB,MAAM,MAAM,QAAQ,eAAe;AACnD,SAAO,oBAAoB,OAAO,KAAK;AACzC;","names":[]}
package/dist/index.cjs CHANGED
@@ -1,30 +1,31 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
3
 
4
- var _chunkGZSUAD6Mcjs = require('./chunk-GZSUAD6M.cjs');
4
+ var _chunkYA64BEKCcjs = require('./chunk-YA64BEKC.cjs');
5
5
 
6
6
 
7
7
 
8
- var _chunkTV4AZVHZcjs = require('./chunk-TV4AZVHZ.cjs');
8
+ var _chunkUJ3D4DYPcjs = require('./chunk-UJ3D4DYP.cjs');
9
9
 
10
10
 
11
11
 
12
- var _chunkRNH6KTYZcjs = require('./chunk-RNH6KTYZ.cjs');
13
- require('./chunk-BCU7YHWD.cjs');
12
+ var _chunkVBHUVDW4cjs = require('./chunk-VBHUVDW4.cjs');
13
+ require('./chunk-M3TVDUGX.cjs');
14
14
 
15
15
 
16
16
 
17
- var _chunk2XWZW3RUcjs = require('./chunk-2XWZW3RU.cjs');
18
- require('./chunk-7DKZNZUD.cjs');
17
+ var _chunkKFDDI4LHcjs = require('./chunk-KFDDI4LH.cjs');
18
+ require('./chunk-KAJ3GVK2.cjs');
19
+ require('./chunk-UWFI3XV7.cjs');
19
20
 
20
21
 
21
- var _chunkUB7HJ4MXcjs = require('./chunk-UB7HJ4MX.cjs');
22
+ var _chunkGUROIWJYcjs = require('./chunk-GUROIWJY.cjs');
22
23
 
23
24
  // src/engine/pipeline.ts
24
25
  function resolveMode(mode) {
25
26
  if (mode === void 0 || mode === "text") return "text";
26
27
  if (mode === "html" || mode === "markdown" || mode === "yaml") return mode;
27
- throw new (0, _chunkUB7HJ4MXcjs.PolytypoError)(
28
+ throw new (0, _chunkGUROIWJYcjs.PolytypoError)(
28
29
  "POLYTYPO_INVALID_MODE",
29
30
  `Unknown mode "${String(mode)}". Expected "text", "html", "markdown" or "yaml".`
30
31
  );
@@ -32,18 +33,18 @@ function resolveMode(mode) {
32
33
  function runPipeline(input, options) {
33
34
  const given = _nullishCoalesce(options, () => ( {}));
34
35
  const mode = resolveMode(given.mode);
35
- if (mode === "text") return _chunkGZSUAD6Mcjs.runTextPipeline.call(void 0, input, given);
36
- if (mode === "html") return _chunkTV4AZVHZcjs.runHtmlPipeline.call(void 0, input, given);
37
- if (mode === "yaml") return _chunk2XWZW3RUcjs.runYamlPipeline.call(void 0, input, given);
38
- return _chunkRNH6KTYZcjs.runMarkdownPipeline.call(void 0, input, given);
36
+ if (mode === "text") return _chunkYA64BEKCcjs.runTextPipeline.call(void 0, input, given);
37
+ if (mode === "html") return _chunkUJ3D4DYPcjs.runHtmlPipeline.call(void 0, input, given);
38
+ if (mode === "yaml") return _chunkKFDDI4LHcjs.runYamlPipeline.call(void 0, input, given);
39
+ return _chunkVBHUVDW4cjs.runMarkdownPipeline.call(void 0, input, given);
39
40
  }
40
41
  function runAnalyze(input, options) {
41
42
  const given = _nullishCoalesce(options, () => ( {}));
42
43
  const mode = resolveMode(given.mode);
43
- if (mode === "text") return _chunkGZSUAD6Mcjs.analyzeTextPipeline.call(void 0, input, given);
44
- if (mode === "html") return _chunkTV4AZVHZcjs.analyzeHtmlPipeline.call(void 0, input, given);
45
- if (mode === "yaml") return _chunk2XWZW3RUcjs.analyzeYamlPipeline.call(void 0, input, given);
46
- return _chunkRNH6KTYZcjs.analyzeMarkdownPipeline.call(void 0, input, given);
44
+ if (mode === "text") return _chunkYA64BEKCcjs.analyzeTextPipeline.call(void 0, input, given);
45
+ if (mode === "html") return _chunkUJ3D4DYPcjs.analyzeHtmlPipeline.call(void 0, input, given);
46
+ if (mode === "yaml") return _chunkKFDDI4LHcjs.analyzeYamlPipeline.call(void 0, input, given);
47
+ return _chunkVBHUVDW4cjs.analyzeMarkdownPipeline.call(void 0, input, given);
47
48
  }
48
49
 
49
50
  // src/index.ts
@@ -57,5 +58,5 @@ function analyze(input, options) {
57
58
 
58
59
 
59
60
 
60
- exports.PolytypoError = _chunkUB7HJ4MXcjs.PolytypoError; exports.analyze = analyze; exports.transform = transform;
61
+ exports.PolytypoError = _chunkGUROIWJYcjs.PolytypoError; exports.analyze = analyze; exports.transform = transform;
61
62
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/index.cjs","../src/engine/pipeline.ts","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACZA,SAAS,WAAA,CAAY,IAAA,EAA8B;AACjD,EAAA,GAAA,CAAI,KAAA,IAAS,KAAA,EAAA,GAAa,KAAA,IAAS,MAAA,EAAQ,OAAO,MAAA;AAClD,EAAA,GAAA,CAAI,KAAA,IAAS,OAAA,GAAU,KAAA,IAAS,WAAA,GAAc,KAAA,IAAS,MAAA,EAAQ,OAAO,IAAA;AACtE,EAAA,MAAM,IAAI,oCAAA;AAAA,IACR,uBAAA;AAAA,IACA,CAAA,cAAA,EAAiB,MAAA,CAAO,IAAI,CAAC,CAAA,iDAAA;AAAA,EAC/B,CAAA;AACF;AASO,SAAS,WAAA,CAAY,KAAA,EAAe,OAAA,EAA0B;AAInE,EAAA,MAAM,MAAA,mBAA0B,OAAA,UAAW,CAAC,GAAA;AAC5C,EAAA,MAAM,KAAA,EAAO,WAAA,CAAY,KAAA,CAAM,IAAI,CAAA;AACnC,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,OAAO,+CAAA,KAAgB,EAAO,KAAK,CAAA;AACxD,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,OAAO,+CAAA,KAAgB,EAAO,KAAK,CAAA;AACxD,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,OAAO,+CAAA,KAAgB,EAAO,KAAK,CAAA;AACxD,EAAA,OAAO,mDAAA,KAAoB,EAAO,KAAK,CAAA;AACzC;AAOO,SAAS,UAAA,CAAW,KAAA,EAAe,OAAA,EAA4B;AACpE,EAAA,MAAM,MAAA,mBAA0B,OAAA,UAAW,CAAC,GAAA;AAC5C,EAAA,MAAM,KAAA,EAAO,WAAA,CAAY,KAAA,CAAM,IAAI,CAAA;AACnC,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,OAAO,mDAAA,KAAoB,EAAO,KAAK,CAAA;AAC5D,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,OAAO,mDAAA,KAAoB,EAAO,KAAK,CAAA;AAC5D,EAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,OAAO,mDAAA,KAAoB,EAAO,KAAK,CAAA;AAC5D,EAAA,OAAO,uDAAA,KAAwB,EAAO,KAAK,CAAA;AAC7C;ADHA;AACA;AE5CO,SAAS,SAAA,CAAU,KAAA,EAAe,OAAA,EAA0B;AACjE,EAAA,OAAO,WAAA,CAAY,KAAA,EAAO,OAAO,CAAA;AACnC;AAYO,SAAS,OAAA,CAAQ,KAAA,EAAe,OAAA,EAA4B;AACjE,EAAA,OAAO,UAAA,CAAW,KAAA,EAAO,OAAO,CAAA;AAClC;AFmCA;AACE;AACA;AACA;AACF,kHAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/index.cjs","sourcesContent":[null,"import { PolytypoError } from \"../errors.js\";\nimport type { Mode, Options } from \"../types.js\";\nimport { analyzeHtmlPipeline, runHtmlPipeline } from \"./html-pipeline.js\";\nimport { analyzeMarkdownPipeline, runMarkdownPipeline } from \"./markdown-pipeline.js\";\nimport { analyzeTextPipeline, runTextPipeline } from \"./text-pipeline.js\";\nimport { analyzeYamlPipeline, runYamlPipeline } from \"./yaml-pipeline.js\";\nimport type { Change } from \"./origin.js\";\n\nexport { planRules } from \"./rule-runner.js\";\n\nfunction resolveMode(mode: Mode | undefined): Mode {\n if (mode === undefined || mode === \"text\") return \"text\";\n if (mode === \"html\" || mode === \"markdown\" || mode === \"yaml\") return mode;\n throw new PolytypoError(\n \"POLYTYPO_INVALID_MODE\",\n `Unknown mode \"${String(mode)}\". Expected \"text\", \"html\", \"markdown\" or \"yaml\".`,\n );\n}\n\n/**\n * The aggregate entry's dispatcher: every mode is reachable, so it is the only pipeline module\n * that imports all four mode-specific ones (and therefore the only one whose module graph\n * includes both `parse5` and the Micromark/MDX stack). `polytypo/text`, `polytypo/html` and\n * `polytypo/markdown` each call their own mode-specific pipeline directly and never import this\n * module (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1).\n */\nexport function runPipeline(input: string, options: Options): string {\n // A plain-JS caller can omit the options object entirely. Reading through a null here would\n // raise a native TypeError, which is outside the error taxonomy; an absent `locale` is an\n // unknown locale and must say so with a code (locale-resolution.md 3.1).\n const given: Partial<Options> = options ?? {};\n const mode = resolveMode(given.mode);\n if (mode === \"text\") return runTextPipeline(input, given);\n if (mode === \"html\") return runHtmlPipeline(input, given);\n if (mode === \"yaml\") return runYamlPipeline(input, given);\n return runMarkdownPipeline(input, given);\n}\n\n/**\n * The dispatcher for `analyze` (analyze.md §1). Mode resolution, and therefore\n * POLYTYPO_INVALID_MODE, is shared with `runPipeline` rather than duplicated: A1 requires the\n * two entry points to accept and reject exactly the same arguments.\n */\nexport function runAnalyze(input: string, options: Options): Change[] {\n const given: Partial<Options> = options ?? {};\n const mode = resolveMode(given.mode);\n if (mode === \"text\") return analyzeTextPipeline(input, given);\n if (mode === \"html\") return analyzeHtmlPipeline(input, given);\n if (mode === \"yaml\") return analyzeYamlPipeline(input, given);\n return analyzeMarkdownPipeline(input, given);\n}\n","import { runAnalyze, runPipeline } from \"./engine/pipeline.js\";\nimport type { Change } from \"./engine/origin.js\";\nimport type { Options } from \"./types.js\";\n\nexport function transform(input: string, options: Options): string {\n return runPipeline(input, options);\n}\n\n/**\n * The same pipeline as `transform`, reporting what it would do instead of doing it\n * (spec/rules/analyze.md). Offsets are code-point offsets into `input` in every mode.\n *\n * What it guarantees: the list is empty exactly when `transform` would return the input\n * unchanged, every `ruleId` was enabled for the call, and every offset is inside the input.\n * What it does not: the list is a report, not a patch — two rules may touch the same original\n * range, so replaying it is not guaranteed to reproduce `transform`'s output. Call `transform`\n * for the text (analyze.md §4, §5).\n */\nexport function analyze(input: string, options: Options): Change[] {\n return runAnalyze(input, options);\n}\n\nexport { PolytypoError } from \"./errors.js\";\nexport type { PolytypoErrorCode } from \"./errors.js\";\nexport type { Change } from \"./engine/origin.js\";\nexport type {\n Dialect,\n Edit,\n LocaleData,\n LocaleSource,\n Mode,\n NarrowNbsp,\n Options,\n QuotePair,\n Rule,\n RuleContext,\n RuleId,\n} from \"./types.js\";\n"]}
1
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/index.cjs","../src/engine/pipeline.ts","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACbA,SAAS,WAAA,CAAY,IAAA,EAA8B;AACjD,EAAA,GAAA,CAAI,KAAA,IAAS,KAAA,EAAA,GAAa,KAAA,IAAS,MAAA,EAAQ,OAAO,MAAA;AAClD,EAAA,GAAA,CAAI,KAAA,IAAS,OAAA,GAAU,KAAA,IAAS,WAAA,GAAc,KAAA,IAAS,MAAA,EAAQ,OAAO,IAAA;AACtE,EAAA,MAAM,IAAI,oCAAA;AAAA,IACR,uBAAA;AAAA,IACA,CAAA,cAAA,EAAiB,MAAA,CAAO,IAAI,CAAC,CAAA,iDAAA;AAAA,EAC/B,CAAA;AACF;AASO,SAAS,WAAA,CAAY,KAAA,EAAe,OAAA,EAA0B;AAInE,EAAA,MAAM,MAAA,mBAA0B,OAA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ypoError } from \"../errors.js\";\nimport type { Mode, Options } from \"../types.js\";\nimport { analyzeHtmlPipeline, runHtmlPipeline } from \"./html-pipeline.js\";\nimport { analyzeMarkdownPipeline, runMarkdownPipeline } from \"./markdown-pipeline.js\";\nimport { analyzeTextPipeline, runTextPipeline } from \"./text-pipeline.js\";\nimport { analyzeYamlPipeline, runYamlPipeline } from \"./yaml-pipeline.js\";\nimport type { Change } from \"./origin.js\";\n\nexport { planRules } from \"./rule-runner.js\";\n\nfunction resolveMode(mode: Mode | undefined): Mode {\n if (mode === undefined || mode === \"text\") return \"text\";\n if (mode === \"html\" || mode === \"markdown\" || mode === \"yaml\") return mode;\n throw new PolytypoError(\n \"POLYTYPO_INVALID_MODE\",\n `Unknown mode \"${String(mode)}\". Expected \"text\", \"html\", \"markdown\" or \"yaml\".`,\n );\n}\n\n/**\n * The aggregate entry's dispatcher: every mode is reachable, so it is the only pipeline module\n * that imports all four mode-specific ones (and therefore the only one whose module graph\n * includes both `parse5` and the Micromark/MDX stack). `polytypo/text`, `polytypo/html` and\n * `polytypo/markdown` each call their own mode-specific pipeline directly and never import this\n * module (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1).\n */\nexport function runPipeline(input: string, options: Options): string {\n // A plain-JS caller can omit the options object entirely. Reading through a null here would\n // raise a native TypeError, which is outside the error taxonomy; an absent `locale` is an\n // unknown locale and must say so with a code (locale-resolution.md 3.1).\n const given: Partial<Options> = options ?? {};\n const mode = resolveMode(given.mode);\n if (mode === \"text\") return runTextPipeline(input, given);\n if (mode === \"html\") return runHtmlPipeline(input, given);\n if (mode === \"yaml\") return runYamlPipeline(input, given);\n return runMarkdownPipeline(input, given);\n}\n\n/**\n * The dispatcher for `analyze` (analyze.md §1). Mode resolution, and therefore\n * POLYTYPO_INVALID_MODE, is shared with `runPipeline` rather than duplicated: A1 requires the\n * two entry points to accept and reject exactly the same arguments.\n */\nexport function runAnalyze(input: string, options: Options): Change[] {\n const given: Partial<Options> = options ?? {};\n const mode = resolveMode(given.mode);\n if (mode === \"text\") return analyzeTextPipeline(input, given);\n if (mode === \"html\") return analyzeHtmlPipeline(input, given);\n if (mode === \"yaml\") return analyzeYamlPipeline(input, given);\n return analyzeMarkdownPipeline(input, given);\n}\n","import { runAnalyze, runPipeline } from \"./engine/pipeline.js\";\nimport type { Change } from \"./engine/origin.js\";\nimport type { Options } from \"./types.js\";\n\nexport function transform(input: string, options: Options): string {\n return runPipeline(input, options);\n}\n\n/**\n * The same pipeline as `transform`, reporting what it would do instead of doing it\n * (spec/rules/analyze.md). Offsets are code-point offsets into `input` in every mode.\n *\n * What it guarantees: the list is empty exactly when `transform` would return the input\n * unchanged, every `ruleId` was enabled for the call, and every offset is inside the input.\n * What it does not: the list is a report, not a patch — two rules may touch the same original\n * range, so replaying it is not guaranteed to reproduce `transform`'s output. Call `transform`\n * for the text (analyze.md §4, §5).\n */\nexport function analyze(input: string, options: Options): Change[] {\n return runAnalyze(input, options);\n}\n\nexport { PolytypoError } from \"./errors.js\";\nexport type { PolytypoErrorCode } from \"./errors.js\";\nexport type { Change } from \"./engine/origin.js\";\nexport type {\n Dialect,\n Edit,\n LocaleData,\n LocaleSource,\n Mode,\n NarrowNbsp,\n Options,\n QuotePair,\n Rule,\n RuleContext,\n RuleId,\n} from \"./types.js\";\n"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as Options, C as Change } from './errors-C1_sHGgx.cjs';
2
- export { D as Dialect, E as Edit, L as LocaleData, a as LocaleSource, M as Mode, N as NarrowNbsp, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-C1_sHGgx.cjs';
1
+ import { O as Options, C as Change } from './errors-DeHxbXRn.cjs';
2
+ export { D as Dialect, E as Edit, L as LocaleData, a as LocaleSource, M as Mode, N as NarrowNbsp, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-DeHxbXRn.cjs';
3
3
 
4
4
  declare function transform(input: string, options: Options): string;
5
5
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as Options, C as Change } from './errors-C1_sHGgx.js';
2
- export { D as Dialect, E as Edit, L as LocaleData, a as LocaleSource, M as Mode, N as NarrowNbsp, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-C1_sHGgx.js';
1
+ import { O as Options, C as Change } from './errors-DeHxbXRn.js';
2
+ export { D as Dialect, E as Edit, L as LocaleData, a as LocaleSource, M as Mode, N as NarrowNbsp, P as PolytypoError, b as PolytypoErrorCode, Q as QuotePair, R as Rule, c as RuleContext, d as RuleId } from './errors-DeHxbXRn.js';
3
3
 
4
4
  declare function transform(input: string, options: Options): string;
5
5
  /**
package/dist/index.js CHANGED
@@ -1,24 +1,25 @@
1
1
  import {
2
2
  analyzeTextPipeline,
3
3
  runTextPipeline
4
- } from "./chunk-ODTH774G.js";
4
+ } from "./chunk-XLTVLET5.js";
5
5
  import {
6
6
  analyzeHtmlPipeline,
7
7
  runHtmlPipeline
8
- } from "./chunk-UOPLHOTJ.js";
8
+ } from "./chunk-4RAZ2EDS.js";
9
9
  import {
10
10
  analyzeMarkdownPipeline,
11
11
  runMarkdownPipeline
12
- } from "./chunk-27B32RJQ.js";
13
- import "./chunk-RZYVLO3Z.js";
12
+ } from "./chunk-YH77XVJB.js";
13
+ import "./chunk-PEBD5XTD.js";
14
14
  import {
15
15
  analyzeYamlPipeline,
16
16
  runYamlPipeline
17
- } from "./chunk-4ELGGQ7B.js";
18
- import "./chunk-OHMN6WPZ.js";
17
+ } from "./chunk-6UQAKZ7L.js";
18
+ import "./chunk-KCKZHLI5.js";
19
+ import "./chunk-F6HVIPLF.js";
19
20
  import {
20
21
  PolytypoError
21
- } from "./chunk-VVBJZBXR.js";
22
+ } from "./chunk-EQ2JTKYF.js";
22
23
 
23
24
  // src/engine/pipeline.ts
24
25
  function resolveMode(mode) {