polytypo 1.2.0 → 1.3.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 (83) hide show
  1. package/README.md +48 -0
  2. package/dist/chunk-442V6TKI.cjs +31 -0
  3. package/dist/chunk-442V6TKI.cjs.map +1 -0
  4. package/dist/chunk-72GQS2N7.cjs +147 -0
  5. package/dist/chunk-72GQS2N7.cjs.map +1 -0
  6. package/dist/chunk-7S5PZ7T5.cjs +205 -0
  7. package/dist/chunk-7S5PZ7T5.cjs.map +1 -0
  8. package/dist/chunk-7ZJ7YYTQ.js +264 -0
  9. package/dist/chunk-7ZJ7YYTQ.js.map +1 -0
  10. package/dist/chunk-A3VCFDVL.cjs +264 -0
  11. package/dist/chunk-A3VCFDVL.cjs.map +1 -0
  12. package/dist/{chunk-KAO74OJ6.js → chunk-B3I7VL5E.js} +2 -2
  13. package/dist/chunk-DAUTLRFG.js +33 -0
  14. package/dist/chunk-DAUTLRFG.js.map +1 -0
  15. package/dist/chunk-GLQQOA6T.js +5778 -0
  16. package/dist/chunk-GLQQOA6T.js.map +1 -0
  17. package/dist/{chunk-POGDWVG5.cjs → chunk-KRY73ZPE.cjs} +40 -16
  18. package/dist/chunk-KRY73ZPE.cjs.map +1 -0
  19. package/dist/{chunk-YYHKX5HE.cjs → chunk-M7YWQ47K.cjs} +3 -3
  20. package/dist/{chunk-YYHKX5HE.cjs.map → chunk-M7YWQ47K.cjs.map} +1 -1
  21. package/dist/{chunk-VARU43JT.js → chunk-NT2RADO3.js} +4 -154
  22. package/dist/chunk-NT2RADO3.js.map +1 -0
  23. package/dist/chunk-PLWW5KPC.js +205 -0
  24. package/dist/chunk-PLWW5KPC.js.map +1 -0
  25. package/dist/{chunk-6NTDU63P.js → chunk-PNX4XW5I.js} +35 -11
  26. package/dist/chunk-PNX4XW5I.js.map +1 -0
  27. package/dist/chunk-QLV5EWGF.cjs +33 -0
  28. package/dist/chunk-QLV5EWGF.cjs.map +1 -0
  29. package/dist/chunk-W3XMTX7Q.js +31 -0
  30. package/dist/chunk-W3XMTX7Q.js.map +1 -0
  31. package/dist/chunk-YX6QTWOV.cjs +5778 -0
  32. package/dist/chunk-YX6QTWOV.cjs.map +1 -0
  33. package/dist/{errors-joZChNws.d.ts → errors-CGFOVO3h.d.cts} +34 -4
  34. package/dist/{errors-joZChNws.d.cts → errors-CGFOVO3h.d.ts} +34 -4
  35. package/dist/html.cjs +15 -7
  36. package/dist/html.cjs.map +1 -1
  37. package/dist/html.d.cts +9 -3
  38. package/dist/html.d.ts +9 -3
  39. package/dist/html.js +12 -4
  40. package/dist/html.js.map +1 -1
  41. package/dist/index.cjs +33 -12
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +14 -3
  44. package/dist/index.d.ts +14 -3
  45. package/dist/index.js +28 -7
  46. package/dist/index.js.map +1 -1
  47. package/dist/markdown.cjs +15 -7
  48. package/dist/markdown.cjs.map +1 -1
  49. package/dist/markdown.d.cts +9 -3
  50. package/dist/markdown.d.ts +9 -3
  51. package/dist/markdown.js +12 -4
  52. package/dist/markdown.js.map +1 -1
  53. package/dist/text.cjs +13 -6
  54. package/dist/text.cjs.map +1 -1
  55. package/dist/text.d.cts +8 -3
  56. package/dist/text.d.ts +8 -3
  57. package/dist/text.js +10 -3
  58. package/dist/text.js.map +1 -1
  59. package/dist/yaml.cjs +29 -0
  60. package/dist/yaml.cjs.map +1 -0
  61. package/dist/yaml.d.cts +27 -0
  62. package/dist/yaml.d.ts +27 -0
  63. package/dist/yaml.js +29 -0
  64. package/dist/yaml.js.map +1 -0
  65. package/package.json +12 -2
  66. package/dist/chunk-44A6YP7S.js +0 -21
  67. package/dist/chunk-44A6YP7S.js.map +0 -1
  68. package/dist/chunk-5VBDCDS6.cjs +0 -19
  69. package/dist/chunk-5VBDCDS6.cjs.map +0 -1
  70. package/dist/chunk-6NTDU63P.js.map +0 -1
  71. package/dist/chunk-B4O4R6HI.cjs +0 -5633
  72. package/dist/chunk-B4O4R6HI.cjs.map +0 -1
  73. package/dist/chunk-HGUA2NVX.cjs +0 -21
  74. package/dist/chunk-HGUA2NVX.cjs.map +0 -1
  75. package/dist/chunk-LS57O4KJ.cjs +0 -297
  76. package/dist/chunk-LS57O4KJ.cjs.map +0 -1
  77. package/dist/chunk-OHF7OFWY.js +0 -5633
  78. package/dist/chunk-OHF7OFWY.js.map +0 -1
  79. package/dist/chunk-POGDWVG5.cjs.map +0 -1
  80. package/dist/chunk-RC3UKUYZ.js +0 -19
  81. package/dist/chunk-RC3UKUYZ.js.map +0 -1
  82. package/dist/chunk-VARU43JT.js.map +0 -1
  83. /package/dist/{chunk-KAO74OJ6.js.map → chunk-B3I7VL5E.js.map} +0 -0
@@ -1,14 +1,18 @@
1
1
  import {
2
2
  htmlFragmentSpans,
3
3
  isSkippedElement,
4
- runOverSpans,
5
4
  wrapParserErrors
6
- } from "./chunk-VARU43JT.js";
5
+ } from "./chunk-NT2RADO3.js";
6
+ import {
7
+ analyzeOverSpans,
8
+ runOverSpans
9
+ } from "./chunk-PLWW5KPC.js";
7
10
  import {
8
11
  PolytypoError,
9
12
  getLocaleData,
10
- planRules
11
- } from "./chunk-OHF7OFWY.js";
13
+ planRules,
14
+ resolveNarrowTarget
15
+ } from "./chunk-GLQQOA6T.js";
12
16
 
13
17
  // src/modes/markdown.ts
14
18
  import { parse, postprocess, preprocess } from "micromark";
@@ -35,9 +39,11 @@ var SKIPPED_TOKEN_TYPES = /* @__PURE__ */ new Set([
35
39
  "mdxFlowExpression",
36
40
  "mdxTextExpression",
37
41
  "mdxjsEsm",
38
- // Not in modes.md 3.7, and it has to be: without it the second `---` of a YAML block reads as
39
- // a setext underline, `title: Une note` becomes a paragraph, and `fr` puts a narrow no-break
40
- // space in front of the colon of a machine-read metadata field. Reported as a spec gap.
42
+ // modes.md 3.7.3, and it matters: without it the second `---` of a YAML block reads as a setext
43
+ // underline, `title: Une note` becomes a paragraph, and `fr` puts a narrow no-break space in
44
+ // front of the colon of a machine-read metadata field. Covered by conformance fixtures
45
+ // en-us-markdown-{commonmark,mdx}-frontmatter, fr-markdown-{commonmark,mdx}-frontmatter-nbsp,
46
+ // en-us-markdown-commonmark-frontmatter-toml and -frontmatter-unterminated.
41
47
  "frontmatter"
42
48
  ]);
43
49
  var RAW_TAG_TOKEN_TYPES = /* @__PURE__ */ new Set([
@@ -104,8 +110,10 @@ function resolveDialect(dialect) {
104
110
  `Unknown dialect "${String(dialect)}". Expected "commonmark" or "mdx".`
105
111
  );
106
112
  }
113
+ var FRONTMATTER_MATTERS = ["yaml", "toml"];
107
114
  function extensionsFor(dialect) {
108
- return dialect === "mdx" ? [frontmatter(), gfm(), mdxjs()] : [frontmatter(), gfm()];
115
+ const fm = frontmatter([...FRONTMATTER_MATTERS]);
116
+ return dialect === "mdx" ? [fm, gfm(), mdxjs()] : [fm, gfm()];
109
117
  }
110
118
  function markdownSpans(source, dialect) {
111
119
  const events = wrapParserErrors(dialect, () => tokenize(source, extensionsFor(dialect)));
@@ -150,14 +158,30 @@ function markdownSpans(source, dialect) {
150
158
 
151
159
  // src/engine/markdown-pipeline.ts
152
160
  function runMarkdownPipeline(input, options) {
161
+ const narrowTarget = resolveNarrowTarget(options.narrowNbsp);
153
162
  const planned = planRules(options.rules);
154
163
  const locale = getLocaleData(options.locale);
155
164
  const dialect = resolveDialect(options.dialect);
156
165
  const spans = markdownSpans(input, dialect);
157
- return runOverSpans(input, spans, planned, locale, "markdown");
166
+ return runOverSpans(input, spans, planned, locale, "markdown", narrowTarget);
167
+ }
168
+ function analyzeMarkdownPipeline(input, options) {
169
+ const narrowTarget = resolveNarrowTarget(options.narrowNbsp);
170
+ const planned = planRules(options.rules);
171
+ const locale = getLocaleData(options.locale);
172
+ const dialect = resolveDialect(options.dialect);
173
+ return analyzeOverSpans(
174
+ input,
175
+ markdownSpans(input, dialect),
176
+ planned,
177
+ locale,
178
+ "markdown",
179
+ narrowTarget
180
+ );
158
181
  }
159
182
 
160
183
  export {
161
- runMarkdownPipeline
184
+ runMarkdownPipeline,
185
+ analyzeMarkdownPipeline
162
186
  };
163
- //# sourceMappingURL=chunk-6NTDU63P.js.map
187
+ //# sourceMappingURL=chunk-PNX4XW5I.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 { 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 \"frontmatter\",\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","import { markdownSpans, resolveDialect } from \"../modes/markdown.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 * `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 spans = markdownSpans(input, dialect);\n return runOverSpans(input, spans, planned, locale, \"markdown\", narrowTarget);\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 return analyzeOverSpans(\n input,\n markdownSpans(input, dialect),\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;AAgBtB,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;AA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,IACA,cAAc,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,33 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk72GQS2N7cjs = require('./chunk-72GQS2N7.cjs');
4
+
5
+
6
+
7
+ var _chunk7S5PZ7T5cjs = require('./chunk-7S5PZ7T5.cjs');
8
+
9
+
10
+
11
+
12
+ var _chunkYX6QTWOVcjs = require('./chunk-YX6QTWOV.cjs');
13
+
14
+ // src/engine/html-pipeline.ts
15
+ function runHtmlPipeline(input, options) {
16
+ const narrowTarget = _chunkYX6QTWOVcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
17
+ const planned = _chunkYX6QTWOVcjs.planRules.call(void 0, options.rules);
18
+ const locale = _chunkYX6QTWOVcjs.getLocaleData.call(void 0, options.locale);
19
+ const spans = _chunk72GQS2N7cjs.htmlSpans.call(void 0, input);
20
+ return _chunk7S5PZ7T5cjs.runOverSpans.call(void 0, input, spans, planned, locale, "html", narrowTarget);
21
+ }
22
+ function analyzeHtmlPipeline(input, options) {
23
+ const narrowTarget = _chunkYX6QTWOVcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
24
+ const planned = _chunkYX6QTWOVcjs.planRules.call(void 0, options.rules);
25
+ const locale = _chunkYX6QTWOVcjs.getLocaleData.call(void 0, options.locale);
26
+ return _chunk7S5PZ7T5cjs.analyzeOverSpans.call(void 0, input, _chunk72GQS2N7cjs.htmlSpans.call(void 0, input), planned, locale, "html", narrowTarget);
27
+ }
28
+
29
+
30
+
31
+
32
+ exports.runHtmlPipeline = runHtmlPipeline; exports.analyzeHtmlPipeline = analyzeHtmlPipeline;
33
+ //# sourceMappingURL=chunk-QLV5EWGF.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-QLV5EWGF.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-QLV5EWGF.cjs","sourcesContent":[null,"import { htmlSpans } from \"../modes/html.js\";\nimport type { Options } from \"../types.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { resolveNarrowTarget } from \"./narrow-target.js\";\nimport { planRules } from \"./rule-runner.js\";\nimport { analyzeOverSpans, runOverSpans } from \"./span-runner.js\";\nimport type { Change } from \"./origin.js\";\n\n/**\n * `html` mode only. Imports `parse5` (via `../modes/html.js`) and nothing from\n * `../modes/markdown.js` or the Micromark/MDX stack — this is what makes `polytypo/html`'s\n * module graph exclude the Markdown parser (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1).\n *\n * Validation order — `planRules` before `getLocaleData` before parsing — mirrors the pre-Stage-5\n * aggregate `runPipeline` exactly (an unknown-rule error must win over an unknown-locale error,\n * and both must win over a parse failure, since that is public, tested behaviour).\n */\nexport function runHtmlPipeline(input: string, options: Partial<Options>): string {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const spans = htmlSpans(input);\n return runOverSpans(input, spans, planned, locale, \"html\", narrowTarget);\n}\n\n/** analyze.md §1, `html` mode: offsets are into the document, not into a span (analyze.md §6). */\nexport function analyzeHtmlPipeline(input: string, options: Partial<Options>): Change[] {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n return analyzeOverSpans(input, htmlSpans(input), planned, locale, \"html\", narrowTarget);\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import {
2
+ fromCodePoints,
3
+ getLocaleData,
4
+ planRules,
5
+ resolveNarrowTarget,
6
+ runRules,
7
+ runRulesRecording,
8
+ toCodePoints
9
+ } from "./chunk-GLQQOA6T.js";
10
+
11
+ // src/engine/text-pipeline.ts
12
+ function runTextPipeline(input, options) {
13
+ const narrowTarget = resolveNarrowTarget(options.narrowNbsp);
14
+ const planned = planRules(options.rules);
15
+ const locale = getLocaleData(options.locale);
16
+ return fromCodePoints(runRules(toCodePoints(input), planned, locale, "text", narrowTarget));
17
+ }
18
+ function analyzeTextPipeline(input, options) {
19
+ const narrowTarget = resolveNarrowTarget(options.narrowNbsp);
20
+ const planned = planRules(options.rules);
21
+ const locale = getLocaleData(options.locale);
22
+ const cp = toCodePoints(input);
23
+ const origin = cp.map((_value, index) => index);
24
+ return runRulesRecording(cp, planned, locale, "text", narrowTarget, origin, cp.length);
25
+ }
26
+
27
+ export {
28
+ runTextPipeline,
29
+ analyzeTextPipeline
30
+ };
31
+ //# sourceMappingURL=chunk-W3XMTX7Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/engine/text-pipeline.ts"],"sourcesContent":["import type { Options } from \"../types.js\";\nimport { fromCodePoints, toCodePoints } from \"./codepoints.js\";\nimport type { Change } from \"./origin.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { resolveNarrowTarget } from \"./narrow-target.js\";\nimport { planRules, runRules, runRulesRecording } from \"./rule-runner.js\";\n\n/**\n * `text` mode only. Deliberately imports nothing from `../modes/html.js` or\n * `../modes/markdown.js` (or their parser dependencies) — this is what makes `polytypo/text`'s\n * module graph exclude `parse5` and the Micromark stack (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md\n * 5.1).\n *\n * Validation order — `planRules` before `getLocaleData` — mirrors the pre-Stage-5 aggregate\n * `runPipeline` exactly (an unknown-rule error must win over an unknown-locale error when both\n * are present, since that is public, tested behaviour, not an implementation detail this\n * refactor was authorised to change).\n */\nexport function runTextPipeline(input: string, options: Partial<Options>): string {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n return fromCodePoints(runRules(toCodePoints(input), planned, locale, \"text\", narrowTarget));\n}\n\n/** analyze.md §1: the same pipeline as `runTextPipeline`, reporting instead of applying. */\nexport function analyzeTextPipeline(input: string, options: Partial<Options>): Change[] {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const cp = toCodePoints(input);\n const origin = cp.map((_value, index) => index);\n return runRulesRecording(cp, planned, locale, \"text\", narrowTarget, origin, cp.length);\n}\n"],"mappings":";;;;;;;;;;;AAkBO,SAAS,gBAAgB,OAAe,SAAmC;AAChF,QAAM,eAAe,oBAAoB,QAAQ,UAAU;AAC3D,QAAM,UAAU,UAAU,QAAQ,KAAK;AACvC,QAAM,SAAS,cAAc,QAAQ,MAAM;AAC3C,SAAO,eAAe,SAAS,aAAa,KAAK,GAAG,SAAS,QAAQ,QAAQ,YAAY,CAAC;AAC5F;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,KAAK,aAAa,KAAK;AAC7B,QAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,UAAU,KAAK;AAC9C,SAAO,kBAAkB,IAAI,SAAS,QAAQ,QAAQ,cAAc,QAAQ,GAAG,MAAM;AACvF;","names":[]}