polytypo 1.2.0 → 1.3.1
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.
- package/README.md +48 -0
- package/dist/{chunk-KAO74OJ6.js → chunk-4GYU4TXA.js} +2 -2
- package/dist/{chunk-6NTDU63P.js → chunk-5NCJ3Y65.js} +35 -11
- package/dist/chunk-5NCJ3Y65.js.map +1 -0
- package/dist/chunk-5U3DRTV7.js +205 -0
- package/dist/chunk-5U3DRTV7.js.map +1 -0
- package/dist/chunk-5VNPHCL2.cjs +264 -0
- package/dist/chunk-5VNPHCL2.cjs.map +1 -0
- package/dist/{chunk-POGDWVG5.cjs → chunk-AR6FDQAX.cjs} +40 -16
- package/dist/chunk-AR6FDQAX.cjs.map +1 -0
- package/dist/chunk-B7WXSXRG.js +31 -0
- package/dist/chunk-B7WXSXRG.js.map +1 -0
- package/dist/{chunk-VARU43JT.js → chunk-DXWMSR26.js} +4 -154
- package/dist/chunk-DXWMSR26.js.map +1 -0
- package/dist/chunk-ECYUONLP.cjs +205 -0
- package/dist/chunk-ECYUONLP.cjs.map +1 -0
- package/dist/chunk-FK3F3YZT.cjs +33 -0
- package/dist/chunk-FK3F3YZT.cjs.map +1 -0
- package/dist/chunk-QNSBCZU5.cjs +31 -0
- package/dist/chunk-QNSBCZU5.cjs.map +1 -0
- package/dist/chunk-THTCAO3O.cjs +147 -0
- package/dist/chunk-THTCAO3O.cjs.map +1 -0
- package/dist/chunk-UBEV2AC3.js +264 -0
- package/dist/chunk-UBEV2AC3.js.map +1 -0
- package/dist/chunk-V4EOJ44S.cjs +5778 -0
- package/dist/chunk-V4EOJ44S.cjs.map +1 -0
- package/dist/chunk-VC5XLP6O.js +33 -0
- package/dist/chunk-VC5XLP6O.js.map +1 -0
- package/dist/chunk-VKJVMMCI.js +5778 -0
- package/dist/chunk-VKJVMMCI.js.map +1 -0
- package/dist/{chunk-YYHKX5HE.cjs → chunk-W2T7B2SH.cjs} +3 -3
- package/dist/{chunk-YYHKX5HE.cjs.map → chunk-W2T7B2SH.cjs.map} +1 -1
- package/dist/{errors-joZChNws.d.ts → errors-CGFOVO3h.d.cts} +34 -4
- package/dist/{errors-joZChNws.d.cts → errors-CGFOVO3h.d.ts} +34 -4
- package/dist/html.cjs +15 -7
- package/dist/html.cjs.map +1 -1
- package/dist/html.d.cts +9 -3
- package/dist/html.d.ts +9 -3
- package/dist/html.js +12 -4
- package/dist/html.js.map +1 -1
- package/dist/index.cjs +33 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +28 -7
- package/dist/index.js.map +1 -1
- package/dist/markdown.cjs +15 -7
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.d.cts +9 -3
- package/dist/markdown.d.ts +9 -3
- package/dist/markdown.js +12 -4
- package/dist/markdown.js.map +1 -1
- package/dist/text.cjs +13 -6
- package/dist/text.cjs.map +1 -1
- package/dist/text.d.cts +8 -3
- package/dist/text.d.ts +8 -3
- package/dist/text.js +10 -3
- package/dist/text.js.map +1 -1
- package/dist/yaml.cjs +29 -0
- package/dist/yaml.cjs.map +1 -0
- package/dist/yaml.d.cts +27 -0
- package/dist/yaml.d.ts +27 -0
- package/dist/yaml.js +29 -0
- package/dist/yaml.js.map +1 -0
- package/package.json +12 -2
- package/dist/chunk-44A6YP7S.js +0 -21
- package/dist/chunk-44A6YP7S.js.map +0 -1
- package/dist/chunk-5VBDCDS6.cjs +0 -19
- package/dist/chunk-5VBDCDS6.cjs.map +0 -1
- package/dist/chunk-6NTDU63P.js.map +0 -1
- package/dist/chunk-B4O4R6HI.cjs +0 -5633
- package/dist/chunk-B4O4R6HI.cjs.map +0 -1
- package/dist/chunk-HGUA2NVX.cjs +0 -21
- package/dist/chunk-HGUA2NVX.cjs.map +0 -1
- package/dist/chunk-LS57O4KJ.cjs +0 -297
- package/dist/chunk-LS57O4KJ.cjs.map +0 -1
- package/dist/chunk-OHF7OFWY.js +0 -5633
- package/dist/chunk-OHF7OFWY.js.map +0 -1
- package/dist/chunk-POGDWVG5.cjs.map +0 -1
- package/dist/chunk-RC3UKUYZ.js +0 -19
- package/dist/chunk-RC3UKUYZ.js.map +0 -1
- package/dist/chunk-VARU43JT.js.map +0 -1
- /package/dist/{chunk-KAO74OJ6.js.map → chunk-4GYU4TXA.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-THTCAO3O.cjs","../src/modes/html.ts","../src/modes/parse-error.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,gCAAqC;ADMrC;AACA;AEAA,SAAS,QAAA,CAAS,KAAA,EAAwB;AACxC,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,SAAA,GAAY,MAAA,IAAU,IAAA,EAAM,OAAO,MAAA,CAAO,KAAK,CAAA;AACpE,EAAA,MAAM,WAAA,EAAa,KAAA;AACnB,EAAA,MAAM,OAAA,EACJ,OAAO,UAAA,CAAW,OAAA,IAAW,SAAA,EAAW,UAAA,CAAW,OAAA,EAAU,KAAA,CAAgB,OAAA;AAC/E,EAAA,MAAM,MAAA,EAAQ,UAAA,CAAW,KAAA;AACzB,EAAA,GAAA,CACE,MAAA,IAAU,KAAA,GACV,MAAA,IAAU,KAAA,EAAA,GACV,OAAO,KAAA,CAAM,KAAA,IAAS,SAAA,GACtB,OAAO,KAAA,CAAM,OAAA,IAAW,QAAA,EACxB;AACA,IAAA,OAAO,CAAA,EAAA;AACT,EAAA;AACO,EAAA;AACT;AAcgB;AACV,EAAA;AACK,IAAA;AACA,EAAA;AACH,IAAA;AACE,IAAA;AACJ,MAAA;AACA,MAAA;AACF,IAAA;AACF,EAAA;AACF;AFjBY;AACA;ACfN;AACJ,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACD;AAEe;AACP,EAAA;AACT;AAEM;AACA;AACO;AACP;AACA;AAGA;AAEG;AACA,EAAA;AACT;AAES;AACA,EAAA;AACT;AAES;AACA,EAAA;AACT;AAQS;AACH,EAAA;AACI,EAAA;AACC,EAAA;AAEL,EAAA;AACG,IAAA;AACC,IAAA;AACA,IAAA;AACG,IAAA;AACH,IAAA;AAEJ,IAAA;AAGK,MAAA;AACP,IAAA;AACI,IAAA;AACG,IAAA;AACT,EAAA;AAEM,EAAA;AAEJ,EAAA;AAIK,IAAA;AACP,EAAA;AACU,EAAA;AACH,EAAA;AACT;AAOgB;AACR,EAAA;AACF,EAAA;AACI,EAAA;AACD,EAAA;AACD,IAAA;AACI,MAAA;AACF,MAAA;AACE,QAAA;AACJ,QAAA;AACI,QAAA;AACJ,QAAA;AACF,MAAA;AACF,IAAA;AACK,IAAA;AACP,EAAA;AACU,EAAA;AACH,EAAA;AACT;AAES;AACA,EAAA;AACT;AAES;AACE,EAAA;AACD,IAAA;AACF,IAAA;AACJ,IAAA;AACQ,MAAA;AACR,IAAA;AACA,IAAA;AACF,EAAA;AAGS,EAAA;AAEL,EAAA;AAGK,EAAA;AACC,IAAA;AACR,IAAA;AACF,EAAA;AAEK,EAAA;AACL,EAAA;AACF;AAQgB;AACR,EAAA;AACA,EAAA;AACE,EAAA;AACD,EAAA;AACT;AAGgB;AACR,EAAA;AAA4B,IAAA;AAChC,IAAA;AACF,EAAA;AACM,EAAA;AACE,EAAA;AACD,EAAA;AAGT;AD9BY;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-THTCAO3O.cjs","sourcesContent":[null,"import { parse, parseFragment } from \"parse5\";\nimport type { DefaultTreeAdapterMap } from \"parse5\";\nimport { wrapParserErrors } from \"./parse-error.js\";\nimport type { Span } from \"./spans.js\";\n\ntype Node = DefaultTreeAdapterMap[\"node\"];\ntype ParentNode = DefaultTreeAdapterMap[\"parentNode\"];\n\n/**\n * spec/rules/modes.md 3.6, exhaustive and **closed**: extending it is a spec change, not an\n * implementation decision. `svg` and `math` are here because in MathML a quotation mark, a\n * hyphen and a prime are operators and identifiers — substituting a curly glyph changes what\n * the expression means. Everything not listed is processable, **including unknown and custom\n * elements**: guessing from a tag name is exactly the heuristic that diverges across runtimes.\n */\nconst SKIPPED_ELEMENTS: ReadonlySet<string> = new Set([\n \"code\",\n \"pre\",\n \"kbd\",\n \"samp\",\n \"var\",\n \"script\",\n \"style\",\n \"textarea\",\n \"svg\",\n \"math\",\n]);\n\nexport function isSkippedElement(tagName: string): boolean {\n return SKIPPED_ELEMENTS.has(tagName);\n}\n\nconst AMPERSAND = 0x26;\nconst SEMICOLON = 0x3b;\nconst HASH = 0x23;\nconst LOWER_X = 0x78;\nconst UPPER_X = 0x58;\n\n/** Longest named reference in the WHATWG table is 32 characters; the guard is a bound, not a rule. */\nconst MAX_REFERENCE_BODY = 34;\n\nfunction isAsciiDigit(unit: number): boolean {\n return unit >= 0x30 && unit <= 0x39;\n}\n\nfunction isAsciiHexDigit(unit: number): boolean {\n return isAsciiDigit(unit) || (unit >= 0x61 && unit <= 0x66) || (unit >= 0x41 && unit <= 0x46);\n}\n\nfunction isAsciiAlphanumeric(unit: number): boolean {\n return isAsciiDigit(unit) || (unit >= 0x61 && unit <= 0x7a) || (unit >= 0x41 && unit <= 0x5a);\n}\n\n/**\n * The end offset of a well-formed character reference starting at `at`, or -1. A bare `&` that a\n * parser would repair is deliberately **not** treated as a reference: it stays inside the span,\n * where no rule can emit or delete it, rather than manufacturing a boundary that suppresses\n * conversions around it.\n */\nfunction characterReferenceEnd(source: string, at: number, limit: number): number {\n if (source.charCodeAt(at) !== AMPERSAND) return -1;\n let i = at + 1;\n if (i >= limit) return -1;\n\n if (source.charCodeAt(i) === HASH) {\n i += 1;\n const unit = i < limit ? source.charCodeAt(i) : -1;\n const hex = unit === LOWER_X || unit === UPPER_X;\n if (hex) i += 1;\n const digitsAt = i;\n while (\n i < limit &&\n (hex ? isAsciiHexDigit(source.charCodeAt(i)) : isAsciiDigit(source.charCodeAt(i)))\n ) {\n i += 1;\n }\n if (i === digitsAt) return -1;\n return i < limit && source.charCodeAt(i) === SEMICOLON ? i + 1 : -1;\n }\n\n const nameAt = i;\n while (\n i < limit &&\n i - nameAt < MAX_REFERENCE_BODY &&\n isAsciiAlphanumeric(source.charCodeAt(i))\n ) {\n i += 1;\n }\n if (i === nameAt) return -1;\n return i < limit && source.charCodeAt(i) === SEMICOLON ? i + 1 : -1;\n}\n\n/**\n * modes.md 3.6: every character reference is skipped as an **opaque unit**, and a text node\n * containing one is split into spans around it. That is the only way ` ` survives as\n * ` ` instead of becoming a literal U+00A0 on the way out.\n */\nexport function splitCharacterReferences(source: string, start: number, end: number): Span[] {\n const spans: Span[] = [];\n let cursor = start;\n let i = start;\n while (i < end) {\n if (source.charCodeAt(i) === AMPERSAND) {\n const stop = characterReferenceEnd(source, i, end);\n if (stop > 0) {\n if (i > cursor) spans.push({ start: cursor, end: i });\n cursor = stop;\n i = stop;\n continue;\n }\n }\n i += 1;\n }\n if (end > cursor) spans.push({ start: cursor, end });\n return spans;\n}\n\nfunction isParent(node: Node): node is ParentNode {\n return \"childNodes\" in node;\n}\n\nfunction collect(node: Node, source: string, spans: Span[]): void {\n if (node.nodeName === \"#text\") {\n const location = node.sourceCodeLocation;\n if (location === undefined || location === null) return;\n for (const span of splitCharacterReferences(source, location.startOffset, location.endOffset)) {\n spans.push(span);\n }\n return;\n }\n\n // Comments, doctype and processing instructions never contribute a span (modes.md 3.6).\n if (node.nodeName === \"#comment\" || node.nodeName === \"#documentType\") return;\n\n if (\"tagName\" in node && isSkippedElement(node.tagName)) return;\n\n // A `template`'s children live in a separate document fragment; `template` is not skipped.\n if (node.nodeName === \"template\" && \"content\" in node) {\n collect(node.content, source, spans);\n return;\n }\n\n if (!isParent(node)) return;\n for (const child of node.childNodes) collect(child, source, spans);\n}\n\n/**\n * Locate the processable spans of an HTML document. The tree is used only to find offsets and is\n * then discarded — modes.md 4 forbids reserialisation, which is what makes attribute quoting,\n * self-closing forms, entity spelling, tag case and malformed-input recovery preserved by\n * construction rather than by effort.\n */\nexport function htmlSpans(source: string): Span[] {\n const document = wrapParserErrors(\"HTML\", () => parse(source, { sourceCodeLocationInfo: true }));\n const spans: Span[] = [];\n collect(document, source, spans);\n return spans;\n}\n\n/** The same, for a fragment: used for HTML blocks embedded in markdown (modes.md 3.7). */\nexport function htmlFragmentSpans(source: string, offset: number): Span[] {\n const fragment = wrapParserErrors(\"HTML\", () =>\n parseFragment(source, { sourceCodeLocationInfo: true }),\n );\n const spans: Span[] = [];\n collect(fragment, source, spans);\n return offset === 0\n ? spans\n : spans.map((span) => ({ start: span.start + offset, end: span.end + offset }));\n}\n","import { PolytypoError } from \"../errors.js\";\n\ninterface PositionedError {\n readonly reason?: unknown;\n readonly place?: { readonly line?: unknown; readonly column?: unknown } | null;\n}\n\nfunction describe(error: unknown): string {\n if (typeof error !== \"object\" || error === null) return String(error);\n const positioned = error as PositionedError;\n const reason =\n typeof positioned.reason === \"string\" ? positioned.reason : (error as Error).message;\n const place = positioned.place;\n if (\n place !== null &&\n place !== undefined &&\n typeof place.line === \"number\" &&\n typeof place.column === \"number\"\n ) {\n return `${reason} (line ${place.line}, column ${place.column})`;\n }\n return reason;\n}\n\n/**\n * spec/rules/modes.md 3.7.2. **The parser's own error type must never escape.** A\n * `VFileMessage`, a `Nokogiri::SyntaxError` or a Python exception on the public surface puts a\n * dependency's type into the contract and is unreproducible in the other four runtimes; only the\n * code is contractual (ARCHITECTURE.md 4.6), while the message and the source position are\n * useful and are not.\n *\n * Reachable in exactly one place: `dialect: \"mdx\"`, because MDX embeds JavaScript. HTML parsing\n * is specified with total error recovery and every byte sequence is valid CommonMark, so neither\n * of the other two languages can fail. The wrapper is applied to all of them anyway — the\n * guarantee is that no parser type escapes, not that this particular parser is trusted.\n */\nexport function wrapParserErrors<T>(what: string, run: () => T): T {\n try {\n return run();\n } catch (error) {\n if (error instanceof PolytypoError) throw error;\n throw new PolytypoError(\n \"POLYTYPO_MALFORMED_INPUT\",\n `Input does not parse as ${what}: ${describe(error)}`,\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import {
|
|
2
|
+
analyzeOverSpans,
|
|
3
|
+
runOverSpans
|
|
4
|
+
} from "./chunk-5U3DRTV7.js";
|
|
5
|
+
import {
|
|
6
|
+
PolytypoError,
|
|
7
|
+
getLocaleData,
|
|
8
|
+
planRules,
|
|
9
|
+
resolveNarrowTarget
|
|
10
|
+
} from "./chunk-VKJVMMCI.js";
|
|
11
|
+
|
|
12
|
+
// src/modes/yaml.ts
|
|
13
|
+
var TAB = 9;
|
|
14
|
+
var LF = 10;
|
|
15
|
+
var CR = 13;
|
|
16
|
+
var SPACE = 32;
|
|
17
|
+
var BANG = 33;
|
|
18
|
+
var DQUOTE = 34;
|
|
19
|
+
var HASH = 35;
|
|
20
|
+
var PERCENT = 37;
|
|
21
|
+
var AMPERSAND = 38;
|
|
22
|
+
var SQUOTE = 39;
|
|
23
|
+
var STAR = 42;
|
|
24
|
+
var PLUS = 43;
|
|
25
|
+
var DASH = 45;
|
|
26
|
+
var DOT = 46;
|
|
27
|
+
var ZERO = 48;
|
|
28
|
+
var ONE = 49;
|
|
29
|
+
var NINE = 57;
|
|
30
|
+
var COLON = 58;
|
|
31
|
+
var GREATER = 62;
|
|
32
|
+
var LBRACKET = 91;
|
|
33
|
+
var BACKSLASH = 92;
|
|
34
|
+
var LBRACE = 123;
|
|
35
|
+
var PIPE = 124;
|
|
36
|
+
function splitLines(source) {
|
|
37
|
+
const lines = [];
|
|
38
|
+
let start = 0;
|
|
39
|
+
const endOf = (i) => i > start && source.charCodeAt(i - 1) === CR ? i - 1 : i;
|
|
40
|
+
for (let i = 0; i < source.length; i += 1) {
|
|
41
|
+
if (source.charCodeAt(i) === LF) {
|
|
42
|
+
lines.push({ start, end: endOf(i) });
|
|
43
|
+
start = i + 1;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (start < source.length) lines.push({ start, end: endOf(source.length) });
|
|
47
|
+
return lines;
|
|
48
|
+
}
|
|
49
|
+
function firstNonSpace(source, line) {
|
|
50
|
+
let i = line.start;
|
|
51
|
+
while (i < line.end && source.charCodeAt(i) === SPACE) i += 1;
|
|
52
|
+
return i;
|
|
53
|
+
}
|
|
54
|
+
function isBlank(source, line) {
|
|
55
|
+
return firstNonSpace(source, line) === line.end;
|
|
56
|
+
}
|
|
57
|
+
function hasTab(source, line) {
|
|
58
|
+
for (let i = line.start; i < line.end; i += 1) if (source.charCodeAt(i) === TAB) return true;
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
function isDocumentMarker(source, from, end) {
|
|
62
|
+
if (end - from < 3) return false;
|
|
63
|
+
const c = source.charCodeAt(from);
|
|
64
|
+
if (c !== DASH && c !== DOT) return false;
|
|
65
|
+
if (source.charCodeAt(from + 1) !== c || source.charCodeAt(from + 2) !== c) return false;
|
|
66
|
+
return from + 3 === end || source.charCodeAt(from + 3) === SPACE;
|
|
67
|
+
}
|
|
68
|
+
function isIndicatorColon(source, j, end) {
|
|
69
|
+
if (source.charCodeAt(j) !== COLON) return false;
|
|
70
|
+
return j + 1 === end || source.charCodeAt(j + 1) === SPACE;
|
|
71
|
+
}
|
|
72
|
+
function isSequenceDash(source, j, end) {
|
|
73
|
+
if (source.charCodeAt(j) !== DASH) return false;
|
|
74
|
+
return j + 1 === end || source.charCodeAt(j + 1) === SPACE;
|
|
75
|
+
}
|
|
76
|
+
function valueRunEnd(source, lines, li, indent) {
|
|
77
|
+
let k = li + 1;
|
|
78
|
+
while (k < lines.length) {
|
|
79
|
+
const next = lines[k];
|
|
80
|
+
if (!isBlank(source, next) && firstNonSpace(source, next) - next.start <= indent) break;
|
|
81
|
+
k += 1;
|
|
82
|
+
}
|
|
83
|
+
return k;
|
|
84
|
+
}
|
|
85
|
+
function yamlSpans(source, keys) {
|
|
86
|
+
const listed = new Set(keys);
|
|
87
|
+
const lines = splitLines(source);
|
|
88
|
+
const spans = [];
|
|
89
|
+
let li = 0;
|
|
90
|
+
while (li < lines.length) li = scanLine(source, lines, li, listed, spans);
|
|
91
|
+
return spans;
|
|
92
|
+
}
|
|
93
|
+
function scanLine(source, lines, li, listed, spans) {
|
|
94
|
+
const line = lines[li];
|
|
95
|
+
const skipLine = li + 1;
|
|
96
|
+
const start = firstNonSpace(source, line);
|
|
97
|
+
if (start === line.end || hasTab(source, line)) return skipLine;
|
|
98
|
+
const indent = start - line.start;
|
|
99
|
+
const head = source.charCodeAt(start);
|
|
100
|
+
if (head === HASH || head === PERCENT) return skipLine;
|
|
101
|
+
if (isDocumentMarker(source, start, line.end)) return skipLine;
|
|
102
|
+
let i = start;
|
|
103
|
+
while (i < line.end && isSequenceDash(source, i, line.end)) {
|
|
104
|
+
i += 2;
|
|
105
|
+
while (i < line.end && source.charCodeAt(i) === SPACE) i += 1;
|
|
106
|
+
}
|
|
107
|
+
if (i >= line.end) return skipLine;
|
|
108
|
+
const keyStart = i;
|
|
109
|
+
let colon = -1;
|
|
110
|
+
for (let j = i; j < line.end; j += 1) {
|
|
111
|
+
const c = source.charCodeAt(j);
|
|
112
|
+
if (c === DQUOTE || c === SQUOTE || c === LBRACE || c === LBRACKET || c === AMPERSAND || c === STAR || c === BANG || c === HASH) {
|
|
113
|
+
return skipLine;
|
|
114
|
+
}
|
|
115
|
+
if (isIndicatorColon(source, j, line.end)) {
|
|
116
|
+
colon = j;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (colon < 0) return skipLine;
|
|
121
|
+
let keyEnd = colon;
|
|
122
|
+
while (keyEnd > keyStart && source.charCodeAt(keyEnd - 1) === SPACE) keyEnd -= 1;
|
|
123
|
+
if (keyEnd <= keyStart) return skipLine;
|
|
124
|
+
let v = colon + 1;
|
|
125
|
+
while (v < line.end && source.charCodeAt(v) === SPACE) v += 1;
|
|
126
|
+
if (v >= line.end) return skipLine;
|
|
127
|
+
const next = valueRunEnd(source, lines, li, indent);
|
|
128
|
+
if (!listed.has(source.slice(keyStart, keyEnd))) return next;
|
|
129
|
+
const value = source.charCodeAt(v);
|
|
130
|
+
if (value === HASH || value === AMPERSAND || value === STAR || value === BANG || value === LBRACE || value === LBRACKET) {
|
|
131
|
+
return next;
|
|
132
|
+
}
|
|
133
|
+
if (value === PIPE || value === GREATER) {
|
|
134
|
+
blockScalar(source, lines, li, next, indent, v, spans);
|
|
135
|
+
return next;
|
|
136
|
+
}
|
|
137
|
+
if (value === DQUOTE || value === SQUOTE) {
|
|
138
|
+
if (next === li + 1) quotedScalar(source, line, v, spans);
|
|
139
|
+
return next;
|
|
140
|
+
}
|
|
141
|
+
if (next === li + 1) plainScalar(source, line, v, spans);
|
|
142
|
+
return next;
|
|
143
|
+
}
|
|
144
|
+
function blockScalar(source, lines, li, runEnd, indent, v, spans) {
|
|
145
|
+
const line = lines[li];
|
|
146
|
+
let h = v + 1;
|
|
147
|
+
let explicitIndent = 0;
|
|
148
|
+
let chomping = false;
|
|
149
|
+
while (h < line.end) {
|
|
150
|
+
const c = source.charCodeAt(h);
|
|
151
|
+
if ((c === DASH || c === PLUS) && !chomping) {
|
|
152
|
+
chomping = true;
|
|
153
|
+
h += 1;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (c >= ONE && c <= NINE && explicitIndent === 0) {
|
|
157
|
+
explicitIndent = c - ZERO;
|
|
158
|
+
h += 1;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
while (h < line.end && source.charCodeAt(h) === SPACE) h += 1;
|
|
164
|
+
if (h < line.end && source.charCodeAt(h) !== HASH) return;
|
|
165
|
+
const content = [];
|
|
166
|
+
let contentIndent = -1;
|
|
167
|
+
for (let k = li + 1; k < runEnd; k += 1) {
|
|
168
|
+
const next = lines[k];
|
|
169
|
+
if (isBlank(source, next)) continue;
|
|
170
|
+
if (hasTab(source, next)) return;
|
|
171
|
+
const nextIndent = firstNonSpace(source, next) - next.start;
|
|
172
|
+
if (contentIndent < 0) {
|
|
173
|
+
contentIndent = explicitIndent > 0 ? indent + explicitIndent : nextIndent;
|
|
174
|
+
}
|
|
175
|
+
if (nextIndent < contentIndent) return;
|
|
176
|
+
content.push(next);
|
|
177
|
+
}
|
|
178
|
+
if (contentIndent <= 0) return;
|
|
179
|
+
for (const c of content) {
|
|
180
|
+
const from = c.start + contentIndent;
|
|
181
|
+
if (c.end > from) spans.push({ start: from, end: c.end });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function quotedScalar(source, line, v, spans) {
|
|
185
|
+
const quote = source.charCodeAt(v);
|
|
186
|
+
let close = -1;
|
|
187
|
+
for (let j = v + 1; j < line.end; j += 1) {
|
|
188
|
+
const c = source.charCodeAt(j);
|
|
189
|
+
if (quote === DQUOTE && c === BACKSLASH) return;
|
|
190
|
+
if (quote === SQUOTE && c === SQUOTE && j + 1 < line.end && source.charCodeAt(j + 1) === SQUOTE) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (c === quote) {
|
|
194
|
+
close = j;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (close < 0) return;
|
|
199
|
+
let after = close + 1;
|
|
200
|
+
while (after < line.end && source.charCodeAt(after) === SPACE) after += 1;
|
|
201
|
+
if (after < line.end && source.charCodeAt(after) !== HASH) return;
|
|
202
|
+
if (close > v + 1) spans.push({ start: v + 1, end: close });
|
|
203
|
+
}
|
|
204
|
+
function plainScalar(source, line, v, spans) {
|
|
205
|
+
let end = line.end;
|
|
206
|
+
for (let j = v; j < line.end; j += 1) {
|
|
207
|
+
if (source.charCodeAt(j) === HASH && j > v && source.charCodeAt(j - 1) === SPACE) {
|
|
208
|
+
end = j - 1;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
while (end > v && source.charCodeAt(end - 1) === SPACE) end -= 1;
|
|
213
|
+
if (end <= v) return;
|
|
214
|
+
if (isSequenceDash(source, v, line.end)) return;
|
|
215
|
+
for (let j = v; j < end; j += 1) if (isIndicatorColon(source, j, line.end)) return;
|
|
216
|
+
let segment = v;
|
|
217
|
+
for (let j = v; j <= end; j += 1) {
|
|
218
|
+
if (j === end || source.charCodeAt(j) === COLON || source.charCodeAt(j) === HASH) {
|
|
219
|
+
if (j > segment) spans.push({ start: segment, end: j });
|
|
220
|
+
segment = j + 1;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// src/engine/yaml-keys.ts
|
|
226
|
+
function resolveYamlKeys(value) {
|
|
227
|
+
if (!Array.isArray(value)) {
|
|
228
|
+
throw new PolytypoError(
|
|
229
|
+
"POLYTYPO_INVALID_OPTION",
|
|
230
|
+
`"keys" is required when mode is "yaml" and must be a list of strings (modes.md \xA73.8.2). Received ${value === void 0 ? "nothing" : JSON.stringify(value)}.`
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
for (const key of value) {
|
|
234
|
+
if (typeof key !== "string") {
|
|
235
|
+
throw new PolytypoError(
|
|
236
|
+
"POLYTYPO_INVALID_OPTION",
|
|
237
|
+
`"keys" must contain only strings; received ${JSON.stringify(key)}.`
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return value;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// src/engine/yaml-pipeline.ts
|
|
245
|
+
function runYamlPipeline(input, options) {
|
|
246
|
+
const narrowTarget = resolveNarrowTarget(options.narrowNbsp);
|
|
247
|
+
const planned = planRules(options.rules);
|
|
248
|
+
const locale = getLocaleData(options.locale);
|
|
249
|
+
const keys = resolveYamlKeys(options.keys);
|
|
250
|
+
return runOverSpans(input, yamlSpans(input, keys), planned, locale, "yaml", narrowTarget);
|
|
251
|
+
}
|
|
252
|
+
function analyzeYamlPipeline(input, options) {
|
|
253
|
+
const narrowTarget = resolveNarrowTarget(options.narrowNbsp);
|
|
254
|
+
const planned = planRules(options.rules);
|
|
255
|
+
const locale = getLocaleData(options.locale);
|
|
256
|
+
const keys = resolveYamlKeys(options.keys);
|
|
257
|
+
return analyzeOverSpans(input, yamlSpans(input, keys), planned, locale, "yaml", narrowTarget);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export {
|
|
261
|
+
runYamlPipeline,
|
|
262
|
+
analyzeYamlPipeline
|
|
263
|
+
};
|
|
264
|
+
//# sourceMappingURL=chunk-UBEV2AC3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/modes/yaml.ts","../src/engine/yaml-keys.ts","../src/engine/yaml-pipeline.ts"],"sourcesContent":["import type { Span } from \"./spans.js\";\n\n/**\n * spec/rules/modes.md 3.8. `yaml` differs from the other two document modes twice over.\n *\n * It uses **no parser** (3.8.1): two of the five ecosystems' YAML libraries cannot report the\n * source offsets the round-trip guarantee needs, so the scan below is specified rather than\n * delegated and is written the same way in every runtime.\n *\n * And the caller names the keys (3.8.2). YAML is a data format with islands of prose in it — the\n * inverse of HTML and Markdown — and nothing in its syntax separates `description:` from `run:`.\n * A keyless draft of this file rewrote `if !` as `if!` inside a workflow's shell script; there is\n * no content test that would not, because shell and template expressions are written in words.\n *\n * It also **skips by default** — the inverse of 3.6's closed skip list. A construct this scan\n * does not recognise with certainty yields no spans, so the worst outcome of a gap in it is prose\n * left untypeset, never a changed byte.\n *\n * Offsets are UTF-16 indices, like every other mode in this runtime; every character the scan\n * tests is ASCII, so indexing by code unit and indexing by code point agree on all of them.\n */\n\nconst TAB = 0x09;\nconst LF = 0x0a;\nconst CR = 0x0d;\nconst SPACE = 0x20;\nconst BANG = 0x21;\nconst DQUOTE = 0x22;\nconst HASH = 0x23;\nconst PERCENT = 0x25;\nconst AMPERSAND = 0x26;\nconst SQUOTE = 0x27;\nconst STAR = 0x2a;\nconst PLUS = 0x2b;\nconst DASH = 0x2d;\nconst DOT = 0x2e;\nconst ZERO = 0x30;\nconst ONE = 0x31;\nconst NINE = 0x39;\nconst COLON = 0x3a;\nconst GREATER = 0x3e;\nconst LBRACKET = 0x5b;\nconst BACKSLASH = 0x5c;\nconst LBRACE = 0x7b;\nconst PIPE = 0x7c;\n\ninterface Line {\n readonly start: number;\n /** Index of the line terminator, or of the end of the source — never inside a span. */\n readonly end: number;\n}\n\n/**\n * 3.8.4: a line ends at U+000A, and **a U+000D immediately before it is not part of the line** —\n * it is a terminator like the U+000A itself, so it lies outside every span and comes back\n * untouched. Without that clause a CRLF file behaves differently from the same bytes with LF: the\n * block header reads as `|\\r` and is unrecognised, and a plain scalar carries the carriage return\n * inside its span. Five runtimes split lines with five different standard-library calls, so the\n * treatment has to be stated rather than inherited.\n */\nfunction splitLines(source: string): Line[] {\n const lines: Line[] = [];\n let start = 0;\n const endOf = (i: number): number => (i > start && source.charCodeAt(i - 1) === CR ? i - 1 : i);\n for (let i = 0; i < source.length; i += 1) {\n if (source.charCodeAt(i) === LF) {\n lines.push({ start, end: endOf(i) });\n start = i + 1;\n }\n }\n if (start < source.length) lines.push({ start, end: endOf(source.length) });\n return lines;\n}\n\n/** Index of the first code unit that is not U+0020, or `line.end` for a blank line. */\nfunction firstNonSpace(source: string, line: Line): number {\n let i = line.start;\n while (i < line.end && source.charCodeAt(i) === SPACE) i += 1;\n return i;\n}\n\nfunction isBlank(source: string, line: Line): boolean {\n return firstNonSpace(source, line) === line.end;\n}\n\nfunction hasTab(source: string, line: Line): boolean {\n for (let i = line.start; i < line.end; i += 1) if (source.charCodeAt(i) === TAB) return true;\n return false;\n}\n\n/**\n * 3.8.4 step 3. `---` and `...` at the head of a line, bare or introducing a node: the\n * trailing-content form is declined too, so `--- key: value` never yields a key of `--- key`.\n */\nfunction isDocumentMarker(source: string, from: number, end: number): boolean {\n if (end - from < 3) return false;\n const c = source.charCodeAt(from);\n if (c !== DASH && c !== DOT) return false;\n if (source.charCodeAt(from + 1) !== c || source.charCodeAt(from + 2) !== c) return false;\n return from + 3 === end || source.charCodeAt(from + 3) === SPACE;\n}\n\n/** A colon that ends the line or is followed by U+0020 — the only colon YAML reads as an indicator. */\nfunction isIndicatorColon(source: string, j: number, end: number): boolean {\n if (source.charCodeAt(j) !== COLON) return false;\n return j + 1 === end || source.charCodeAt(j + 1) === SPACE;\n}\n\n/** A `-` that ends the line or is followed by U+0020 — a block sequence entry marker. */\nfunction isSequenceDash(source: string, j: number, end: number): boolean {\n if (source.charCodeAt(j) !== DASH) return false;\n return j + 1 === end || source.charCodeAt(j + 1) === SPACE;\n}\n\n/**\n * The value run of 3.8.4 step 7: every following line that is blank or indented more than the\n * key line. **Those lines are never scanned again** — without that, a multi-line quoted scalar,\n * a multi-line flow collection and a folded plain scalar all leak their continuation lines back\n * into the scan as if they were mappings, and a span can end up holding a scalar's own closing\n * delimiter.\n */\nfunction valueRunEnd(source: string, lines: readonly Line[], li: number, indent: number): number {\n let k = li + 1;\n while (k < lines.length) {\n const next = lines[k] as Line;\n if (!isBlank(source, next) && firstNonSpace(source, next) - next.start <= indent) break;\n k += 1;\n }\n return k;\n}\n\nexport function yamlSpans(source: string, keys: readonly string[]): Span[] {\n const listed = new Set(keys);\n const lines = splitLines(source);\n const spans: Span[] = [];\n let li = 0;\n while (li < lines.length) li = scanLine(source, lines, li, listed, spans);\n return spans;\n}\n\n/** One step of 3.8.4. Returns the index of the next line to scan. */\nfunction scanLine(\n source: string,\n lines: readonly Line[],\n li: number,\n listed: ReadonlySet<string>,\n spans: Span[],\n): number {\n const line = lines[li] as Line;\n const skipLine = li + 1;\n\n // step 1 — blank, or a tab anywhere, which makes indentation undecidable.\n const start = firstNonSpace(source, line);\n if (start === line.end || hasTab(source, line)) return skipLine;\n const indent = start - line.start;\n\n // steps 2 and 3 — comment, directive, document marker.\n const head = source.charCodeAt(start);\n if (head === HASH || head === PERCENT) return skipLine;\n if (isDocumentMarker(source, start, line.end)) return skipLine;\n\n // step 4 — block sequence entries are consumed, not skipped; `- - key: v` nests.\n let i = start;\n while (i < line.end && isSequenceDash(source, i, line.end)) {\n i += 2;\n while (i < line.end && source.charCodeAt(i) === SPACE) i += 1;\n }\n if (i >= line.end) return skipLine;\n\n // step 5 — find the key. A colon NOT followed by U+0020 or the line end is an ordinary key\n // character, so `a:b: v` has the key `a:b`; stating that is what keeps five scanners agreeing.\n const keyStart = i;\n let colon = -1;\n for (let j = i; j < line.end; j += 1) {\n const c = source.charCodeAt(j);\n if (\n c === DQUOTE ||\n c === SQUOTE ||\n c === LBRACE ||\n c === LBRACKET ||\n c === AMPERSAND ||\n c === STAR ||\n c === BANG ||\n c === HASH\n ) {\n return skipLine;\n }\n if (isIndicatorColon(source, j, line.end)) {\n colon = j;\n break;\n }\n }\n if (colon < 0) return skipLine;\n let keyEnd = colon;\n while (keyEnd > keyStart && source.charCodeAt(keyEnd - 1) === SPACE) keyEnd -= 1;\n if (keyEnd <= keyStart) return skipLine;\n\n // step 6 — an empty value means a nested node, whose lines ARE scanned on their own.\n let v = colon + 1;\n while (v < line.end && source.charCodeAt(v) === SPACE) v += 1;\n if (v >= line.end) return skipLine;\n\n // step 7 — the line carries an inline value, so its continuation lines belong to that value.\n const next = valueRunEnd(source, lines, li, indent);\n\n // step 8 — the key must be listed. Checked before the value's form, so an unlisted key costs\n // nothing to decline: this is what makes `run:`, `if:` and `image:` unreachable.\n if (!listed.has(source.slice(keyStart, keyEnd))) return next;\n\n // step 9 — the scalar form.\n const value = source.charCodeAt(v);\n if (\n value === HASH ||\n value === AMPERSAND ||\n value === STAR ||\n value === BANG ||\n value === LBRACE ||\n value === LBRACKET\n ) {\n return next;\n }\n if (value === PIPE || value === GREATER) {\n blockScalar(source, lines, li, next, indent, v, spans);\n return next;\n }\n if (value === DQUOTE || value === SQUOTE) {\n if (next === li + 1) quotedScalar(source, line, v, spans);\n return next;\n }\n if (next === li + 1) plainScalar(source, line, v, spans);\n return next;\n}\n\n/**\n * 3.8.5. One span per non-blank content line, starting after the block's own indentation. The\n * header, the indentation and every line terminator lie outside every span — including the run\n * of line terminators at the end that the chomping indicator governs, which is why `|`, `|-`,\n * `|+`, `>`, `>-` and `>+` are handled identically here.\n */\nfunction blockScalar(\n source: string,\n lines: readonly Line[],\n li: number,\n runEnd: number,\n indent: number,\n v: number,\n spans: Span[],\n): void {\n const line = lines[li] as Line;\n\n // The header: at most one chomping indicator and at most one indentation indicator, in either\n // order, then optional spaces and an optional comment. Anything else is unrecognised.\n let h = v + 1;\n let explicitIndent = 0;\n let chomping = false;\n while (h < line.end) {\n const c = source.charCodeAt(h);\n if ((c === DASH || c === PLUS) && !chomping) {\n chomping = true;\n h += 1;\n continue;\n }\n if (c >= ONE && c <= NINE && explicitIndent === 0) {\n explicitIndent = c - ZERO;\n h += 1;\n continue;\n }\n break;\n }\n while (h < line.end && source.charCodeAt(h) === SPACE) h += 1;\n if (h < line.end && source.charCodeAt(h) !== HASH) return;\n\n // One definition of the run, and three conditions that make the whole block yield no spans.\n const content: Line[] = [];\n let contentIndent = -1;\n for (let k = li + 1; k < runEnd; k += 1) {\n const next = lines[k] as Line;\n if (isBlank(source, next)) continue; // blank lines belong to the block and yield no span\n if (hasTab(source, next)) return;\n const nextIndent = firstNonSpace(source, next) - next.start;\n if (contentIndent < 0) {\n contentIndent = explicitIndent > 0 ? indent + explicitIndent : nextIndent;\n }\n // An explicit indicator that disagrees with the block as written, or a later line dedented\n // inside it, is ambiguous rather than guessable — bail rather than choose.\n if (nextIndent < contentIndent) return;\n content.push(next);\n }\n if (contentIndent <= 0) return;\n\n for (const c of content) {\n const from = c.start + contentIndent;\n if (c.end > from) spans.push({ start: from, end: c.end });\n }\n}\n\n/**\n * 3.8.6. The span is the content between the quotes. Both bails exist so that source characters\n * and content characters are the same thing, which the offset model of 3.1 requires — the same\n * constraint that makes an HTML character reference an opaque unit in 3.6. No colon test applies\n * here: quoting neutralises the colon, and applying the plain-scalar test would decline\n * `title: \"Chapter 1: the beginning\"`.\n */\nfunction quotedScalar(source: string, line: Line, v: number, spans: Span[]): void {\n const quote = source.charCodeAt(v);\n let close = -1;\n for (let j = v + 1; j < line.end; j += 1) {\n const c = source.charCodeAt(j);\n if (quote === DQUOTE && c === BACKSLASH) return;\n if (\n quote === SQUOTE &&\n c === SQUOTE &&\n j + 1 < line.end &&\n source.charCodeAt(j + 1) === SQUOTE\n ) {\n return;\n }\n if (c === quote) {\n close = j;\n break;\n }\n }\n if (close < 0) return;\n\n let after = close + 1;\n while (after < line.end && source.charCodeAt(after) === SPACE) after += 1;\n if (after < line.end && source.charCodeAt(after) !== HASH) return;\n\n if (close > v + 1) spans.push({ start: v + 1, end: close });\n}\n\n/**\n * 3.8.6. In a plain scalar `:` and `#` are still live: U+0020 beside either of them is what turns\n * a scalar into a mapping indicator or a comment, and `dashes` emits U+0020 in every `-spaced`\n * locale. Lifting both out as opaque units leaves the dash token against a boundary marker, which\n * `dashes` declines on its own account — the edge-growth rule of 3.4 is the second net, not the\n * first.\n */\nfunction plainScalar(source: string, line: Line, v: number, spans: Span[]): void {\n // The scalar ends before a trailing comment, so a colon inside that comment is not the\n // scalar's and must not decline it.\n let end = line.end;\n for (let j = v; j < line.end; j += 1) {\n if (source.charCodeAt(j) === HASH && j > v && source.charCodeAt(j - 1) === SPACE) {\n end = j - 1;\n break;\n }\n }\n while (end > v && source.charCodeAt(end - 1) === SPACE) end -= 1;\n if (end <= v) return;\n\n // Compact nesting is not a value: `key: - item` opens a sequence, and `key: a .:` is a mapping\n // whose key is `a .` — a plain scalar can never contain a colon in that position.\n if (isSequenceDash(source, v, line.end)) return;\n for (let j = v; j < end; j += 1) if (isIndicatorColon(source, j, line.end)) return;\n\n let segment = v;\n for (let j = v; j <= end; j += 1) {\n if (j === end || source.charCodeAt(j) === COLON || source.charCodeAt(j) === HASH) {\n if (j > segment) spans.push({ start: segment, end: j });\n segment = j + 1;\n }\n }\n}\n","import { PolytypoError } from \"../errors.js\";\n\n/**\n * modes.md §3.8.2: `yaml` mode's `keys` option, resolved once at the call boundary.\n *\n * It has **no default**, for the reason `dialect` has none. YAML is a data format with islands of\n * prose in it, and nothing in its syntax marks them — `description` holds a sentence and `run`\n * holds a shell script, spelled identically — so a default would be a guess about the schema\n * above the document. An **empty list is legal**: \"process nothing\" is a choice a caller may\n * make, not an error.\n *\n * Checked after `locale`, last of the option checks, alongside `dialect` (ARCHITECTURE.md §7).\n * The two never both apply, since each belongs to a different mode.\n */\nexport function resolveYamlKeys(value: unknown): readonly string[] {\n if (!Array.isArray(value)) {\n throw new PolytypoError(\n \"POLYTYPO_INVALID_OPTION\",\n `\"keys\" is required when mode is \"yaml\" and must be a list of strings (modes.md §3.8.2). ` +\n `Received ${value === undefined ? \"nothing\" : JSON.stringify(value)}.`,\n );\n }\n for (const key of value as readonly unknown[]) {\n if (typeof key !== \"string\") {\n throw new PolytypoError(\n \"POLYTYPO_INVALID_OPTION\",\n `\"keys\" must contain only strings; received ${JSON.stringify(key)}.`,\n );\n }\n }\n return value as readonly string[];\n}\n","import { yamlSpans } from \"../modes/yaml.js\";\nimport type { Options } from \"../types.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { resolveNarrowTarget } from \"./narrow-target.js\";\nimport { resolveYamlKeys } from \"./yaml-keys.js\";\nimport { planRules } from \"./rule-runner.js\";\nimport { analyzeOverSpans, runOverSpans } from \"./span-runner.js\";\nimport type { Change } from \"./origin.js\";\n\n/**\n * `yaml` mode only, and the only mode pipeline with **no parser dependency at all** — span\n * selection is the specified scan of modes.md 3.8, not a library. There is likewise no\n * `POLYTYPO_MALFORMED_INPUT` counterpart here: with no declared grammar to violate, a file that\n * is not YAML yields few spans or none and comes back byte for byte (modes.md 3.8.3). The only\n * throw this mode adds is `keys`, which is about the call and not the input.\n */\nexport function runYamlPipeline(input: string, options: Partial<Options>): string {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const keys = resolveYamlKeys(options.keys);\n return runOverSpans(input, yamlSpans(input, keys), planned, locale, \"yaml\", narrowTarget);\n}\n\n/** analyze.md §1, `yaml` mode: offsets are into the document, not into a span (analyze.md §6). */\nexport function analyzeYamlPipeline(input: string, options: Partial<Options>): Change[] {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const keys = resolveYamlKeys(options.keys);\n return analyzeOverSpans(input, yamlSpans(input, keys), planned, locale, \"yaml\", narrowTarget);\n}\n"],"mappings":";;;;;;;;;;;;AAsBA,IAAM,MAAM;AACZ,IAAM,KAAK;AACX,IAAM,KAAK;AACX,IAAM,QAAQ;AACd,IAAM,OAAO;AACb,IAAM,SAAS;AACf,IAAM,OAAO;AACb,IAAM,UAAU;AAChB,IAAM,YAAY;AAClB,IAAM,SAAS;AACf,IAAM,OAAO;AACb,IAAM,OAAO;AACb,IAAM,OAAO;AACb,IAAM,MAAM;AACZ,IAAM,OAAO;AACb,IAAM,MAAM;AACZ,IAAM,OAAO;AACb,IAAM,QAAQ;AACd,IAAM,UAAU;AAChB,IAAM,WAAW;AACjB,IAAM,YAAY;AAClB,IAAM,SAAS;AACf,IAAM,OAAO;AAgBb,SAAS,WAAW,QAAwB;AAC1C,QAAM,QAAgB,CAAC;AACvB,MAAI,QAAQ;AACZ,QAAM,QAAQ,CAAC,MAAuB,IAAI,SAAS,OAAO,WAAW,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI;AAC7F,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,GAAG;AACzC,QAAI,OAAO,WAAW,CAAC,MAAM,IAAI;AAC/B,YAAM,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC,EAAE,CAAC;AACnC,cAAQ,IAAI;AAAA,IACd;AAAA,EACF;AACA,MAAI,QAAQ,OAAO,OAAQ,OAAM,KAAK,EAAE,OAAO,KAAK,MAAM,OAAO,MAAM,EAAE,CAAC;AAC1E,SAAO;AACT;AAGA,SAAS,cAAc,QAAgB,MAAoB;AACzD,MAAI,IAAI,KAAK;AACb,SAAO,IAAI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