polytypo 1.17.4 → 1.17.5
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/dist/{chunk-GQKLJ73E.cjs → chunk-5NNYCXAY.cjs} +6 -6
- package/dist/{chunk-GQKLJ73E.cjs.map → chunk-5NNYCXAY.cjs.map} +1 -1
- package/dist/{chunk-ZTHGDNKA.cjs → chunk-6K24ORC5.cjs} +35 -1
- package/dist/chunk-6K24ORC5.cjs.map +1 -0
- package/dist/{chunk-7ZKTX4XN.js → chunk-6LD3PNML.js} +2 -2
- package/dist/chunk-DY6SB6P5.cjs +34 -0
- package/dist/{chunk-3LFCYGJ2.cjs.map → chunk-DY6SB6P5.cjs.map} +1 -1
- package/dist/{chunk-MTB7GEW4.cjs → chunk-GBCWL22D.cjs} +3 -3
- package/dist/{chunk-MTB7GEW4.cjs.map → chunk-GBCWL22D.cjs.map} +1 -1
- package/dist/{chunk-3YFHGJLX.js → chunk-GDPTDX27.js} +4 -4
- package/dist/{chunk-PJMNCAM6.js → chunk-H6XVGE3W.js} +3 -3
- package/dist/{chunk-SFAHXSBP.cjs → chunk-J5QSJEEK.cjs} +23 -23
- package/dist/{chunk-SFAHXSBP.cjs.map → chunk-J5QSJEEK.cjs.map} +1 -1
- package/dist/{chunk-4C6Q4VWE.js → chunk-JY3LROUM.js} +2 -2
- package/dist/{chunk-KFRNMKKO.cjs → chunk-MNKTURJI.cjs} +4 -4
- package/dist/{chunk-KFRNMKKO.cjs.map → chunk-MNKTURJI.cjs.map} +1 -1
- package/dist/chunk-O4QRECCM.cjs +36 -0
- package/dist/{chunk-SUDJFZXB.cjs.map → chunk-O4QRECCM.cjs.map} +1 -1
- package/dist/{chunk-HOVHQ7FV.js → chunk-QDCBN2MY.js} +3 -3
- package/dist/{chunk-CBZVCWYE.js → chunk-QSGNKUHE.js} +35 -1
- package/dist/{chunk-CBZVCWYE.js.map → chunk-QSGNKUHE.js.map} +1 -1
- package/dist/{chunk-3B7OFB3Z.js → chunk-S3O4HAUT.js} +2 -2
- package/dist/chunk-WSJG4QWF.cjs +38 -0
- package/dist/{chunk-DKIKUSWJ.cjs.map → chunk-WSJG4QWF.cjs.map} +1 -1
- package/dist/{chunk-67JPAOD6.js → chunk-YEV5P25M.js} +2 -2
- package/dist/html.cjs +9 -9
- package/dist/html.js +4 -4
- package/dist/index.cjs +17 -17
- package/dist/index.js +7 -7
- package/dist/markdown.cjs +10 -10
- package/dist/markdown.js +5 -5
- package/dist/text.cjs +8 -8
- package/dist/text.js +3 -3
- package/dist/yaml.cjs +9 -9
- package/dist/yaml.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-3LFCYGJ2.cjs +0 -34
- package/dist/chunk-DKIKUSWJ.cjs +0 -38
- package/dist/chunk-SUDJFZXB.cjs +0 -36
- package/dist/chunk-ZTHGDNKA.cjs.map +0 -1
- /package/dist/{chunk-7ZKTX4XN.js.map → chunk-6LD3PNML.js.map} +0 -0
- /package/dist/{chunk-3YFHGJLX.js.map → chunk-GDPTDX27.js.map} +0 -0
- /package/dist/{chunk-PJMNCAM6.js.map → chunk-H6XVGE3W.js.map} +0 -0
- /package/dist/{chunk-4C6Q4VWE.js.map → chunk-JY3LROUM.js.map} +0 -0
- /package/dist/{chunk-HOVHQ7FV.js.map → chunk-QDCBN2MY.js.map} +0 -0
- /package/dist/{chunk-3B7OFB3Z.js.map → chunk-S3O4HAUT.js.map} +0 -0
- /package/dist/{chunk-67JPAOD6.js.map → chunk-YEV5P25M.js.map} +0 -0
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
runRules,
|
|
10
10
|
runRulesRecording,
|
|
11
11
|
toCodePoints
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-QSGNKUHE.js";
|
|
13
13
|
|
|
14
14
|
// src/engine/text-pipeline.ts
|
|
15
15
|
function runTextPipeline(input, options) {
|
|
@@ -35,4 +35,4 @@ export {
|
|
|
35
35
|
runTextPipeline,
|
|
36
36
|
analyzeTextPipeline
|
|
37
37
|
};
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
38
|
+
//# sourceMappingURL=chunk-6LD3PNML.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkMNKTURJIcjs = require('./chunk-MNKTURJI.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunk6K24ORC5cjs = require('./chunk-6K24ORC5.cjs');
|
|
12
|
+
|
|
13
|
+
// src/engine/html-pipeline.ts
|
|
14
|
+
function runHtmlPipeline(input, options) {
|
|
15
|
+
const narrowTarget = _chunk6K24ORC5cjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
|
|
16
|
+
const planned = _chunk6K24ORC5cjs.planRules.call(void 0, options.rules);
|
|
17
|
+
const locale = _chunk6K24ORC5cjs.getLocaleData.call(void 0, options.locale);
|
|
18
|
+
_chunk6K24ORC5cjs.assertNoProtect.call(void 0, options.protect, "html");
|
|
19
|
+
const spans = _chunkMNKTURJIcjs.htmlSpans.call(void 0, input);
|
|
20
|
+
return _chunk6K24ORC5cjs.runOverSpans.call(void 0, input, spans, planned, locale, "html", narrowTarget);
|
|
21
|
+
}
|
|
22
|
+
function analyzeHtmlPipeline(input, options) {
|
|
23
|
+
const narrowTarget = _chunk6K24ORC5cjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
|
|
24
|
+
const planned = _chunk6K24ORC5cjs.planRules.call(void 0, options.rules);
|
|
25
|
+
const locale = _chunk6K24ORC5cjs.getLocaleData.call(void 0, options.locale);
|
|
26
|
+
_chunk6K24ORC5cjs.assertNoProtect.call(void 0, options.protect, "html");
|
|
27
|
+
return _chunk6K24ORC5cjs.analyzeOverSpans.call(void 0, input, _chunkMNKTURJIcjs.htmlSpans.call(void 0, input), planned, locale, "html", narrowTarget);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.runHtmlPipeline = runHtmlPipeline; exports.analyzeHtmlPipeline = analyzeHtmlPipeline;
|
|
34
|
+
//# sourceMappingURL=chunk-DY6SB6P5.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-DY6SB6P5.cjs","../src/engine/html-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACMO,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,+CAAA,OAAgB,CAAQ,OAAA,EAAS,MAAM,CAAA;AACvC,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,+CAAA,OAAgB,CAAQ,OAAA,EAAS,MAAM,CAAA;AACvC,EAAA,OAAO,gDAAA,KAAiB,EAAO,yCAAA,KAAe,CAAA,EAAG,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,YAAY,CAAA;AACxF;ADNA;AACA;AACE;AACA;AACF,6FAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-DY6SB6P5.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 { assertNoProtect } from \"./protect.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 assertNoProtect(options.protect, \"html\");\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 assertNoProtect(options.protect, \"html\");\n return analyzeOverSpans(input, htmlSpans(input), planned, locale, \"html\", narrowTarget);\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk6K24ORC5cjs = require('./chunk-6K24ORC5.cjs');
|
|
4
4
|
|
|
5
5
|
// src/engine/assert-fixed-mode.ts
|
|
6
6
|
function assertFixedMode(mode, fixed, entryPoint) {
|
|
7
7
|
if (mode === void 0 || mode === fixed) return;
|
|
8
|
-
throw new (0,
|
|
8
|
+
throw new (0, _chunk6K24ORC5cjs.PolytypoError)(
|
|
9
9
|
"POLYTYPO_INVALID_MODE",
|
|
10
10
|
`"${entryPoint}" only supports mode "${fixed}". Received "${String(mode)}" \u2014 import from "polytypo" for the other modes, or omit \`mode\` here.`
|
|
11
11
|
);
|
|
@@ -14,4 +14,4 @@ function assertFixedMode(mode, fixed, entryPoint) {
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
exports.assertFixedMode = assertFixedMode;
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
17
|
+
//# sourceMappingURL=chunk-GBCWL22D.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-GBCWL22D.cjs","../src/engine/assert-fixed-mode.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACMO,SAAS,eAAA,CAAgB,IAAA,EAAe,KAAA,EAAa,UAAA,EAA0B;AACpF,EAAA,GAAA,CAAI,KAAA,IAAS,KAAA,EAAA,GAAa,KAAA,IAAS,KAAA,EAAO,MAAA;AAC1C,EAAA,MAAM,IAAI,oCAAA;AAAA,IACR,uBAAA;AAAA,IACA,CAAA,CAAA,EAAI,UAAU,CAAA,sBAAA,EAAyB,KAAK,CAAA,aAAA,EAAgB,MAAA,CAAO,IAAI,CAAC,CAAA,2EAAA;AAAA,EAE1E,CAAA;AACF;ADLA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-GBCWL22D.cjs","sourcesContent":[null,"import { PolytypoError } from \"../errors.js\";\nimport type { Mode } from \"../types.js\";\n\n/**\n * `polytypo/text`, `polytypo/html` and `polytypo/markdown` each fix `mode` at the type level by\n * omitting it from their Options type (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1, criterion 6).\n * A plain-JS caller — or a TypeScript caller passing a wider-typed variable, which excess-property\n * checking does not catch — can still supply a conflicting `mode` at runtime. That is rejected\n * explicitly here, never silently ignored or overridden.\n */\nexport function assertFixedMode(mode: unknown, fixed: Mode, entryPoint: string): void {\n if (mode === undefined || mode === fixed) return;\n throw new PolytypoError(\n \"POLYTYPO_INVALID_MODE\",\n `\"${entryPoint}\" only supports mode \"${fixed}\". Received \"${String(mode)}\" — ` +\n `import from \"polytypo\" for the other modes, or omit \\`mode\\` here.`,\n );\n}\n"]}
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
htmlFragmentSpans,
|
|
3
3
|
isSkippedElement,
|
|
4
4
|
wrapParserErrors
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-S3O4HAUT.js";
|
|
6
6
|
import {
|
|
7
7
|
resolveFrontmatterKeys,
|
|
8
8
|
yamlSpans
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JY3LROUM.js";
|
|
10
10
|
import {
|
|
11
11
|
PolytypoError,
|
|
12
12
|
analyzeOverUnits,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
planRules,
|
|
17
17
|
resolveNarrowTarget,
|
|
18
18
|
runOverUnits
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-QSGNKUHE.js";
|
|
20
20
|
|
|
21
21
|
// src/modes/markdown.ts
|
|
22
22
|
import { parse, postprocess, preprocess } from "micromark";
|
|
@@ -394,4 +394,4 @@ export {
|
|
|
394
394
|
runMarkdownPipeline,
|
|
395
395
|
analyzeMarkdownPipeline
|
|
396
396
|
};
|
|
397
|
-
//# sourceMappingURL=chunk-
|
|
397
|
+
//# sourceMappingURL=chunk-GDPTDX27.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
htmlSpans
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-S3O4HAUT.js";
|
|
4
4
|
import {
|
|
5
5
|
analyzeOverSpans,
|
|
6
6
|
assertNoProtect,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
planRules,
|
|
9
9
|
resolveNarrowTarget,
|
|
10
10
|
runOverSpans
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-QSGNKUHE.js";
|
|
12
12
|
|
|
13
13
|
// src/engine/html-pipeline.ts
|
|
14
14
|
function runHtmlPipeline(input, options) {
|
|
@@ -31,4 +31,4 @@ export {
|
|
|
31
31
|
runHtmlPipeline,
|
|
32
32
|
analyzeHtmlPipeline
|
|
33
33
|
};
|
|
34
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-H6XVGE3W.js.map
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkMNKTURJIcjs = require('./chunk-MNKTURJI.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk5NNYCXAYcjs = require('./chunk-5NNYCXAY.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ var _chunkGQKLJ73Ecjs = require('./chunk-GQKLJ73E.cjs');
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunk6K24ORC5cjs = require('./chunk-6K24ORC5.cjs');
|
|
20
20
|
|
|
21
21
|
// src/modes/markdown.ts
|
|
22
22
|
var _micromark = require('micromark');
|
|
@@ -109,7 +109,7 @@ function updateElementStack(stack, tag, caseSensitive) {
|
|
|
109
109
|
if (stack[stack.length - 1] === name) stack.pop();
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
|
-
if (!parsed.selfClosing &&
|
|
112
|
+
if (!parsed.selfClosing && _chunkMNKTURJIcjs.isSkippedElement.call(void 0, name)) stack.push(name);
|
|
113
113
|
}
|
|
114
114
|
function tokenize(source, extensions) {
|
|
115
115
|
return _micromark.postprocess.call(void 0,
|
|
@@ -119,12 +119,12 @@ function tokenize(source, extensions) {
|
|
|
119
119
|
function resolveDialect(dialect) {
|
|
120
120
|
if (dialect === "commonmark" || dialect === "mdx") return dialect;
|
|
121
121
|
if (dialect === void 0) {
|
|
122
|
-
throw new (0,
|
|
122
|
+
throw new (0, _chunk6K24ORC5cjs.PolytypoError)(
|
|
123
123
|
"POLYTYPO_INVALID_DIALECT",
|
|
124
124
|
'Mode "markdown" requires a dialect. Expected "commonmark" or "mdx"; there is no default.'
|
|
125
125
|
);
|
|
126
126
|
}
|
|
127
|
-
throw new (0,
|
|
127
|
+
throw new (0, _chunk6K24ORC5cjs.PolytypoError)(
|
|
128
128
|
"POLYTYPO_INVALID_DIALECT",
|
|
129
129
|
`Unknown dialect "${String(dialect)}". Expected "commonmark" or "mdx".`
|
|
130
130
|
);
|
|
@@ -276,7 +276,7 @@ function markdownSpans(source, dialect) {
|
|
|
276
276
|
const masked = maskFrontmatter(source, block);
|
|
277
277
|
const shift = masked.charCodeAt(0) === BOM ? 1 : 0;
|
|
278
278
|
const text = shift === 0 ? masked : masked.slice(shift);
|
|
279
|
-
const events =
|
|
279
|
+
const events = _chunkMNKTURJIcjs.wrapParserErrors.call(void 0, dialect, () => tokenize(text, extensionsFor(dialect)));
|
|
280
280
|
const spans = [];
|
|
281
281
|
const elementStack = [];
|
|
282
282
|
let skipDepth = 0;
|
|
@@ -299,7 +299,7 @@ function markdownSpans(source, dialect) {
|
|
|
299
299
|
}
|
|
300
300
|
if (type === "htmlFlow") {
|
|
301
301
|
if (kind === "enter" && skipDepth === 0 && elementStack.length === 0) {
|
|
302
|
-
for (const span of
|
|
302
|
+
for (const span of _chunkMNKTURJIcjs.htmlFragmentSpans.call(void 0,
|
|
303
303
|
text.slice(token.start.offset, token.end.offset),
|
|
304
304
|
token.start.offset + shift
|
|
305
305
|
)) {
|
|
@@ -321,7 +321,7 @@ function markdownSpans(source, dialect) {
|
|
|
321
321
|
}
|
|
322
322
|
const trimmed = trimUrlTails(
|
|
323
323
|
source,
|
|
324
|
-
|
|
324
|
+
_chunk6K24ORC5cjs.normalizeSpans.call(void 0, removeRanges(spans, labelRanges(events, shift))),
|
|
325
325
|
urlEnds
|
|
326
326
|
);
|
|
327
327
|
if (block === null) return trimmed;
|
|
@@ -354,19 +354,19 @@ function frontmatterSpans(source, frontmatterKeys) {
|
|
|
354
354
|
const { contentStart, contentEnd } = block;
|
|
355
355
|
const content = source.slice(contentStart, contentEnd);
|
|
356
356
|
const declined = declinedContentRanges(content);
|
|
357
|
-
return
|
|
357
|
+
return _chunk5NNYCXAYcjs.yamlSpans.call(void 0, content, frontmatterKeys).filter((span) => !declined.some((range) => span.start < range.end && range.start < span.end)).map((span) => ({ start: span.start + contentStart, end: span.end + contentStart }));
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
// src/engine/markdown-pipeline.ts
|
|
361
361
|
function runMarkdownPipeline(input, options) {
|
|
362
|
-
const narrowTarget =
|
|
363
|
-
const planned =
|
|
364
|
-
const locale =
|
|
362
|
+
const narrowTarget = _chunk6K24ORC5cjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
|
|
363
|
+
const planned = _chunk6K24ORC5cjs.planRules.call(void 0, options.rules);
|
|
364
|
+
const locale = _chunk6K24ORC5cjs.getLocaleData.call(void 0, options.locale);
|
|
365
365
|
const dialect = resolveDialect(options.dialect);
|
|
366
|
-
const frontmatterKeys =
|
|
367
|
-
|
|
366
|
+
const frontmatterKeys = _chunk5NNYCXAYcjs.resolveFrontmatterKeys.call(void 0, options.frontmatterKeys);
|
|
367
|
+
_chunk6K24ORC5cjs.assertNoProtect.call(void 0, options.protect, "markdown");
|
|
368
368
|
const units = unitsOf(input, dialect, frontmatterKeys);
|
|
369
|
-
return
|
|
369
|
+
return _chunk6K24ORC5cjs.runOverUnits.call(void 0, input, units, planned, locale, "markdown", narrowTarget);
|
|
370
370
|
}
|
|
371
371
|
function unitsOf(input, dialect, frontmatterKeys) {
|
|
372
372
|
const body = markdownSpans(input, dialect);
|
|
@@ -374,13 +374,13 @@ function unitsOf(input, dialect, frontmatterKeys) {
|
|
|
374
374
|
return [frontmatterSpans(input, frontmatterKeys), body];
|
|
375
375
|
}
|
|
376
376
|
function analyzeMarkdownPipeline(input, options) {
|
|
377
|
-
const narrowTarget =
|
|
378
|
-
const planned =
|
|
379
|
-
const locale =
|
|
377
|
+
const narrowTarget = _chunk6K24ORC5cjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
|
|
378
|
+
const planned = _chunk6K24ORC5cjs.planRules.call(void 0, options.rules);
|
|
379
|
+
const locale = _chunk6K24ORC5cjs.getLocaleData.call(void 0, options.locale);
|
|
380
380
|
const dialect = resolveDialect(options.dialect);
|
|
381
|
-
const frontmatterKeys =
|
|
382
|
-
|
|
383
|
-
return
|
|
381
|
+
const frontmatterKeys = _chunk5NNYCXAYcjs.resolveFrontmatterKeys.call(void 0, options.frontmatterKeys);
|
|
382
|
+
_chunk6K24ORC5cjs.assertNoProtect.call(void 0, options.protect, "markdown");
|
|
383
|
+
return _chunk6K24ORC5cjs.analyzeOverUnits.call(void 0,
|
|
384
384
|
input,
|
|
385
385
|
unitsOf(input, dialect, frontmatterKeys),
|
|
386
386
|
planned,
|
|
@@ -394,4 +394,4 @@ function analyzeMarkdownPipeline(input, options) {
|
|
|
394
394
|
|
|
395
395
|
|
|
396
396
|
exports.runMarkdownPipeline = runMarkdownPipeline; exports.analyzeMarkdownPipeline = analyzeMarkdownPipeline;
|
|
397
|
-
//# sourceMappingURL=chunk-
|
|
397
|
+
//# sourceMappingURL=chunk-J5QSJEEK.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-SFAHXSBP.cjs","../src/modes/markdown.ts","../src/engine/markdown-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACpBA,sCAA+C;AAC/C,gFAA4B;AAC5B,gEAAoB;AACpB,oEAAsB;AAiBtB,IAAM,oBAAA,kBAA2C,IAAI,GAAA,CAAI;AAAA;AAAA,EAEvD,YAAA;AAAA,EACA,cAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA;AAAA,EAGA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA;AAAA,EAEA,iBAAA;AAAA,EACA,4BAAA;AAAA;AAAA;AAAA;AAAA,EAIA,mBAAA;AAAA,EACA,mBAAA;AAAA,EACA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,MAAA;AAAA,EACA;AACF,CAAC,CAAA;AAGD,IAAM,oBAAA,kBAA2C,IAAI,GAAA,CAAI;AAAA,EACvD,UAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,UAAA,EAAY,EAAA;AAClB,IAAM,aAAA,EAAe,EAAA;AACrB,IAAM,MAAA,EAAQ,EAAA;AACd,IAAM,YAAA,EAAc,EAAA;AACpB,IAAM,SAAA,EAAW,EAAA;AAEjB,SAAS,aAAA,CAAc,IAAA,EAAuB;AAC5C,EAAA,OAAQ,KAAA,GAAQ,GAAA,GAAQ,KAAA,GAAQ,IAAA,GAAU,KAAA,GAAQ,G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,CAAQ,KAAA,EAAO,OAAA,EAAS,eAAe,CAAA;AACrD,EAAA,OAAO,4CAAA,KAAa,EAAO,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,UAAA,EAAY,YAAY,CAAA;AAC7E;AAYA,SAAS,OAAA,CACP,KAAA,EACA,OAAA,EACA,eAAA,EACU;AACV,EAAA,MAAM,KAAA,EAAO,aAAA,CAAc,KAAA,EAAO,OAAO,CAAA;AACzC,EAAA,GAAA,CAAI,gBAAA,IAAoB,KAAA,CAAA,EAAW,OAAO,CAAC,IAAI,CAAA;AAC/C,EAAA,OAAO,CAAC,gBAAA,CAAiB,KAAA,EAAO,eAAe,CAAA,EAAG,IAAI,CAAA;AACxD;AAKO,SAAS,uBAAA,CAAwB,KAAA,EAAe,OAAA,EAAqC;AAC1F,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,EAAA,MAAM,QAAA,EAAU,yCAAA,OAAU,CAAQ,KAAK,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,6CAAA,OAAc,CAAQ,MAAM,CAAA;AAC3C,EAAA,MAAM,QAAA,EAAU,cAAA,CAAe,OAAA,CAAQ,OAAO,CAAA;AAC9C,EAAA,MAAM,gBAAA,EAAkB,sDAAA,OAAuB,CAAQ,eAAe,CAAA;AACtE,EAAA,+CAAA,OAAgB,CAAQ,OAAA,EAAS,UAAU,CAAA;AAC3C,EAAA,OAAO,gDAAA;AAAA,IACL,KAAA;AAAA,IACA,OAAA,CAAQ,KAAA,EAAO,OAAA,EAAS,eAAe,CAAA;AAAA,IACvC,OAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF;AFiUA;AACA;AACE;AACA;AACF,6GAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-SFAHXSBP.cjs","sourcesContent":[null,"import { parse, postprocess, preprocess } from \"micromark\";\nimport { frontmatter } from \"micromark-extension-frontmatter\";\nimport { gfm } from \"micromark-extension-gfm\";\nimport { mdxjs } from \"micromark-extension-mdxjs\";\nimport type { Event, Extension } from \"micromark-util-types\";\nimport { PolytypoError } from \"../errors.js\";\nimport type { Dialect } from \"../types.js\";\nimport { htmlFragmentSpans, isSkippedElement } from \"./html.js\";\nimport { yamlSpans } from \"./yaml.js\";\nimport { wrapParserErrors } from \"./parse-error.js\";\nimport { normalizeSpans, 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 // 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 // GFM footnotes: the call's label and the definition's label are matched against each other\n \"gfmFootnoteCall\",\n \"gfmFootnoteDefinitionLabel\",\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/** modes.md 3.7.3 (spec 1.17.2): the text of a shortcut or collapsed reference is its label. */\nfunction labelRanges(events: readonly Event[], shift: number): Span[] {\n const ranges: Span[] = [];\n const open: { hasDest: boolean; labels: Span[] }[] = [];\n for (const [kind, token] of events) {\n const type: string = token.type;\n if (type === \"link\" || type === \"image\") {\n if (kind === \"enter\") open.push({ hasDest: false, labels: [] });\n else {\n const done = open.pop();\n if (done !== undefined && !done.hasDest) ranges.push(...done.labels);\n }\n continue;\n }\n const top = open[open.length - 1];\n if (top === undefined || kind !== \"enter\") continue;\n if (type === \"resource\" || type === \"referenceString\") top.hasDest = true;\n if (type === \"labelText\") {\n top.labels.push({ start: token.start.offset + shift, end: token.end.offset + shift });\n }\n }\n return ranges;\n}\n\nfunction startsUrl(source: string, i: number, end: number): boolean {\n const lower = (k: number) => {\n const c = source.charCodeAt(k);\n return c >= 0x41 && c <= 0x5a ? c + 0x20 : c;\n };\n const at = (word: string) => {\n if (i + word.length > end) return false;\n for (let k = 0; k < word.length; k += 1) if (lower(i + k) !== word.charCodeAt(k)) return false;\n return true;\n };\n return at(\"www.\") || at(\"http://\") || at(\"https://\");\n}\n\n/**\n * modes.md 3.7.3 (spec 1.17.2): the tail of a bare URL, found by scanning the source rather than\n * asking a parser, because parsers disagree about where a URL may start and where it ends.\n */\nfunction trimUrlTails(\n source: string,\n spans: readonly Span[],\n urlEnds: ReadonlySet<number>,\n): Span[] {\n const out: Span[] = [];\n for (const span of spans) {\n let from = span.start;\n let i = span.start;\n let guard =\n span.urlTail === true ||\n (urlEnds.has(span.start) &&\n (source.charCodeAt(span.start) === 0x20 || source.charCodeAt(span.start) === 0x09));\n while (i < span.end) {\n if (!(i === span.start && urlEnds.has(i)) && !startsUrl(source, i, span.end)) {\n i += 1;\n continue;\n }\n let e = i;\n while (e < span.end) {\n const c = source.charCodeAt(e);\n if (c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d || c === 0x3c) break;\n e += 1;\n }\n if (e === i) {\n i += 1;\n continue;\n }\n if (i > from)\n out.push(guard ? { start: from, end: i, urlTail: true } : { start: from, end: i });\n guard = e < span.end && (source.charCodeAt(e) === 0x20 || source.charCodeAt(e) === 0x09);\n from = e;\n i = e;\n }\n if (from < span.end)\n out.push(\n guard ? { start: from, end: span.end, urlTail: true } : { start: from, end: span.end },\n );\n }\n return out;\n}\n\nfunction removeRanges(spans: readonly Span[], ranges: readonly Span[]): Span[] {\n if (ranges.length === 0) return [...spans];\n const out: Span[] = [];\n for (const span of spans) {\n let pieces: Span[] = [span];\n for (const r of ranges) {\n pieces = pieces.flatMap((q) => {\n if (r.end <= q.start || r.start >= q.end) return [q];\n const res: Span[] = [];\n if (q.start < r.start) res.push({ start: q.start, end: r.start });\n if (r.end < q.end) res.push({ start: r.end, end: q.end });\n return res;\n });\n }\n out.push(...pieces);\n }\n return out;\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 const urlEnds = new Set<number>();\n for (const [kind, token] of events) {\n if (\n kind === \"exit\" &&\n (token.type as string) === \"literalAutolink\" &&\n startsUrl(source, token.start.offset + shift, token.end.offset + shift)\n ) {\n urlEnds.add(token.end.offset + shift);\n }\n }\n const trimmed = trimUrlTails(\n source,\n normalizeSpans(removeRanges(spans, labelRanges(events, shift))),\n urlEnds,\n );\n if (block === null) return trimmed;\n return trimmed.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 { assertNoProtect } from \"./protect.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 assertNoProtect(options.protect, \"markdown\");\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 assertNoProtect(options.protect, \"markdown\");\n return analyzeOverUnits(\n input,\n unitsOf(input, dialect, frontmatterKeys),\n planned,\n locale,\n \"markdown\",\n narrowTarget,\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-J5QSJEEK.cjs","../src/modes/markdown.ts","../src/engine/markdown-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACpBA,sCAA+C;AAC/C,gFAA4B;AAC5B,gEAAoB;AACpB,oEAAsB;AAiBtB,IAAM,oBAAA,kBAA2C,IAAI,GAAA,CAAI;AAAA;AAAA,EAEvD,YAAA;AAAA,EACA,cAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA;AAAA,EAGA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA;AAAA,EAEA,iBAAA;AAAA,EACA,4BAAA;AAAA;AAAA;AAAA;AAAA,EAIA,mBAAA;AAAA,EACA,mBAAA;AAAA,EACA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,MAAA;AAAA,EACA;AACF,CAAC,CAAA;AAGD,IAAM,oBAAA,kBAA2C,IAAI,GAAA,CAAI;AAAA,EACvD,UAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,UAAA,EAAY,EAAA;AAClB,IAAM,aAAA,EAAe,EAAA;AACrB,IAAM,MAAA,EAAQ,EAAA;AACd,IAAM,YAAA,EAAc,EAAA;AACpB,IAAM,SAAA,EAAW,EAAA;AAEjB,SAAS,aAAA,CAAc,IAAA,EAAuB;AAC5C,EAAA,OAAQ,KAAA,GAAQ,GAAA,GAAQ,KAAA,GAAQ,IAAA,GAAU,KAAA,GAAQ,GAAA,GAAQ,KAAA,GAAQ,EAAA;AACpE;AAEA,SAAS,aAAA,CAAc,IAAA,EAAuB;AAI5C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,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,UAAA,EAAY,YAAY,CAAA;AAC7E;AAYA,SAAS,OAAA,CACP,KAAA,EACA,OAAA,EACA,eAAA,EACU;AACV,EAAA,MAAM,KAAA,EAAO,aAAA,CAAc,KAAA,EAAO,OAAO,CAAA;AACzC,EAAA,GAAA,CAAI,gBAAA,IAAoB,KAAA,CAAA,EAAW,OAAO,CAAC,IAAI,CAAA;AAC/C,EAAA,OAAO,CAAC,gBAAA,CAAiB,KAAA,EAAO,eAAe,CAAA,EAAG,IAAI,CAAA;AACxD;AAKO,SAAS,uBAAA,CAAwB,KAAA,EAAe,OAAA,EAAqC;AAC1F,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,EAAA,MAAM,QAAA,EAAU,yCAAA,OAAU,CAAQ,KAAK,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,6CAAA,OAAc,CAAQ,MAAM,CAAA;AAC3C,EAAA,MAAM,QAAA,EAAU,cAAA,CAAe,OAAA,CAAQ,OAAO,CAAA;AAC9C,EAAA,MAAM,gBAAA,EAAkB,sDAAA,OAAuB,CAAQ,eAAe,CAAA;AACtE,EAAA,+CAAA,OAAgB,CAAQ,OAAA,EAAS,UAAU,CAAA;AAC3C,EAAA,OAAO,gDAAA;AAAA,IACL,KAAA;AAAA,IACA,OAAA,CAAQ,KAAA,EAAO,OAAA,EAAS,eAAe,CAAA;AAAA,IACvC,OAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF;AFiUA;AACA;AACE;AACA;AACF,6GAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-J5QSJEEK.cjs","sourcesContent":[null,"import { parse, postprocess, preprocess } from \"micromark\";\nimport { frontmatter } from \"micromark-extension-frontmatter\";\nimport { gfm } from \"micromark-extension-gfm\";\nimport { mdxjs } from \"micromark-extension-mdxjs\";\nimport type { Event, Extension } from \"micromark-util-types\";\nimport { PolytypoError } from \"../errors.js\";\nimport type { Dialect } from \"../types.js\";\nimport { htmlFragmentSpans, isSkippedElement } from \"./html.js\";\nimport { yamlSpans } from \"./yaml.js\";\nimport { wrapParserErrors } from \"./parse-error.js\";\nimport { normalizeSpans, 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 // 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 // GFM footnotes: the call's label and the definition's label are matched against each other\n \"gfmFootnoteCall\",\n \"gfmFootnoteDefinitionLabel\",\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/** modes.md 3.7.3 (spec 1.17.2): the text of a shortcut or collapsed reference is its label. */\nfunction labelRanges(events: readonly Event[], shift: number): Span[] {\n const ranges: Span[] = [];\n const open: { hasDest: boolean; labels: Span[] }[] = [];\n for (const [kind, token] of events) {\n const type: string = token.type;\n if (type === \"link\" || type === \"image\") {\n if (kind === \"enter\") open.push({ hasDest: false, labels: [] });\n else {\n const done = open.pop();\n if (done !== undefined && !done.hasDest) ranges.push(...done.labels);\n }\n continue;\n }\n const top = open[open.length - 1];\n if (top === undefined || kind !== \"enter\") continue;\n if (type === \"resource\" || type === \"referenceString\") top.hasDest = true;\n if (type === \"labelText\") {\n top.labels.push({ start: token.start.offset + shift, end: token.end.offset + shift });\n }\n }\n return ranges;\n}\n\nfunction startsUrl(source: string, i: number, end: number): boolean {\n const lower = (k: number) => {\n const c = source.charCodeAt(k);\n return c >= 0x41 && c <= 0x5a ? c + 0x20 : c;\n };\n const at = (word: string) => {\n if (i + word.length > end) return false;\n for (let k = 0; k < word.length; k += 1) if (lower(i + k) !== word.charCodeAt(k)) return false;\n return true;\n };\n return at(\"www.\") || at(\"http://\") || at(\"https://\");\n}\n\n/**\n * modes.md 3.7.3 (spec 1.17.2): the tail of a bare URL, found by scanning the source rather than\n * asking a parser, because parsers disagree about where a URL may start and where it ends.\n */\nfunction trimUrlTails(\n source: string,\n spans: readonly Span[],\n urlEnds: ReadonlySet<number>,\n): Span[] {\n const out: Span[] = [];\n for (const span of spans) {\n let from = span.start;\n let i = span.start;\n let guard =\n span.urlTail === true ||\n (urlEnds.has(span.start) &&\n (source.charCodeAt(span.start) === 0x20 || source.charCodeAt(span.start) === 0x09));\n while (i < span.end) {\n if (!(i === span.start && urlEnds.has(i)) && !startsUrl(source, i, span.end)) {\n i += 1;\n continue;\n }\n let e = i;\n while (e < span.end) {\n const c = source.charCodeAt(e);\n if (c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d || c === 0x3c) break;\n e += 1;\n }\n if (e === i) {\n i += 1;\n continue;\n }\n if (i > from)\n out.push(guard ? { start: from, end: i, urlTail: true } : { start: from, end: i });\n guard = e < span.end && (source.charCodeAt(e) === 0x20 || source.charCodeAt(e) === 0x09);\n from = e;\n i = e;\n }\n if (from < span.end)\n out.push(\n guard ? { start: from, end: span.end, urlTail: true } : { start: from, end: span.end },\n );\n }\n return out;\n}\n\nfunction removeRanges(spans: readonly Span[], ranges: readonly Span[]): Span[] {\n if (ranges.length === 0) return [...spans];\n const out: Span[] = [];\n for (const span of spans) {\n let pieces: Span[] = [span];\n for (const r of ranges) {\n pieces = pieces.flatMap((q) => {\n if (r.end <= q.start || r.start >= q.end) return [q];\n const res: Span[] = [];\n if (q.start < r.start) res.push({ start: q.start, end: r.start });\n if (r.end < q.end) res.push({ start: r.end, end: q.end });\n return res;\n });\n }\n out.push(...pieces);\n }\n return out;\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 const urlEnds = new Set<number>();\n for (const [kind, token] of events) {\n if (\n kind === \"exit\" &&\n (token.type as string) === \"literalAutolink\" &&\n startsUrl(source, token.start.offset + shift, token.end.offset + shift)\n ) {\n urlEnds.add(token.end.offset + shift);\n }\n }\n const trimmed = trimUrlTails(\n source,\n normalizeSpans(removeRanges(spans, labelRanges(events, shift))),\n urlEnds,\n );\n if (block === null) return trimmed;\n return trimmed.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 { assertNoProtect } from \"./protect.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 assertNoProtect(options.protect, \"markdown\");\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 assertNoProtect(options.protect, \"markdown\");\n return analyzeOverUnits(\n input,\n unitsOf(input, dialect, frontmatterKeys),\n planned,\n locale,\n \"markdown\",\n narrowTarget,\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PolytypoError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QSGNKUHE.js";
|
|
4
4
|
|
|
5
5
|
// src/modes/yaml.ts
|
|
6
6
|
var TAB = 9;
|
|
@@ -370,4 +370,4 @@ export {
|
|
|
370
370
|
resolveYamlKeys,
|
|
371
371
|
resolveFrontmatterKeys
|
|
372
372
|
};
|
|
373
|
-
//# sourceMappingURL=chunk-
|
|
373
|
+
//# sourceMappingURL=chunk-JY3LROUM.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk6K24ORC5cjs = require('./chunk-6K24ORC5.cjs');
|
|
4
4
|
|
|
5
5
|
// src/modes/html.ts
|
|
6
6
|
var _parse5 = require('parse5');
|
|
@@ -20,8 +20,8 @@ function wrapParserErrors(what, run) {
|
|
|
20
20
|
try {
|
|
21
21
|
return run();
|
|
22
22
|
} catch (error) {
|
|
23
|
-
if (error instanceof
|
|
24
|
-
throw new (0,
|
|
23
|
+
if (error instanceof _chunk6K24ORC5cjs.PolytypoError) throw error;
|
|
24
|
+
throw new (0, _chunk6K24ORC5cjs.PolytypoError)(
|
|
25
25
|
"POLYTYPO_MALFORMED_INPUT",
|
|
26
26
|
`Input does not parse as ${what}: ${describe(error)}`
|
|
27
27
|
);
|
|
@@ -144,4 +144,4 @@ function htmlFragmentSpans(source, offset) {
|
|
|
144
144
|
|
|
145
145
|
|
|
146
146
|
exports.wrapParserErrors = wrapParserErrors; exports.isSkippedElement = isSkippedElement; exports.htmlSpans = htmlSpans; exports.htmlFragmentSpans = htmlFragmentSpans;
|
|
147
|
-
//# sourceMappingURL=chunk-
|
|
147
|
+
//# sourceMappingURL=chunk-MNKTURJI.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-MNKTURJI.cjs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,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-MNKTURJI.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"]}
|