polytypo 1.29.0 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/{chunk-VRFR4RLZ.js → chunk-4MZ7UTRC.js} +3 -3
- package/dist/{chunk-SMI5FQDC.js → chunk-5KKFD2HR.js} +2 -2
- package/dist/{chunk-IAD2Z4LK.js → chunk-64QBZU2Z.js} +2 -2
- package/dist/{chunk-DGIQD3CL.cjs → chunk-6KMUSOJL.cjs} +9 -7
- package/dist/chunk-6KMUSOJL.cjs.map +1 -0
- package/dist/{chunk-Q23NSX5T.js → chunk-6NR6365G.js} +3 -3
- package/dist/chunk-6PIVYTIT.cjs +38 -0
- package/dist/{chunk-CRSRFLXY.cjs.map → chunk-6PIVYTIT.cjs.map} +1 -1
- package/dist/{chunk-TO4ONFOS.cjs → chunk-CNJV4SNX.cjs} +3 -3
- package/dist/{chunk-TO4ONFOS.cjs.map → chunk-CNJV4SNX.cjs.map} +1 -1
- package/dist/chunk-EBIS5RQW.cjs +36 -0
- package/dist/{chunk-F6U75LDW.cjs.map → chunk-EBIS5RQW.cjs.map} +1 -1
- package/dist/{chunk-46HVHDLD.js → chunk-GGUNL3P6.js} +4 -4
- package/dist/{chunk-6BEQTKTO.cjs → chunk-LLPHSREU.cjs} +23 -23
- package/dist/{chunk-6BEQTKTO.cjs.map → chunk-LLPHSREU.cjs.map} +1 -1
- package/dist/{chunk-SJTHHQVJ.js → chunk-LWWSWVTI.js} +2 -2
- package/dist/chunk-QDTN65K5.cjs +34 -0
- package/dist/{chunk-5X4EL2FZ.cjs.map → chunk-QDTN65K5.cjs.map} +1 -1
- package/dist/{chunk-5NTTJKWN.cjs → chunk-RB7DVXKD.cjs} +6 -6
- package/dist/{chunk-5NTTJKWN.cjs.map → chunk-RB7DVXKD.cjs.map} +1 -1
- package/dist/{chunk-OW7RDXON.js → chunk-Y3POOZLN.js} +1 -1
- package/dist/{chunk-OW7RDXON.js.map → chunk-Y3POOZLN.js.map} +1 -1
- package/dist/{chunk-2DFXIIFM.js → chunk-ZDTUYVAT.js} +6 -4
- package/dist/chunk-ZDTUYVAT.js.map +1 -0
- package/dist/{chunk-RM6623UN.cjs → chunk-ZFNQ2P2F.cjs} +1 -1
- package/dist/{chunk-RM6623UN.cjs.map → chunk-ZFNQ2P2F.cjs.map} +1 -1
- package/dist/html-BGFLg6_c.d.cts +10 -0
- package/dist/html-BGFLg6_c.d.ts +10 -0
- package/dist/html.cjs +12 -9
- package/dist/html.cjs.map +1 -1
- package/dist/html.d.cts +1 -0
- package/dist/html.d.ts +1 -0
- package/dist/html.js +7 -4
- package/dist/html.js.map +1 -1
- package/dist/index.cjs +20 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- 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-2DFXIIFM.js.map +0 -1
- package/dist/chunk-5X4EL2FZ.cjs +0 -34
- package/dist/chunk-CRSRFLXY.cjs +0 -38
- package/dist/chunk-DGIQD3CL.cjs.map +0 -1
- package/dist/chunk-F6U75LDW.cjs +0 -36
- /package/dist/{chunk-VRFR4RLZ.js.map → chunk-4MZ7UTRC.js.map} +0 -0
- /package/dist/{chunk-SMI5FQDC.js.map → chunk-5KKFD2HR.js.map} +0 -0
- /package/dist/{chunk-IAD2Z4LK.js.map → chunk-64QBZU2Z.js.map} +0 -0
- /package/dist/{chunk-Q23NSX5T.js.map → chunk-6NR6365G.js.map} +0 -0
- /package/dist/{chunk-46HVHDLD.js.map → chunk-GGUNL3P6.js.map} +0 -0
- /package/dist/{chunk-SJTHHQVJ.js.map → chunk-LWWSWVTI.js.map} +0 -0
package/README.md
CHANGED
|
@@ -70,6 +70,15 @@ transform(`<a title="test... wait">Wait... she said "go on."</a>`, { locale: "en
|
|
|
70
70
|
// <a title="test... wait">Wait… she said “go on.”</a>
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
`html` mode leaves ten elements alone, with everything inside them: `code`, `pre`, `kbd`, `samp`,
|
|
74
|
+
`var`, `script`, `style`, `textarea`, `svg` and `math`. If you walk a document with a parser of your
|
|
75
|
+
own, read the list instead of copying it. It is a frozen array, exported from `polytypo/html` and
|
|
76
|
+
`polytypo`:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { SKIPPED_ELEMENTS } from "polytypo/html";
|
|
80
|
+
```
|
|
81
|
+
|
|
73
82
|
`yaml` mode is the one that asks something of you, and it asks for a reason. YAML is a data format
|
|
74
83
|
with prose in some of it, so you name the keys whose values are prose; there is no default and no
|
|
75
84
|
guess:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
htmlSpans
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZDTUYVAT.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-Y3POOZLN.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-4MZ7UTRC.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PolytypoError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Y3POOZLN.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-5KKFD2HR.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PolytypoError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Y3POOZLN.js";
|
|
4
4
|
|
|
5
5
|
// src/engine/assert-fixed-mode.ts
|
|
6
6
|
function assertFixedMode(mode, fixed, entryPoint) {
|
|
@@ -14,4 +14,4 @@ function assertFixedMode(mode, fixed, entryPoint) {
|
|
|
14
14
|
export {
|
|
15
15
|
assertFixedMode
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
17
|
+
//# sourceMappingURL=chunk-64QBZU2Z.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkZFNQ2P2Fcjs = require('./chunk-ZFNQ2P2F.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 _chunkZFNQ2P2Fcjs.PolytypoError) throw error;
|
|
24
|
+
throw new (0, _chunkZFNQ2P2Fcjs.PolytypoError)(
|
|
25
25
|
"POLYTYPO_MALFORMED_INPUT",
|
|
26
26
|
`Input does not parse as ${what}: ${describe(error)}`
|
|
27
27
|
);
|
|
@@ -29,7 +29,7 @@ function wrapParserErrors(what, run) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// src/modes/html.ts
|
|
32
|
-
var SKIPPED_ELEMENTS =
|
|
32
|
+
var SKIPPED_ELEMENTS = Object.freeze([
|
|
33
33
|
"code",
|
|
34
34
|
"pre",
|
|
35
35
|
"kbd",
|
|
@@ -41,8 +41,9 @@ var SKIPPED_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
41
41
|
"svg",
|
|
42
42
|
"math"
|
|
43
43
|
]);
|
|
44
|
+
var SKIPPED_ELEMENT_SET = new Set(SKIPPED_ELEMENTS);
|
|
44
45
|
function isSkippedElement(tagName) {
|
|
45
|
-
return
|
|
46
|
+
return SKIPPED_ELEMENT_SET.has(tagName);
|
|
46
47
|
}
|
|
47
48
|
var AMPERSAND = 38;
|
|
48
49
|
var SEMICOLON = 59;
|
|
@@ -245,5 +246,6 @@ function htmlFragmentSpans(source, offset) {
|
|
|
245
246
|
|
|
246
247
|
|
|
247
248
|
|
|
248
|
-
|
|
249
|
-
|
|
249
|
+
|
|
250
|
+
exports.wrapParserErrors = wrapParserErrors; exports.SKIPPED_ELEMENTS = SKIPPED_ELEMENTS; exports.isSkippedElement = isSkippedElement; exports.htmlSpans = htmlSpans; exports.htmlFragmentSpans = htmlFragmentSpans;
|
|
251
|
+
//# sourceMappingURL=chunk-6KMUSOJL.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-6KMUSOJL.cjs","../src/modes/html.ts","../src/modes/parse-error.ts"],"names":[],"mappings":"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","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-6KMUSOJL.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 */\nexport const SKIPPED_ELEMENTS: readonly string[] = Object.freeze([\n \"code\",\n \"pre\",\n \"kbd\",\n \"samp\",\n \"var\",\n \"script\",\n \"style\",\n \"textarea\",\n \"svg\",\n \"math\",\n]);\n\nconst SKIPPED_ELEMENT_SET: ReadonlySet<string> = new Set(SKIPPED_ELEMENTS);\n\nexport function isSkippedElement(tagName: string): boolean {\n return SKIPPED_ELEMENT_SET.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\n/**\n * modes.md 3.6 (spec 1.23.0): a text node of only U+0009, U+000A, U+000C, U+000D and U+0020 that\n * holds a line break is not a span, so the gap around it carries the raw line break and 3.2\n * picks the line marker. Pretty-printed markup then reads as `text` mode reads the same lines.\n */\nfunction isLineBreakWhitespace(source: string, start: number, end: number): boolean {\n let hasLineBreak = false;\n for (let i = start; i < end; i += 1) {\n const c = source.charCodeAt(i);\n if (c === 0x0a || c === 0x0c || c === 0x0d) hasLineBreak = true;\n else if (c !== 0x09 && c !== 0x20) return false;\n }\n return hasLineBreak;\n}\n\nconst LESS_THAN = 0x3c;\nconst SOLIDUS = 0x2f;\nconst GREATER_THAN = 0x3e;\nconst EQUALS = 0x3d;\n\nfunction isAsciiAlpha(unit: number): boolean {\n return (unit >= 0x41 && unit <= 0x5a) || (unit >= 0x61 && unit <= 0x7a);\n}\n\nfunction isTagSpace(unit: number): boolean {\n return unit === 0x09 || unit === 0x0a || unit === 0x0c || unit === 0x0d || unit === 0x20;\n}\n\n/**\n * The offset just past the tag that starts at `at`, or -1 when no tag starts there. Follows the\n * HTML tokenizer: `<` plus a letter, `</` plus a letter, or `</>`. A quote opens a value only in\n * the before-attribute-value state, reached by an `=` that follows an attribute name; an `=` that\n * begins a name, or sits inside an unquoted value, is data.\n */\nfunction tagEnd(source: string, at: number, limit: number): number {\n if (source.charCodeAt(at) !== LESS_THAN) return -1;\n let i = at + 1;\n if (i >= limit) return -1;\n if (source.charCodeAt(i) === SOLIDUS) {\n i += 1;\n if (i >= limit) return -1;\n if (source.charCodeAt(i) === GREATER_THAN) return i + 1;\n }\n if (!isAsciiAlpha(source.charCodeAt(i))) return -1;\n // tag name\n while (i < limit) {\n const c = source.charCodeAt(i);\n if (isTagSpace(c) || c === SOLIDUS || c === GREATER_THAN) break;\n i += 1;\n }\n while (i < limit) {\n // before attribute name\n let c = source.charCodeAt(i);\n if (isTagSpace(c) || c === SOLIDUS) {\n i += 1;\n continue;\n }\n if (c === GREATER_THAN) return i + 1;\n // attribute name: an `=` first in the name is part of it\n i += 1;\n while (i < limit) {\n c = source.charCodeAt(i);\n if (isTagSpace(c) || c === SOLIDUS || c === GREATER_THAN || c === EQUALS) break;\n i += 1;\n }\n // after attribute name\n while (i < limit && isTagSpace(source.charCodeAt(i))) i += 1;\n if (i >= limit) return -1;\n c = source.charCodeAt(i);\n if (c === GREATER_THAN) return i + 1;\n if (c !== EQUALS) continue;\n // before attribute value\n i += 1;\n while (i < limit && isTagSpace(source.charCodeAt(i))) i += 1;\n if (i >= limit) return -1;\n c = source.charCodeAt(i);\n if (c === GREATER_THAN) return i + 1;\n if (c === 0x22 || c === 0x27) {\n const close = source.indexOf(c === 0x22 ? '\"' : \"'\", i + 1);\n if (close === -1 || close >= limit) return -1;\n i = close + 1;\n continue;\n }\n while (i < limit) {\n c = source.charCodeAt(i);\n if (isTagSpace(c) || c === GREATER_THAN) break;\n i += 1;\n }\n }\n return -1;\n}\n\n/**\n * modes.md 3.6 (spec 1.23.1): a tag the parser ignores is still a tag in the source, and parse5\n * merges the text on either side of it into one node. Splitting the run at every tag-shaped token\n * keeps the tag outside every span and puts it in the gap, where 3.2 chooses the marker.\n */\nfunction textPieces(source: string, start: number, end: number): Array<[number, number]> {\n const pieces: Array<[number, number]> = [];\n let cursor = start;\n let i = start;\n while (i < end) {\n if (source.charCodeAt(i) === LESS_THAN) {\n const stop = tagEnd(source, i, end);\n if (stop > 0) {\n if (i > cursor) pieces.push([cursor, i]);\n cursor = stop;\n i = stop;\n continue;\n }\n }\n i += 1;\n }\n if (end > cursor) pieces.push([cursor, end]);\n return pieces;\n}\n\n// Their text is character data, not markup: `<` begins no tag inside them (HTML tokenizer RCDATA,\n// RAWTEXT and PLAINTEXT states), so textPieces must not look for one.\nconst TEXT_ONLY_PARENTS = new Set([\n \"title\",\n \"xmp\",\n \"iframe\",\n \"noembed\",\n \"noframes\",\n \"noscript\",\n \"plaintext\",\n]);\n\nfunction collect(node: Node, source: string, spans: Span[], isTextOnly = false): void {\n if (node.nodeName === \"#text\") {\n const location = node.sourceCodeLocation;\n if (location === undefined || location === null) return;\n const pieces = isTextOnly\n ? ([[location.startOffset, location.endOffset]] as Array<[number, number]>)\n : textPieces(source, location.startOffset, location.endOffset);\n for (const [from, to] of pieces) {\n if (isLineBreakWhitespace(source, from, to)) continue;\n for (const span of splitCharacterReferences(source, from, to)) 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 const textOnly = \"tagName\" in node && TEXT_ONLY_PARENTS.has(node.tagName);\n for (const child of node.childNodes) collect(child, source, spans, textOnly);\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"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveYamlKeys,
|
|
3
3
|
yamlSpans
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5KKFD2HR.js";
|
|
5
5
|
import {
|
|
6
6
|
analyzeOverSpans,
|
|
7
7
|
assertNoProtect,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
planRules,
|
|
10
10
|
resolveNarrowTarget,
|
|
11
11
|
runOverSpans
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Y3POOZLN.js";
|
|
13
13
|
|
|
14
14
|
// src/engine/yaml-pipeline.ts
|
|
15
15
|
function runYamlPipeline(input, options) {
|
|
@@ -33,4 +33,4 @@ export {
|
|
|
33
33
|
runYamlPipeline,
|
|
34
34
|
analyzeYamlPipeline
|
|
35
35
|
};
|
|
36
|
-
//# sourceMappingURL=chunk-
|
|
36
|
+
//# sourceMappingURL=chunk-6NR6365G.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkZFNQ2P2Fcjs = require('./chunk-ZFNQ2P2F.cjs');
|
|
13
|
+
|
|
14
|
+
// src/engine/text-pipeline.ts
|
|
15
|
+
function runTextPipeline(input, options) {
|
|
16
|
+
const narrowTarget = _chunkZFNQ2P2Fcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
|
|
17
|
+
const planned = _chunkZFNQ2P2Fcjs.planRules.call(void 0, options.rules);
|
|
18
|
+
const locale = _chunkZFNQ2P2Fcjs.getLocaleData.call(void 0, options.locale);
|
|
19
|
+
const holes = _chunkZFNQ2P2Fcjs.resolveProtect.call(void 0, options.protect, _chunkZFNQ2P2Fcjs.toCodePoints.call(void 0, input).length);
|
|
20
|
+
if (holes.length > 0) return _chunkZFNQ2P2Fcjs.runProtected.call(void 0, input, holes, planned, locale, narrowTarget);
|
|
21
|
+
return _chunkZFNQ2P2Fcjs.fromCodePoints.call(void 0, _chunkZFNQ2P2Fcjs.runRules.call(void 0, _chunkZFNQ2P2Fcjs.toCodePoints.call(void 0, input), planned, locale, "text", narrowTarget));
|
|
22
|
+
}
|
|
23
|
+
function analyzeTextPipeline(input, options) {
|
|
24
|
+
const narrowTarget = _chunkZFNQ2P2Fcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
|
|
25
|
+
const planned = _chunkZFNQ2P2Fcjs.planRules.call(void 0, options.rules);
|
|
26
|
+
const locale = _chunkZFNQ2P2Fcjs.getLocaleData.call(void 0, options.locale);
|
|
27
|
+
const cp = _chunkZFNQ2P2Fcjs.toCodePoints.call(void 0, input);
|
|
28
|
+
const holes = _chunkZFNQ2P2Fcjs.resolveProtect.call(void 0, options.protect, cp.length);
|
|
29
|
+
if (holes.length > 0) return _chunkZFNQ2P2Fcjs.analyzeProtected.call(void 0, input, holes, planned, locale, narrowTarget);
|
|
30
|
+
const origin = cp.map((_value, index) => index);
|
|
31
|
+
return _chunkZFNQ2P2Fcjs.runRulesRecording.call(void 0, cp, planned, locale, "text", narrowTarget, origin, cp.length);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
exports.runTextPipeline = runTextPipeline; exports.analyzeTextPipeline = analyzeTextPipeline;
|
|
38
|
+
//# sourceMappingURL=chunk-6PIVYTIT.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-6PIVYTIT.cjs","../src/engine/text-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;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,MAAM,MAAA,EAAQ,8CAAA,OAAe,CAAQ,OAAA,EAAS,4CAAA,KAAkB,CAAA,CAAE,MAAM,CAAA;AACxE,EAAA,GAAA,CAAI,KAAA,CAAM,OAAA,EAAS,CAAA,EAAG,OAAO,4CAAA,KAAa,EAAO,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,YAAY,CAAA;AACrF,EAAA,OAAO,8CAAA,wCAAe,4CAAS,KAAkB,CAAA,EAAG,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,YAAY,CAAC,CAAA;AAC5F;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,MAAM,GAAA,EAAK,4CAAA,KAAkB,CAAA;AAC7B,EAAA,MAAM,MAAA,EAAQ,8CAAA,OAAe,CAAQ,OAAA,EAAS,EAAA,CAAG,MAAM,CAAA;AACvD,EAAA,GAAA,CAAI,KAAA,CAAM,OAAA,EAAS,CAAA,EAAG,OAAO,gDAAA,KAAiB,EAAO,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,YAAY,CAAA;AACzF,EAAA,MAAM,OAAA,EAAS,EAAA,CAAG,GAAA,CAAI,CAAC,MAAA,EAAQ,KAAA,EAAA,GAAU,KAAK,CAAA;AAC9C,EAAA,OAAO,iDAAA,EAAkB,EAAI,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,YAAA,EAAc,MAAA,EAAQ,EAAA,CAAG,MAAM,CAAA;AACvF;ADNA;AACA;AACE;AACA;AACF,6FAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-6PIVYTIT.cjs","sourcesContent":[null,"import type { Options } from \"../types.js\";\nimport { fromCodePoints, toCodePoints } from \"./codepoints.js\";\nimport type { Change } from \"./origin.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { resolveNarrowTarget } from \"./narrow-target.js\";\nimport { planRules, runRules, runRulesRecording } from \"./rule-runner.js\";\nimport { analyzeProtected, resolveProtect, runProtected } from \"./protect.js\";\n\n/**\n * `text` mode only. Deliberately imports nothing from `../modes/html.js` or\n * `../modes/markdown.js` (or their parser dependencies) — this is what makes `polytypo/text`'s\n * module graph exclude `parse5` and the Micromark stack (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md\n * 5.1).\n *\n * Validation order — `planRules` before `getLocaleData` — mirrors the pre-Stage-5 aggregate\n * `runPipeline` exactly (an unknown-rule error must win over an unknown-locale error when both\n * are present, since that is public, tested behaviour, not an implementation detail this\n * refactor was authorised to change).\n */\nexport function runTextPipeline(input: string, options: Partial<Options>): string {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const holes = resolveProtect(options.protect, toCodePoints(input).length);\n if (holes.length > 0) return runProtected(input, holes, planned, locale, narrowTarget);\n return fromCodePoints(runRules(toCodePoints(input), planned, locale, \"text\", narrowTarget));\n}\n\n/** analyze.md §1: the same pipeline as `runTextPipeline`, reporting instead of applying. */\nexport function analyzeTextPipeline(input: string, options: Partial<Options>): Change[] {\n const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n const planned = planRules(options.rules);\n const locale = getLocaleData(options.locale);\n const cp = toCodePoints(input);\n const holes = resolveProtect(options.protect, cp.length);\n if (holes.length > 0) return analyzeProtected(input, holes, planned, locale, narrowTarget);\n const origin = cp.map((_value, index) => index);\n return runRulesRecording(cp, planned, locale, \"text\", narrowTarget, origin, cp.length);\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkZFNQ2P2Fcjs = require('./chunk-ZFNQ2P2F.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, _chunkZFNQ2P2Fcjs.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-CNJV4SNX.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-CNJV4SNX.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-CNJV4SNX.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"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkRB7DVXKDcjs = require('./chunk-RB7DVXKD.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkZFNQ2P2Fcjs = require('./chunk-ZFNQ2P2F.cjs');
|
|
13
|
+
|
|
14
|
+
// src/engine/yaml-pipeline.ts
|
|
15
|
+
function runYamlPipeline(input, options) {
|
|
16
|
+
const narrowTarget = _chunkZFNQ2P2Fcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
|
|
17
|
+
const planned = _chunkZFNQ2P2Fcjs.planRules.call(void 0, options.rules);
|
|
18
|
+
const locale = _chunkZFNQ2P2Fcjs.getLocaleData.call(void 0, options.locale);
|
|
19
|
+
const keys = _chunkRB7DVXKDcjs.resolveYamlKeys.call(void 0, options.keys);
|
|
20
|
+
_chunkZFNQ2P2Fcjs.assertNoProtect.call(void 0, options.protect, "yaml");
|
|
21
|
+
return _chunkZFNQ2P2Fcjs.runOverSpans.call(void 0, input, _chunkRB7DVXKDcjs.yamlSpans.call(void 0, input, keys), planned, locale, "yaml", narrowTarget);
|
|
22
|
+
}
|
|
23
|
+
function analyzeYamlPipeline(input, options) {
|
|
24
|
+
const narrowTarget = _chunkZFNQ2P2Fcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
|
|
25
|
+
const planned = _chunkZFNQ2P2Fcjs.planRules.call(void 0, options.rules);
|
|
26
|
+
const locale = _chunkZFNQ2P2Fcjs.getLocaleData.call(void 0, options.locale);
|
|
27
|
+
const keys = _chunkRB7DVXKDcjs.resolveYamlKeys.call(void 0, options.keys);
|
|
28
|
+
_chunkZFNQ2P2Fcjs.assertNoProtect.call(void 0, options.protect, "yaml");
|
|
29
|
+
return _chunkZFNQ2P2Fcjs.analyzeOverSpans.call(void 0, input, _chunkRB7DVXKDcjs.yamlSpans.call(void 0, input, keys), planned, locale, "yaml", narrowTarget);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
exports.runYamlPipeline = runYamlPipeline; exports.analyzeYamlPipeline = analyzeYamlPipeline;
|
|
36
|
+
//# sourceMappingURL=chunk-EBIS5RQW.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-EBIS5RQW.cjs","../src/engine/yaml-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACIO,SAAS,eAAA,CAAgB,KAAA,EAAe,OAAA,EAAmC;AAChF,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,EAAA,MAAM,QAAA,EAAU,yCAAA,OAAU,CAAQ,KAAK,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,6CAAA,OAAc,CAAQ,MAAM,CAAA;AAC3C,EAAA,MAAM,KAAA,EAAO,+CAAA,OAAgB,CAAQ,IAAI,CAAA;AACzC,EAAA,+CAAA,OAAgB,CAAQ,OAAA,EAAS,MAAM,CAAA;AACvC,EAAA,OAAO,4CAAA,KAAa,EAAO,yCAAA,KAAU,EAAO,IAAI,CAAA,EAAG,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,YAAY,CAAA;AAC1F;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,MAAM,KAAA,EAAO,+CAAA,OAAgB,CAAQ,IAAI,CAAA;AACzC,EAAA,+CAAA,OAAgB,CAAQ,OAAA,EAAS,MAAM,CAAA;AACvC,EAAA,OAAO,gDAAA,KAAiB,EAAO,yCAAA,KAAU,EAAO,IAAI,CAAA,EAAG,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,YAAY,CAAA;AAC9F;ADJA;AACA;AACE;AACA;AACF,6FAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-EBIS5RQW.cjs","sourcesContent":[null,"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 { 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 * `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 assertNoProtect(options.protect, \"yaml\");\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 assertNoProtect(options.protect, \"yaml\");\n return analyzeOverSpans(input, yamlSpans(input, keys), planned, locale, \"yaml\", narrowTarget);\n}\n"]}
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
htmlFragmentSpans,
|
|
3
3
|
isSkippedElement,
|
|
4
4
|
wrapParserErrors
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZDTUYVAT.js";
|
|
6
6
|
import {
|
|
7
7
|
resolveFrontmatterKeys,
|
|
8
8
|
yamlSpans
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-5KKFD2HR.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-Y3POOZLN.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-GGUNL3P6.js.map
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunk6KMUSOJLcjs = require('./chunk-6KMUSOJL.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkRB7DVXKDcjs = require('./chunk-RB7DVXKD.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ var _chunk5NTTJKWNcjs = require('./chunk-5NTTJKWN.cjs');
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunkZFNQ2P2Fcjs = require('./chunk-ZFNQ2P2F.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 && _chunk6KMUSOJLcjs.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, _chunkZFNQ2P2Fcjs.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, _chunkZFNQ2P2Fcjs.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 = _chunk6KMUSOJLcjs.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 _chunk6KMUSOJLcjs.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
|
+
_chunkZFNQ2P2Fcjs.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 _chunkRB7DVXKDcjs.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 = _chunkZFNQ2P2Fcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
|
|
363
|
+
const planned = _chunkZFNQ2P2Fcjs.planRules.call(void 0, options.rules);
|
|
364
|
+
const locale = _chunkZFNQ2P2Fcjs.getLocaleData.call(void 0, options.locale);
|
|
365
365
|
const dialect = resolveDialect(options.dialect);
|
|
366
|
-
const frontmatterKeys =
|
|
367
|
-
|
|
366
|
+
const frontmatterKeys = _chunkRB7DVXKDcjs.resolveFrontmatterKeys.call(void 0, options.frontmatterKeys);
|
|
367
|
+
_chunkZFNQ2P2Fcjs.assertNoProtect.call(void 0, options.protect, "markdown");
|
|
368
368
|
const units = unitsOf(input, dialect, frontmatterKeys);
|
|
369
|
-
return
|
|
369
|
+
return _chunkZFNQ2P2Fcjs.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 = _chunkZFNQ2P2Fcjs.resolveNarrowTarget.call(void 0, options.narrowNbsp);
|
|
378
|
+
const planned = _chunkZFNQ2P2Fcjs.planRules.call(void 0, options.rules);
|
|
379
|
+
const locale = _chunkZFNQ2P2Fcjs.getLocaleData.call(void 0, options.locale);
|
|
380
380
|
const dialect = resolveDialect(options.dialect);
|
|
381
|
-
const frontmatterKeys =
|
|
382
|
-
|
|
383
|
-
return
|
|
381
|
+
const frontmatterKeys = _chunkRB7DVXKDcjs.resolveFrontmatterKeys.call(void 0, options.frontmatterKeys);
|
|
382
|
+
_chunkZFNQ2P2Fcjs.assertNoProtect.call(void 0, options.protect, "markdown");
|
|
383
|
+
return _chunkZFNQ2P2Fcjs.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-LLPHSREU.cjs.map
|