polytypo 1.3.1 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-THTCAO3O.cjs → chunk-3ONFVTKE.cjs} +4 -4
- package/dist/{chunk-THTCAO3O.cjs.map → chunk-3ONFVTKE.cjs.map} +1 -1
- package/dist/{chunk-5NCJ3Y65.js → chunk-4CONSHBE.js} +4 -4
- package/dist/{chunk-UBEV2AC3.js → chunk-5VQSIDY6.js} +3 -3
- package/dist/{chunk-DXWMSR26.js → chunk-6QL6N5G5.js} +2 -2
- package/dist/chunk-BF7NY7GO.js +5828 -0
- package/dist/chunk-BF7NY7GO.js.map +1 -0
- package/dist/{chunk-W2T7B2SH.cjs → chunk-EAHREH2D.cjs} +3 -3
- package/dist/{chunk-W2T7B2SH.cjs.map → chunk-EAHREH2D.cjs.map} +1 -1
- package/dist/{chunk-5VNPHCL2.cjs → chunk-FPHGXDAR.cjs} +13 -13
- package/dist/{chunk-5VNPHCL2.cjs.map → chunk-FPHGXDAR.cjs.map} +1 -1
- package/dist/chunk-HHMITBTB.cjs +33 -0
- package/dist/{chunk-FK3F3YZT.cjs.map → chunk-HHMITBTB.cjs.map} +1 -1
- package/dist/{chunk-ECYUONLP.cjs → chunk-K4ZF3RDH.cjs} +16 -16
- package/dist/{chunk-ECYUONLP.cjs.map → chunk-K4ZF3RDH.cjs.map} +1 -1
- package/dist/chunk-K5CSTJE2.cjs +31 -0
- package/dist/{chunk-QNSBCZU5.cjs.map → chunk-K5CSTJE2.cjs.map} +1 -1
- package/dist/chunk-NEUH35JH.cjs +5828 -0
- package/dist/chunk-NEUH35JH.cjs.map +1 -0
- package/dist/{chunk-AR6FDQAX.cjs → chunk-NFFM6OBH.cjs} +17 -17
- package/dist/{chunk-AR6FDQAX.cjs.map → chunk-NFFM6OBH.cjs.map} +1 -1
- package/dist/{chunk-B7WXSXRG.js → chunk-OPGIEVOR.js} +2 -2
- package/dist/{chunk-5U3DRTV7.js → chunk-Q5XENI33.js} +2 -2
- package/dist/{chunk-VC5XLP6O.js → chunk-RJGBWBR4.js} +4 -4
- package/dist/{chunk-4GYU4TXA.js → chunk-YGI76J7W.js} +2 -2
- package/dist/{errors-CGFOVO3h.d.cts → errors-C1_sHGgx.d.cts} +28 -1
- package/dist/{errors-CGFOVO3h.d.ts → errors-C1_sHGgx.d.ts} +28 -1
- package/dist/html.cjs +10 -10
- package/dist/html.d.cts +2 -2
- package/dist/html.d.ts +2 -2
- package/dist/html.js +5 -5
- package/dist/index.cjs +17 -17
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- package/dist/markdown.cjs +10 -10
- package/dist/markdown.d.cts +2 -2
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +5 -5
- package/dist/text.cjs +8 -8
- package/dist/text.d.cts +2 -2
- package/dist/text.d.ts +2 -2
- package/dist/text.js +3 -3
- package/dist/yaml.cjs +9 -9
- package/dist/yaml.d.cts +2 -2
- package/dist/yaml.d.ts +2 -2
- package/dist/yaml.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-FK3F3YZT.cjs +0 -33
- package/dist/chunk-QNSBCZU5.cjs +0 -31
- package/dist/chunk-V4EOJ44S.cjs +0 -5778
- package/dist/chunk-V4EOJ44S.cjs.map +0 -1
- package/dist/chunk-VKJVMMCI.js +0 -5778
- package/dist/chunk-VKJVMMCI.js.map +0 -1
- /package/dist/{chunk-5NCJ3Y65.js.map → chunk-4CONSHBE.js.map} +0 -0
- /package/dist/{chunk-UBEV2AC3.js.map → chunk-5VQSIDY6.js.map} +0 -0
- /package/dist/{chunk-DXWMSR26.js.map → chunk-6QL6N5G5.js.map} +0 -0
- /package/dist/{chunk-B7WXSXRG.js.map → chunk-OPGIEVOR.js.map} +0 -0
- /package/dist/{chunk-5U3DRTV7.js.map → chunk-Q5XENI33.js.map} +0 -0
- /package/dist/{chunk-VC5XLP6O.js.map → chunk-RJGBWBR4.js.map} +0 -0
- /package/dist/{chunk-4GYU4TXA.js.map → chunk-YGI76J7W.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkNEUH35JHcjs = require('./chunk-NEUH35JH.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 _chunkNEUH35JHcjs.PolytypoError) throw error;
|
|
24
|
+
throw new (0, _chunkNEUH35JHcjs.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-3ONFVTKE.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-3ONFVTKE.cjs","../src/modes/html.ts","../src/modes/parse-error.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,gCAAqC;ADMrC;AACA;AEAA,SAAS,QAAA,CAAS,KAAA,EAAwB;AACxC,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU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F,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-3ONFVTKE.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"]}
|
|
@@ -2,17 +2,17 @@ import {
|
|
|
2
2
|
htmlFragmentSpans,
|
|
3
3
|
isSkippedElement,
|
|
4
4
|
wrapParserErrors
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-6QL6N5G5.js";
|
|
6
6
|
import {
|
|
7
7
|
analyzeOverSpans,
|
|
8
8
|
runOverSpans
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-Q5XENI33.js";
|
|
10
10
|
import {
|
|
11
11
|
PolytypoError,
|
|
12
12
|
getLocaleData,
|
|
13
13
|
planRules,
|
|
14
14
|
resolveNarrowTarget
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-BF7NY7GO.js";
|
|
16
16
|
|
|
17
17
|
// src/modes/markdown.ts
|
|
18
18
|
import { parse, postprocess, preprocess } from "micromark";
|
|
@@ -184,4 +184,4 @@ export {
|
|
|
184
184
|
runMarkdownPipeline,
|
|
185
185
|
analyzeMarkdownPipeline
|
|
186
186
|
};
|
|
187
|
-
//# sourceMappingURL=chunk-
|
|
187
|
+
//# sourceMappingURL=chunk-4CONSHBE.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
analyzeOverSpans,
|
|
3
3
|
runOverSpans
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-Q5XENI33.js";
|
|
5
5
|
import {
|
|
6
6
|
PolytypoError,
|
|
7
7
|
getLocaleData,
|
|
8
8
|
planRules,
|
|
9
9
|
resolveNarrowTarget
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-BF7NY7GO.js";
|
|
11
11
|
|
|
12
12
|
// src/modes/yaml.ts
|
|
13
13
|
var TAB = 9;
|
|
@@ -261,4 +261,4 @@ export {
|
|
|
261
261
|
runYamlPipeline,
|
|
262
262
|
analyzeYamlPipeline
|
|
263
263
|
};
|
|
264
|
-
//# sourceMappingURL=chunk-
|
|
264
|
+
//# sourceMappingURL=chunk-5VQSIDY6.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PolytypoError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BF7NY7GO.js";
|
|
4
4
|
|
|
5
5
|
// src/modes/html.ts
|
|
6
6
|
import { parse, parseFragment } from "parse5";
|
|
@@ -144,4 +144,4 @@ export {
|
|
|
144
144
|
htmlSpans,
|
|
145
145
|
htmlFragmentSpans
|
|
146
146
|
};
|
|
147
|
-
//# sourceMappingURL=chunk-
|
|
147
|
+
//# sourceMappingURL=chunk-6QL6N5G5.js.map
|