@aftertext/compiler 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +38 -2
- package/dist/ast/expression.d.ts +55 -0
- package/dist/ast/expression.d.ts.map +1 -0
- package/dist/ast/expression.js +2 -0
- package/dist/ast/expression.js.map +1 -0
- package/dist/ast/index.d.ts +6 -0
- package/dist/ast/index.d.ts.map +1 -0
- package/dist/ast/index.js +2 -0
- package/dist/ast/index.js.map +1 -0
- package/dist/ast/inline.d.ts +39 -0
- package/dist/ast/inline.d.ts.map +1 -0
- package/dist/ast/inline.js +2 -0
- package/dist/ast/inline.js.map +1 -0
- package/dist/ast/presentation.d.ts +41 -0
- package/dist/ast/presentation.d.ts.map +1 -0
- package/dist/ast/presentation.js +8 -0
- package/dist/ast/presentation.js.map +1 -0
- package/dist/ast/span.d.ts +19 -0
- package/dist/ast/span.d.ts.map +1 -0
- package/dist/ast/span.js +2 -0
- package/dist/ast/span.js.map +1 -0
- package/dist/ast/story.d.ts +350 -0
- package/dist/ast/story.d.ts.map +1 -0
- package/dist/ast/story.js +2 -0
- package/dist/ast/story.js.map +1 -0
- package/dist/compile.d.ts +25 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +19 -0
- package/dist/compile.js.map +1 -0
- package/dist/diagnostics/codes.d.ts +25 -0
- package/dist/diagnostics/codes.d.ts.map +1 -0
- package/dist/diagnostics/codes.js +66 -0
- package/dist/diagnostics/codes.js.map +1 -0
- package/dist/diagnostics/index.d.ts +3 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +2 -0
- package/dist/diagnostics/index.js.map +1 -0
- package/dist/diagnostics/types.d.ts +19 -0
- package/dist/diagnostics/types.d.ts.map +1 -0
- package/dist/diagnostics/types.js +2 -0
- package/dist/diagnostics/types.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/blocks.d.ts +40 -0
- package/dist/parser/blocks.d.ts.map +1 -0
- package/dist/parser/blocks.js +907 -0
- package/dist/parser/blocks.js.map +1 -0
- package/dist/parser/directive-line.d.ts +21 -0
- package/dist/parser/directive-line.d.ts.map +1 -0
- package/dist/parser/directive-line.js +50 -0
- package/dist/parser/directive-line.js.map +1 -0
- package/dist/parser/document.d.ts +13 -0
- package/dist/parser/document.d.ts.map +1 -0
- package/dist/parser/document.js +28 -0
- package/dist/parser/document.js.map +1 -0
- package/dist/parser/expression-lexer.d.ts +26 -0
- package/dist/parser/expression-lexer.d.ts.map +1 -0
- package/dist/parser/expression-lexer.js +137 -0
- package/dist/parser/expression-lexer.js.map +1 -0
- package/dist/parser/expression-parser.d.ts +13 -0
- package/dist/parser/expression-parser.d.ts.map +1 -0
- package/dist/parser/expression-parser.js +201 -0
- package/dist/parser/expression-parser.js.map +1 -0
- package/dist/parser/frontmatter.d.ts +23 -0
- package/dist/parser/frontmatter.d.ts.map +1 -0
- package/dist/parser/frontmatter.js +118 -0
- package/dist/parser/frontmatter.js.map +1 -0
- package/dist/parser/index.d.ts +2 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +2 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/lexical-primitives.d.ts +38 -0
- package/dist/parser/lexical-primitives.d.ts.map +1 -0
- package/dist/parser/lexical-primitives.js +46 -0
- package/dist/parser/lexical-primitives.js.map +1 -0
- package/dist/parser/lines.d.ts +32 -0
- package/dist/parser/lines.d.ts.map +1 -0
- package/dist/parser/lines.js +60 -0
- package/dist/parser/lines.js.map +1 -0
- package/dist/parser/markdown.d.ts +19 -0
- package/dist/parser/markdown.d.ts.map +1 -0
- package/dist/parser/markdown.js +221 -0
- package/dist/parser/markdown.js.map +1 -0
- package/dist/parser/serializer-safety.d.ts +56 -0
- package/dist/parser/serializer-safety.d.ts.map +1 -0
- package/dist/parser/serializer-safety.js +65 -0
- package/dist/parser/serializer-safety.js.map +1 -0
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +2 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/validate.d.ts +4 -0
- package/dist/validation/validate.d.ts.map +1 -0
- package/dist/validation/validate.js +221 -0
- package/dist/validation/validate.js.map +1 -0
- package/package.json +43 -4
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { isMap, isScalar, LineCounter, parseDocument } from "yaml";
|
|
2
|
+
import { Diagnostics } from "../diagnostics/codes.js";
|
|
3
|
+
import { joinLineText, lineEnd, lineStart, splitLines } from "./lines.js";
|
|
4
|
+
const DELIMITER = "---";
|
|
5
|
+
/** A YAML scalar resolving to one of v0.1's allowed initial-state value types. */
|
|
6
|
+
function isAllowedScalarNode(node) {
|
|
7
|
+
if (!node || !isScalar(node))
|
|
8
|
+
return false;
|
|
9
|
+
const value = node.value;
|
|
10
|
+
return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
11
|
+
}
|
|
12
|
+
function keyName(key) {
|
|
13
|
+
return isScalar(key) ? String(key.value) : String(key);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Extracts and parses a leading `--- ... ---` YAML frontmatter block, if
|
|
17
|
+
* present, normalizing it into a StoryMetadata plus a first-class initial
|
|
18
|
+
* state map. Unsupported state values (arrays, nested objects, YAML
|
|
19
|
+
* timestamps/binary/aliases, ...) are reported as AT1201 diagnostics and
|
|
20
|
+
* dropped from the state map rather than throwing. If the YAML itself has
|
|
21
|
+
* syntax errors, only AT1202 is reported for `state:` — semantic
|
|
22
|
+
* validation of its (possibly parser-recovered, unreliable) contents is
|
|
23
|
+
* skipped to avoid a misleading AT1201 cascade. Returns the remaining
|
|
24
|
+
* body lines (frontmatter stripped) for the block parser to consume.
|
|
25
|
+
*/
|
|
26
|
+
export function extractFrontmatter(source) {
|
|
27
|
+
const lines = splitLines(source);
|
|
28
|
+
const diagnostics = [];
|
|
29
|
+
const emptyMetadata = { title: undefined, entry: undefined, span: undefined };
|
|
30
|
+
const empty = { metadata: emptyMetadata, initialState: {}, bodyLines: lines, diagnostics };
|
|
31
|
+
if (lines.length === 0 || lines[0].text.trim() !== DELIMITER) {
|
|
32
|
+
return empty;
|
|
33
|
+
}
|
|
34
|
+
let closingIndex = -1;
|
|
35
|
+
for (let i = 1; i < lines.length; i++) {
|
|
36
|
+
if (lines[i].text.trim() === DELIMITER) {
|
|
37
|
+
closingIndex = i;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (closingIndex === -1) {
|
|
42
|
+
// No closing delimiter: treat the whole thing as body (best-effort recovery).
|
|
43
|
+
return empty;
|
|
44
|
+
}
|
|
45
|
+
const openLine = lines[0];
|
|
46
|
+
const closeLine = lines[closingIndex];
|
|
47
|
+
const yamlLines = lines.slice(1, closingIndex);
|
|
48
|
+
const yamlText = joinLineText(yamlLines);
|
|
49
|
+
const span = { start: lineStart(openLine), end: lineEnd(closeLine) };
|
|
50
|
+
const bodyLines = lines.slice(closingIndex + 1);
|
|
51
|
+
const anchorLine = yamlLines.length > 0 ? yamlLines[0].number : openLine.number + 1;
|
|
52
|
+
const anchorOffset = yamlLines.length > 0 ? yamlLines[0].startOffset : closeLine.startOffset;
|
|
53
|
+
const lineCounter = new LineCounter();
|
|
54
|
+
const doc = parseDocument(yamlText, { lineCounter, prettyErrors: false });
|
|
55
|
+
function positionAt(offset) {
|
|
56
|
+
const local = lineCounter.linePos(offset);
|
|
57
|
+
return { line: anchorLine + (local.line - 1), column: local.col, offset: anchorOffset + offset };
|
|
58
|
+
}
|
|
59
|
+
function spanOfNode(node) {
|
|
60
|
+
const range = node.range;
|
|
61
|
+
if (!range) {
|
|
62
|
+
const fallback = positionAt(0);
|
|
63
|
+
return { start: fallback, end: fallback };
|
|
64
|
+
}
|
|
65
|
+
return { start: positionAt(range[0]), end: positionAt(range[1]) };
|
|
66
|
+
}
|
|
67
|
+
// YAML syntax errors (e.g. an unclosed flow sequence) don't throw — the
|
|
68
|
+
// `yaml` package collects them here and still returns a best-effort,
|
|
69
|
+
// partially-resolved document. Surface each as an AT1202 diagnostic
|
|
70
|
+
// rather than silently continuing on possibly-broken content.
|
|
71
|
+
const hasYamlSyntaxErrors = doc.errors.length > 0;
|
|
72
|
+
for (const error of doc.errors) {
|
|
73
|
+
const errorSpan = { start: positionAt(error.pos[0]), end: positionAt(error.pos[1]) };
|
|
74
|
+
diagnostics.push(Diagnostics.invalidFrontmatter(error.message, errorSpan));
|
|
75
|
+
}
|
|
76
|
+
let title;
|
|
77
|
+
let entry;
|
|
78
|
+
const state = {};
|
|
79
|
+
if (isMap(doc.contents)) {
|
|
80
|
+
for (const pair of doc.contents.items) {
|
|
81
|
+
const key = keyName(pair.key);
|
|
82
|
+
const value = pair.value;
|
|
83
|
+
if (key === "title" && isAllowedScalarNode(value) && typeof value.value === "string") {
|
|
84
|
+
title = value.value;
|
|
85
|
+
}
|
|
86
|
+
else if (key === "entry" && isAllowedScalarNode(value) && typeof value.value === "string") {
|
|
87
|
+
entry = value.value;
|
|
88
|
+
}
|
|
89
|
+
else if (key === "state" && !hasYamlSyntaxErrors) {
|
|
90
|
+
// Skip semantic validation of `state:` entirely when the YAML
|
|
91
|
+
// itself failed to parse cleanly — the tree the parser recovers
|
|
92
|
+
// around a syntax error doesn't reflect the author's intent, and
|
|
93
|
+
// validating it would only produce misleading AT1201 diagnostics
|
|
94
|
+
// cascading from the real AT1202 syntax error.
|
|
95
|
+
if (value && isMap(value)) {
|
|
96
|
+
for (const statePair of value.items) {
|
|
97
|
+
const stateKey = keyName(statePair.key);
|
|
98
|
+
const stateValue = statePair.value;
|
|
99
|
+
if (isAllowedScalarNode(stateValue)) {
|
|
100
|
+
state[stateKey] = stateValue.value;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
diagnostics.push(Diagnostics.unsupportedStateValue(stateKey, spanOfNode(stateValue ?? value)));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (value && !(isScalar(value) && value.value === null)) {
|
|
108
|
+
// `state:` with no value at all resolves to a null scalar — treated
|
|
109
|
+
// as "no initial state", not a malformed declaration.
|
|
110
|
+
diagnostics.push(Diagnostics.unsupportedStateValue("state", spanOfNode(value)));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const metadata = { title, entry, span };
|
|
116
|
+
return { metadata, initialState: state, bodyLines, diagnostics };
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/parser/frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAInE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAmB,MAAM,YAAY,CAAC;AAU3F,MAAM,SAAS,GAAG,KAAK,CAAC;AAExB,kFAAkF;AAClF,SAAS,mBAAmB,CAAC,IAA6B;IACxD,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC;IAClC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,CAAC;AAChH,CAAC;AAED,SAAS,OAAO,CAAC,GAAY;IAC3B,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,C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EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure, dependency-free lexical facts shared between the block parser
|
|
3
|
+
* (`blocks.ts`) and the public serializer-safety predicates
|
|
4
|
+
* (`serializer-safety.ts`, docs/PROJECT_SPEC.md Section 25.40's "Serializer
|
|
5
|
+
* Injection Safety Amendment"). Deliberately has zero imports — in
|
|
6
|
+
* particular, no `remark`/`mdast` dependency — so it can be safely reached
|
|
7
|
+
* from the public compiler surface (`src/index.ts`) without pulling in
|
|
8
|
+
* anything `parseProseChunk`/`markdown.ts` needs.
|
|
9
|
+
*
|
|
10
|
+
* `blocks.ts` and `serializer-safety.ts` both import these two facts from
|
|
11
|
+
* here rather than each defining/scanning for them independently, so the
|
|
12
|
+
* parser's actual tokenization behavior and the Editor-facing boundary-
|
|
13
|
+
* safety predicates cannot silently drift apart.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The exact separator-whitespace definition Presentation argument
|
|
17
|
+
* tokenization (`tokenizePresentationArgs`) and Choice tail parsing
|
|
18
|
+
* (`CHOICE_TAIL_PATTERN`'s `if`-separator) both use to recognize a token
|
|
19
|
+
* boundary — expressed as raw regex source so it can be interpolated into a
|
|
20
|
+
* larger composite pattern (`CHOICE_TAIL_PATTERN`) as well as used directly
|
|
21
|
+
* via `SEPARATOR_WHITESPACE_PATTERN`. Keeping one source string, rather than
|
|
22
|
+
* a hardcoded `\s` duplicated at each use site, is what makes it a true
|
|
23
|
+
* single source of truth — a `RegExp` object alone cannot be spliced into
|
|
24
|
+
* another pattern's literal source.
|
|
25
|
+
*/
|
|
26
|
+
export declare const SEPARATOR_WHITESPACE_SOURCE: string;
|
|
27
|
+
/** The exact separator-whitespace definition Presentation argument tokenization (`tokenizePresentationArgs`) and Choice tail parsing both use to recognize a token boundary. */
|
|
28
|
+
export declare const SEPARATOR_WHITESPACE_PATTERN: RegExp;
|
|
29
|
+
/**
|
|
30
|
+
* Finds the last `->` in `text` that isn't escaped as `\->`, scanning left
|
|
31
|
+
* to right so an escaped arrow inside display text (`A \-> B`) is skipped
|
|
32
|
+
* and only a real, unescaped arrow can act as the Choice item delimiter.
|
|
33
|
+
* Using the *last* unescaped arrow (rather than the first) means display
|
|
34
|
+
* text is free to contain its own literal `->` via escaping without
|
|
35
|
+
* confusing the split. Returns -1 if no unescaped arrow exists.
|
|
36
|
+
*/
|
|
37
|
+
export declare function findLastUnescapedArrow(text: string): number;
|
|
38
|
+
//# sourceMappingURL=lexical-primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexical-primitives.d.ts","sourceRoot":"","sources":["../../src/parser/lexical-primitives.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,QAAiB,CAAC;AAE1D,gLAAgL;AAChL,eAAO,MAAM,4BAA4B,QAA0C,CAAC;AAEpF;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ3D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure, dependency-free lexical facts shared between the block parser
|
|
3
|
+
* (`blocks.ts`) and the public serializer-safety predicates
|
|
4
|
+
* (`serializer-safety.ts`, docs/PROJECT_SPEC.md Section 25.40's "Serializer
|
|
5
|
+
* Injection Safety Amendment"). Deliberately has zero imports — in
|
|
6
|
+
* particular, no `remark`/`mdast` dependency — so it can be safely reached
|
|
7
|
+
* from the public compiler surface (`src/index.ts`) without pulling in
|
|
8
|
+
* anything `parseProseChunk`/`markdown.ts` needs.
|
|
9
|
+
*
|
|
10
|
+
* `blocks.ts` and `serializer-safety.ts` both import these two facts from
|
|
11
|
+
* here rather than each defining/scanning for them independently, so the
|
|
12
|
+
* parser's actual tokenization behavior and the Editor-facing boundary-
|
|
13
|
+
* safety predicates cannot silently drift apart.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The exact separator-whitespace definition Presentation argument
|
|
17
|
+
* tokenization (`tokenizePresentationArgs`) and Choice tail parsing
|
|
18
|
+
* (`CHOICE_TAIL_PATTERN`'s `if`-separator) both use to recognize a token
|
|
19
|
+
* boundary — expressed as raw regex source so it can be interpolated into a
|
|
20
|
+
* larger composite pattern (`CHOICE_TAIL_PATTERN`) as well as used directly
|
|
21
|
+
* via `SEPARATOR_WHITESPACE_PATTERN`. Keeping one source string, rather than
|
|
22
|
+
* a hardcoded `\s` duplicated at each use site, is what makes it a true
|
|
23
|
+
* single source of truth — a `RegExp` object alone cannot be spliced into
|
|
24
|
+
* another pattern's literal source.
|
|
25
|
+
*/
|
|
26
|
+
export const SEPARATOR_WHITESPACE_SOURCE = String.raw `\s`;
|
|
27
|
+
/** The exact separator-whitespace definition Presentation argument tokenization (`tokenizePresentationArgs`) and Choice tail parsing both use to recognize a token boundary. */
|
|
28
|
+
export const SEPARATOR_WHITESPACE_PATTERN = new RegExp(SEPARATOR_WHITESPACE_SOURCE);
|
|
29
|
+
/**
|
|
30
|
+
* Finds the last `->` in `text` that isn't escaped as `\->`, scanning left
|
|
31
|
+
* to right so an escaped arrow inside display text (`A \-> B`) is skipped
|
|
32
|
+
* and only a real, unescaped arrow can act as the Choice item delimiter.
|
|
33
|
+
* Using the *last* unescaped arrow (rather than the first) means display
|
|
34
|
+
* text is free to contain its own literal `->` via escaping without
|
|
35
|
+
* confusing the split. Returns -1 if no unescaped arrow exists.
|
|
36
|
+
*/
|
|
37
|
+
export function findLastUnescapedArrow(text) {
|
|
38
|
+
let lastIndex = -1;
|
|
39
|
+
for (let i = 0; i < text.length - 1; i++) {
|
|
40
|
+
if (text[i] === "-" && text[i + 1] === ">" && text[i - 1] !== "\\") {
|
|
41
|
+
lastIndex = i;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return lastIndex;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=lexical-primitives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexical-primitives.js","sourceRoot":"","sources":["../../src/parser/lexical-primitives.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,GAAG,CAAA,IAAI,CAAC;AAE1D,gLAAgL;AAChL,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAEpF;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACnE,SAAS,GAAG,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SourcePosition } from "../ast/span.js";
|
|
2
|
+
/** One physical line of source, with its absolute offsets in the full source string. */
|
|
3
|
+
export interface SourceLine {
|
|
4
|
+
/** 1-based line number. */
|
|
5
|
+
readonly number: number;
|
|
6
|
+
/** Offset of the first character of this line (before any trailing \r\n stripping). */
|
|
7
|
+
readonly startOffset: number;
|
|
8
|
+
/** Offset just past the last content character, excluding the line terminator. */
|
|
9
|
+
readonly endOffset: number;
|
|
10
|
+
/** Line text with any trailing \r\n / \n stripped. */
|
|
11
|
+
readonly text: string;
|
|
12
|
+
/** Length of the line terminator that followed this line: 0, 1 (\n) or 2 (\r\n). */
|
|
13
|
+
readonly newlineLength: 0 | 1 | 2;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Splits source into lines while tracking absolute offsets, so downstream
|
|
17
|
+
* AST nodes can carry accurate SourceSpans back into the original text.
|
|
18
|
+
*/
|
|
19
|
+
export declare function splitLines(source: string): SourceLine[];
|
|
20
|
+
/** The position of the start of a line (column 1). */
|
|
21
|
+
export declare function lineStart(line: SourceLine): SourcePosition;
|
|
22
|
+
/** The position just past the end of a line's content. */
|
|
23
|
+
export declare function lineEnd(line: SourceLine): SourcePosition;
|
|
24
|
+
/**
|
|
25
|
+
* Reconstructs the exact original source text spanned by a contiguous run
|
|
26
|
+
* of lines (including original line terminators), so it can be re-parsed
|
|
27
|
+
* (e.g. by remark) with offsets that stay in lockstep with the full source.
|
|
28
|
+
*/
|
|
29
|
+
export declare function joinLineText(lines: readonly SourceLine[]): string;
|
|
30
|
+
/** Position of a given 0-based character index within a line's text. */
|
|
31
|
+
export declare function positionAt(line: SourceLine, charIndex: number): SourcePosition;
|
|
32
|
+
//# sourceMappingURL=lines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lines.d.ts","sourceRoot":"","sources":["../../src/parser/lines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,wFAAwF;AACxF,MAAM,WAAW,UAAU;IACzB,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uFAAuF;IACvF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,kFAAkF;IAClF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,QAAQ,CAAC,aAAa,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE,CA0BvD;AAED,sDAAsD;AACtD,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,CAE1D;AAED,0DAA0D;AAC1D,wBAAgB,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,CAMxD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,MAAM,CAIjE;AAED,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,cAAc,CAM9E"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits source into lines while tracking absolute offsets, so downstream
|
|
3
|
+
* AST nodes can carry accurate SourceSpans back into the original text.
|
|
4
|
+
*/
|
|
5
|
+
export function splitLines(source) {
|
|
6
|
+
const lines = [];
|
|
7
|
+
let start = 0;
|
|
8
|
+
let lineNumber = 1;
|
|
9
|
+
for (let i = 0; i <= source.length; i++) {
|
|
10
|
+
if (i === source.length || source[i] === "\n") {
|
|
11
|
+
let end = i;
|
|
12
|
+
let newlineLength = i === source.length ? 0 : 1;
|
|
13
|
+
if (end > start && source[end - 1] === "\r") {
|
|
14
|
+
end -= 1;
|
|
15
|
+
newlineLength = 2;
|
|
16
|
+
}
|
|
17
|
+
lines.push({
|
|
18
|
+
number: lineNumber,
|
|
19
|
+
startOffset: start,
|
|
20
|
+
endOffset: end,
|
|
21
|
+
text: source.slice(start, end),
|
|
22
|
+
newlineLength
|
|
23
|
+
});
|
|
24
|
+
lineNumber += 1;
|
|
25
|
+
start = i + 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return lines;
|
|
29
|
+
}
|
|
30
|
+
/** The position of the start of a line (column 1). */
|
|
31
|
+
export function lineStart(line) {
|
|
32
|
+
return { line: line.number, column: 1, offset: line.startOffset };
|
|
33
|
+
}
|
|
34
|
+
/** The position just past the end of a line's content. */
|
|
35
|
+
export function lineEnd(line) {
|
|
36
|
+
return {
|
|
37
|
+
line: line.number,
|
|
38
|
+
column: line.endOffset - line.startOffset + 1,
|
|
39
|
+
offset: line.endOffset
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reconstructs the exact original source text spanned by a contiguous run
|
|
44
|
+
* of lines (including original line terminators), so it can be re-parsed
|
|
45
|
+
* (e.g. by remark) with offsets that stay in lockstep with the full source.
|
|
46
|
+
*/
|
|
47
|
+
export function joinLineText(lines) {
|
|
48
|
+
return lines
|
|
49
|
+
.map((line) => line.text + (line.newlineLength === 2 ? "\r\n" : line.newlineLength === 1 ? "\n" : ""))
|
|
50
|
+
.join("");
|
|
51
|
+
}
|
|
52
|
+
/** Position of a given 0-based character index within a line's text. */
|
|
53
|
+
export function positionAt(line, charIndex) {
|
|
54
|
+
return {
|
|
55
|
+
line: line.number,
|
|
56
|
+
column: charIndex + 1,
|
|
57
|
+
offset: line.startOffset + charIndex
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=lines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lines.js","sourceRoot":"","sources":["../../src/parser/lines.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,MAAM,KAAK,GAAiB,EAAE,CAAC;IAC/B,IAAI,KAA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AAC,WAAW,GAAG,CAAC;QAC7C,MAAM,EAAE,IAAI,CAAC,SAAS;KACvB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAA4B;IACvD,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,aAAa,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SACrG,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,UAAU,CAAC,IAAgB,EAAE,SAAiB;IAC5D,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,MAAM;QACjB,MAAM,EAAE,SAAS,GAAG,CAAC;QACrB,MAAM,EAAE,IAAI,CAAC,WAAW,GAAG,SAAS;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StoryBlock } from "../ast/story.js";
|
|
2
|
+
import type { Diagnostic } from "../diagnostics/types.js";
|
|
3
|
+
interface ChunkAnchor {
|
|
4
|
+
/** 1-based line number of the chunk's first line in the full document. */
|
|
5
|
+
readonly startLine: number;
|
|
6
|
+
/** Absolute character offset of the chunk's first character in the full document. */
|
|
7
|
+
readonly startOffset: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Parses a contiguous run of prose source text (already known to contain no
|
|
11
|
+
* AfterText directives) as Markdown, converting the result into
|
|
12
|
+
* AfterText-owned StoryBlock nodes anchored back to the full document via
|
|
13
|
+
* `anchor`. Constructs outside v0.1's supported subset (lists, blockquotes,
|
|
14
|
+
* images, code blocks, ...) still fall back to flattened plain text, but
|
|
15
|
+
* emit an AT3001 warning rather than changing document meaning silently.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseProseChunk(text: string, anchor: ChunkAnchor, diagnostics: Diagnostic[]): StoryBlock[];
|
|
18
|
+
export type { ChunkAnchor };
|
|
19
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/parser/markdown.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAA8B,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAY1D,UAAU,WAAW;IACnB,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,qFAAqF;IACrF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AA6ND;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAI1G;AAED,YAAY,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { unified } from "unified";
|
|
2
|
+
import remarkParse from "remark-parse";
|
|
3
|
+
import { toString as mdastToString } from "mdast-util-to-string";
|
|
4
|
+
import { Diagnostics } from "../diagnostics/codes.js";
|
|
5
|
+
import { SEPARATOR_WHITESPACE_PATTERN } from "./lexical-primitives.js";
|
|
6
|
+
/**
|
|
7
|
+
* Bridges remark's mdast into AfterText-owned AST types. mdast/unified
|
|
8
|
+
* types are used only inside this module — nothing from `mdast` or
|
|
9
|
+
* `unified` is re-exported from the compiler's public API. This is the
|
|
10
|
+
* one place allowed to "leak" parser-library concepts, and it does so by
|
|
11
|
+
* translation, not by re-export.
|
|
12
|
+
*/
|
|
13
|
+
const markdownProcessor = unified().use(remarkParse);
|
|
14
|
+
function remapPosition(pos, anchor) {
|
|
15
|
+
return {
|
|
16
|
+
line: anchor.startLine + (pos.line - 1),
|
|
17
|
+
column: pos.column,
|
|
18
|
+
offset: anchor.startOffset + pos.offset
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function remapSpan(position, anchor) {
|
|
22
|
+
if (!position) {
|
|
23
|
+
const zero = { line: anchor.startLine, column: 1, offset: anchor.startOffset };
|
|
24
|
+
return { start: zero, end: zero };
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
start: remapPosition({ line: position.start.line, column: position.start.column, offset: position.start.offset ?? 0 }, anchor),
|
|
28
|
+
end: remapPosition({ line: position.end.line, column: position.end.column, offset: position.end.offset ?? 0 }, anchor)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function convertInlineChildren(children, anchor, diagnostics) {
|
|
32
|
+
const result = [];
|
|
33
|
+
for (const child of children) {
|
|
34
|
+
const node = convertInline(child, anchor, diagnostics);
|
|
35
|
+
if (node)
|
|
36
|
+
result.push(node);
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
function convertInline(node, anchor, diagnostics) {
|
|
41
|
+
const span = remapSpan(node.position, anchor);
|
|
42
|
+
switch (node.type) {
|
|
43
|
+
case "text":
|
|
44
|
+
return { type: "Text", value: node.value, span };
|
|
45
|
+
case "emphasis":
|
|
46
|
+
return { type: "Emphasis", children: convertInlineChildren(node.children, anchor, diagnostics), span };
|
|
47
|
+
case "strong":
|
|
48
|
+
return { type: "Strong", children: convertInlineChildren(node.children, anchor, diagnostics), span };
|
|
49
|
+
case "inlineCode":
|
|
50
|
+
return { type: "InlineCode", value: node.value, span };
|
|
51
|
+
case "link":
|
|
52
|
+
return {
|
|
53
|
+
type: "Link",
|
|
54
|
+
url: node.url,
|
|
55
|
+
children: convertInlineChildren(node.children, anchor, diagnostics),
|
|
56
|
+
span
|
|
57
|
+
};
|
|
58
|
+
case "break":
|
|
59
|
+
return { type: "LineBreak", span };
|
|
60
|
+
default: {
|
|
61
|
+
// Fallback for inline constructs outside v0.1's supported subset
|
|
62
|
+
// (images, footnotes, raw html, ...): flatten to plain text rather
|
|
63
|
+
// than reimplementing the rest of Markdown's inline grammar, but
|
|
64
|
+
// warn so this doesn't silently change document meaning.
|
|
65
|
+
diagnostics.push(Diagnostics.unsupportedMarkdown(node.type, span));
|
|
66
|
+
const text = mdastToString(node);
|
|
67
|
+
return text.length > 0 ? { type: "Text", value: text, span } : undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Advances `position` forward by `count` characters on the same source
|
|
73
|
+
* line. Safe only when the caller knows the scan cannot cross a line
|
|
74
|
+
* ending — true for an ATX Heading's own opening-marker/separator region,
|
|
75
|
+
* which is always confined to that Heading's single physical line.
|
|
76
|
+
*/
|
|
77
|
+
function advancePositionOnLine(position, count) {
|
|
78
|
+
return { line: position.line, column: position.column + count, offset: position.offset + count };
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Computes `HeadingNode.contentSourceSpan` for a Heading with zero inline
|
|
82
|
+
* children (an empty authored ATX Heading — Setext Headings cannot have
|
|
83
|
+
* empty content, see docs/PROJECT_SPEC.md Section 25.49). Scans forward
|
|
84
|
+
* from immediately after the opening `#` marker run, consuming contiguous
|
|
85
|
+
* separator whitespace, bounded by `span.end.offset` — which already
|
|
86
|
+
* excludes the line ending but includes any trailing whitespace and any
|
|
87
|
+
* recognized ATX closing-hash run. Stopping at the first non-whitespace
|
|
88
|
+
* character (or at `span.end.offset`) therefore lands exactly before a
|
|
89
|
+
* closing-hash run when one is present, or at the end of trailing
|
|
90
|
+
* whitespace when one is not — in both cases the correct zero-width
|
|
91
|
+
* position, derived purely from already-computed facts (never a second
|
|
92
|
+
* Markdown parser).
|
|
93
|
+
*/
|
|
94
|
+
function computeEmptyHeadingContentSpan(depth, span, chunkText, anchor) {
|
|
95
|
+
const markerEnd = advancePositionOnLine(span.start, depth);
|
|
96
|
+
let offset = markerEnd.offset;
|
|
97
|
+
const upperBound = span.end.offset;
|
|
98
|
+
while (offset < upperBound && SEPARATOR_WHITESPACE_PATTERN.test(chunkText[offset - anchor.startOffset])) {
|
|
99
|
+
offset++;
|
|
100
|
+
}
|
|
101
|
+
const position = advancePositionOnLine(markerEnd, offset - markerEnd.offset);
|
|
102
|
+
return { start: position, end: position };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Computes `HeadingNode.contentSourceSpan` for a Heading with at least one
|
|
106
|
+
* inline child: the first child's span start through the last child's span
|
|
107
|
+
* end already excludes the opening marker/separator, any recognized ATX
|
|
108
|
+
* closing-hash run, trailing Heading whitespace, the Setext underline, and
|
|
109
|
+
* the line ending — confirmed sufficient by investigation, zero additional
|
|
110
|
+
* computation needed.
|
|
111
|
+
*/
|
|
112
|
+
function computeNonemptyHeadingContentSpan(children) {
|
|
113
|
+
const first = children[0];
|
|
114
|
+
const last = children[children.length - 1];
|
|
115
|
+
return { start: first.span.start, end: last.span.end };
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Computes `HeadingNode.levelSourceSpan` (docs/PROJECT_SPEC.md Section
|
|
119
|
+
* 25.50). ATX and Setext style is distinguished purely from already-
|
|
120
|
+
* published `span` facts — `span.start.line === span.end.line` for ATX
|
|
121
|
+
* (a single physical line) vs. Setext (always two-or-more physical lines,
|
|
122
|
+
* content plus underline) — an architectural source fact, not a heuristic,
|
|
123
|
+
* confirmed by investigation with no counterexample found.
|
|
124
|
+
*
|
|
125
|
+
* ATX: the opening marker run is exactly `[span.start.offset,
|
|
126
|
+
* span.start.offset + depth)` — the same fact `computeEmptyHeadingContentSpan`
|
|
127
|
+
* already uses to find the marker's end.
|
|
128
|
+
*
|
|
129
|
+
* Setext: the underline character run sits on the Heading's own final
|
|
130
|
+
* physical line, which `span.end` already terminates (excluding the line
|
|
131
|
+
* ending but including underline trailing whitespace). Scanning backward
|
|
132
|
+
* from `span.end.offset` — first past trailing separator whitespace, then
|
|
133
|
+
* past the homogeneous run of the underline character itself — locates the
|
|
134
|
+
* run's exact boundaries. Both scans are bounded within `chunkText`, which
|
|
135
|
+
* this module already holds for the current prose chunk; this is the same
|
|
136
|
+
* bounded-scan technique `computeEmptyHeadingContentSpan` already uses, not
|
|
137
|
+
* a second Markdown parser. Safe because every character involved (marker
|
|
138
|
+
* indentation, the underline run, and trailing whitespace) is ASCII and
|
|
139
|
+
* confined to one physical line, so offset and column move in lockstep.
|
|
140
|
+
*/
|
|
141
|
+
function computeHeadingLevelSpan(span, depth, chunkText, anchor) {
|
|
142
|
+
if (span.start.line === span.end.line) {
|
|
143
|
+
return { start: span.start, end: advancePositionOnLine(span.start, depth) };
|
|
144
|
+
}
|
|
145
|
+
const charAt = (offset) => chunkText[offset - anchor.startOffset];
|
|
146
|
+
let endOffset = span.end.offset;
|
|
147
|
+
while (endOffset > span.start.offset && SEPARATOR_WHITESPACE_PATTERN.test(charAt(endOffset - 1))) {
|
|
148
|
+
endOffset--;
|
|
149
|
+
}
|
|
150
|
+
const markerChar = charAt(endOffset - 1);
|
|
151
|
+
let startOffset = endOffset;
|
|
152
|
+
while (startOffset > span.start.offset && charAt(startOffset - 1) === markerChar) {
|
|
153
|
+
startOffset--;
|
|
154
|
+
}
|
|
155
|
+
const end = {
|
|
156
|
+
line: span.end.line,
|
|
157
|
+
column: span.end.column - (span.end.offset - endOffset),
|
|
158
|
+
offset: endOffset
|
|
159
|
+
};
|
|
160
|
+
const start = {
|
|
161
|
+
line: span.end.line,
|
|
162
|
+
column: end.column - (endOffset - startOffset),
|
|
163
|
+
offset: startOffset
|
|
164
|
+
};
|
|
165
|
+
return { start, end };
|
|
166
|
+
}
|
|
167
|
+
function convertBlock(node, anchor, diagnostics, chunkText) {
|
|
168
|
+
const span = remapSpan(node.position, anchor);
|
|
169
|
+
if (node.type === "paragraph") {
|
|
170
|
+
const paragraph = node;
|
|
171
|
+
const result = {
|
|
172
|
+
type: "Paragraph",
|
|
173
|
+
children: convertInlineChildren(paragraph.children, anchor, diagnostics),
|
|
174
|
+
span
|
|
175
|
+
};
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
if (node.type === "heading") {
|
|
179
|
+
const heading = node;
|
|
180
|
+
const children = convertInlineChildren(heading.children, anchor, diagnostics);
|
|
181
|
+
const contentSourceSpan = children.length > 0
|
|
182
|
+
? computeNonemptyHeadingContentSpan(children)
|
|
183
|
+
: computeEmptyHeadingContentSpan(heading.depth, span, chunkText, anchor);
|
|
184
|
+
const levelSourceSpan = computeHeadingLevelSpan(span, heading.depth, chunkText, anchor);
|
|
185
|
+
const result = {
|
|
186
|
+
type: "Heading",
|
|
187
|
+
depth: heading.depth,
|
|
188
|
+
children,
|
|
189
|
+
span,
|
|
190
|
+
contentSourceSpan,
|
|
191
|
+
levelSourceSpan
|
|
192
|
+
};
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
// Fallback for block constructs outside v0.1's supported subset (lists,
|
|
196
|
+
// blockquotes, code fences, tables, ...): rendered as a plain paragraph
|
|
197
|
+
// of their flattened text so no source content is silently dropped, but
|
|
198
|
+
// warn so this doesn't silently change document meaning.
|
|
199
|
+
diagnostics.push(Diagnostics.unsupportedMarkdown(node.type, span));
|
|
200
|
+
const text = mdastToString(node);
|
|
201
|
+
const fallback = {
|
|
202
|
+
type: "Paragraph",
|
|
203
|
+
children: text.length > 0 ? [{ type: "Text", value: text, span }] : [],
|
|
204
|
+
span
|
|
205
|
+
};
|
|
206
|
+
return fallback;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Parses a contiguous run of prose source text (already known to contain no
|
|
210
|
+
* AfterText directives) as Markdown, converting the result into
|
|
211
|
+
* AfterText-owned StoryBlock nodes anchored back to the full document via
|
|
212
|
+
* `anchor`. Constructs outside v0.1's supported subset (lists, blockquotes,
|
|
213
|
+
* images, code blocks, ...) still fall back to flattened plain text, but
|
|
214
|
+
* emit an AT3001 warning rather than changing document meaning silently.
|
|
215
|
+
*/
|
|
216
|
+
export function parseProseChunk(text, anchor, diagnostics) {
|
|
217
|
+
const root = markdownProcessor.parse(text);
|
|
218
|
+
const parent = root;
|
|
219
|
+
return parent.children.map((child) => convertBlock(child, anchor, diagnostics, text));
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/parser/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAYjE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AASrD,SAAS,aAAa,CAAC,GAAmB,EAAE,MAAmB;IAC7D,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,SAAS,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;QACvC,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,MAAM,EAAE,MAAM,CAAC,WAAW,GAAG,GAAG,CAAC,MAAM;KACxC,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,QAAmC,EAAE,MAAmB;IACzE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,GAAmB,EAAE,IAAI,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;QAC/F,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;IACpC,CAAC;IACD,OAAO;QACL,KAAK,EAAE,aAAa,CAClB,EAAE,IAAI,EAAE,QAAQ,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