@astryxdesign/core 0.6.2-canary.bfee8a4 → 0.6.2-canary.cb7a565
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/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +12 -2
- package/dist/Collapsible/Collapsible.d.ts.map +1 -1
- package/dist/Collapsible/Collapsible.js +6 -1
- package/dist/Kbd/Kbd.d.ts +5 -3
- package/dist/Kbd/Kbd.d.ts.map +1 -1
- package/dist/Kbd/Kbd.js +36 -42
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +6 -2
- package/dist/Markdown/Markdown.d.ts +8 -2
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.fr23.bench.d.ts +2 -0
- package/dist/Markdown/Markdown.fr23.bench.d.ts.map +1 -0
- package/dist/Markdown/Markdown.fr23.bench.js +248 -0
- package/dist/Markdown/Markdown.js +262 -109
- package/dist/Markdown/ast.d.ts +162 -0
- package/dist/Markdown/ast.d.ts.map +1 -0
- package/dist/Markdown/ast.js +74 -0
- package/dist/Markdown/index.d.ts +3 -1
- package/dist/Markdown/index.d.ts.map +1 -1
- package/dist/Markdown/index.js +1 -0
- package/dist/Markdown/parser.d.ts +104 -58
- package/dist/Markdown/parser.d.ts.map +1 -1
- package/dist/Markdown/parser.js +693 -167
- package/dist/Markdown/plugins/index.d.ts +14 -0
- package/dist/Markdown/plugins/index.d.ts.map +1 -0
- package/dist/Markdown/plugins/index.js +12 -0
- package/dist/Markdown/plugins/protocol.d.ts +191 -0
- package/dist/Markdown/plugins/protocol.d.ts.map +1 -0
- package/dist/Markdown/plugins/protocol.js +957 -0
- package/dist/Markdown/plugins/semanticFence.d.ts +36 -0
- package/dist/Markdown/plugins/semanticFence.d.ts.map +1 -0
- package/dist/Markdown/plugins/semanticFence.js +213 -0
- package/dist/Markdown/plugins/sourceDecoration.d.ts +76 -0
- package/dist/Markdown/plugins/sourceDecoration.d.ts.map +1 -0
- package/dist/Markdown/plugins/sourceDecoration.js +393 -0
- package/dist/Markdown/plugins/textTransform.d.ts +30 -0
- package/dist/Markdown/plugins/textTransform.d.ts.map +1 -0
- package/dist/Markdown/plugins/textTransform.js +374 -0
- package/dist/Markdown/url.d.ts +4 -0
- package/dist/Markdown/url.d.ts.map +1 -0
- package/dist/Markdown/url.js +25 -0
- package/dist/Markdown/utils.d.ts +4 -2
- package/dist/Markdown/utils.d.ts.map +1 -1
- package/dist/Markdown/utils.js +2 -1
- package/dist/Outline/index.d.ts +1 -0
- package/dist/Outline/index.d.ts.map +1 -1
- package/dist/Outline/parseOutlineFromMarkdown.d.ts +7 -1
- package/dist/Outline/parseOutlineFromMarkdown.d.ts.map +1 -1
- package/dist/Outline/parseOutlineFromMarkdown.js +14 -8
- package/dist/Outline/useOutlineFromMarkdown.d.ts +3 -1
- package/dist/Outline/useOutlineFromMarkdown.d.ts.map +1 -1
- package/dist/Outline/useOutlineFromMarkdown.js +8 -3
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +46 -30
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +13 -1
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +5 -5
- package/dist/SideNav/SideNav.d.ts +2 -1
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +9 -3
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +14 -8
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +11 -0
- package/dist/TabList/Tab.d.ts +1 -1
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +20 -7
- package/dist/ToggleButton/ToggleButton.d.ts +2 -1
- package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButton/ToggleButton.js +7 -1
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +15 -6
- package/dist/astryx.css +8 -0
- package/dist/utils/interactionOverlay.stylex.d.ts +8 -0
- package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
- package/dist/utils/interactionOverlay.stylex.js +9 -0
- package/package.json +8 -3
- package/src/Button/__tests__/Button.a11y.chromium.spec.ts +17 -1
- package/src/Button/__tests__/Button.a11y.known-failures.ts +0 -29
- package/src/Button/__tests__/Button.a11y.renders.tsx +9 -2
- package/src/Button/__tests__/Button.a11y.states.ts +9 -0
- package/src/CheckboxInput/CheckboxInput.doc.mjs +11 -0
- package/src/CheckboxInput/CheckboxInput.test.tsx +34 -0
- package/src/CheckboxInput/CheckboxInput.tsx +21 -1
- package/src/ClickableCard/ClickableCard.test.tsx +102 -5
- package/src/Collapsible/Collapsible.doc.mjs +11 -0
- package/src/Collapsible/Collapsible.test.tsx +21 -0
- package/src/Collapsible/Collapsible.tsx +5 -0
- package/src/Kbd/Kbd.doc.mjs +3 -3
- package/src/Kbd/Kbd.test.tsx +57 -1
- package/src/Kbd/Kbd.tsx +57 -37
- package/src/Link/Link.doc.mjs +11 -0
- package/src/Link/Link.test.tsx +24 -0
- package/src/Link/Link.tsx +5 -0
- package/src/Markdown/Markdown.doc.mjs +175 -0
- package/src/Markdown/Markdown.fr23.bench.ts +288 -0
- package/src/Markdown/Markdown.fr23.perf.test.ts +211 -0
- package/src/Markdown/Markdown.helpers.perf.test.ts +489 -0
- package/src/Markdown/Markdown.public.test.ts +126 -3
- package/src/Markdown/Markdown.spec.md +159 -43
- package/src/Markdown/Markdown.test.tsx +11 -0
- package/src/Markdown/Markdown.tsx +414 -135
- package/src/Markdown/ast.test.ts +307 -0
- package/src/Markdown/ast.ts +337 -0
- package/src/Markdown/incremental.test.ts +12 -0
- package/src/Markdown/index.ts +34 -0
- package/src/Markdown/parser.ts +1117 -235
- package/src/Markdown/plugins/index.ts +47 -0
- package/src/Markdown/plugins/protocol.test.tsx +955 -0
- package/src/Markdown/plugins/protocol.ts +1619 -0
- package/src/Markdown/plugins/semanticFence.test.tsx +546 -0
- package/src/Markdown/plugins/semanticFence.ts +424 -0
- package/src/Markdown/plugins/sourceDecoration.test.tsx +799 -0
- package/src/Markdown/plugins/sourceDecoration.ts +539 -0
- package/src/Markdown/plugins/textTransform.test.ts +467 -0
- package/src/Markdown/plugins/textTransform.ts +554 -0
- package/src/Markdown/url.ts +30 -0
- package/src/Markdown/utils.ts +13 -1
- package/src/Outline/Outline.doc.mjs +7 -5
- package/src/Outline/Outline.spec.md +1 -1
- package/src/Outline/index.ts +1 -0
- package/src/Outline/modules/parseOutlineFromMarkdown.spec.md +142 -0
- package/src/Outline/parseOutlineFromMarkdown.ts +39 -13
- package/src/Outline/useOutlineFromMarkdown.ts +15 -3
- package/src/PowerSearch/PowerSearchEditPopover.test.tsx +150 -1
- package/src/PowerSearch/PowerSearchEditPopover.tsx +51 -28
- package/src/RadioList/RadioList.doc.mjs +11 -0
- package/src/RadioList/RadioList.test.tsx +32 -0
- package/src/RadioList/RadioListItem.tsx +25 -1
- package/src/SegmentedControl/SegmentedControl.doc.mjs +2 -2
- package/src/SegmentedControl/SegmentedControl.test.tsx +31 -0
- package/src/SegmentedControl/SegmentedControlItem.tsx +6 -9
- package/src/SideNav/SideNav.doc.mjs +1 -1
- package/src/SideNav/SideNav.test.tsx +10 -0
- package/src/SideNav/SideNav.tsx +14 -2
- package/src/Slider/Slider.doc.mjs +11 -0
- package/src/Slider/Slider.test.tsx +128 -0
- package/src/Slider/Slider.tsx +25 -7
- package/src/Switch/Switch.doc.mjs +11 -0
- package/src/Switch/Switch.test.tsx +16 -0
- package/src/Switch/Switch.tsx +28 -0
- package/src/TabList/Tab.tsx +35 -7
- package/src/TabList/TabList.doc.mjs +11 -0
- package/src/TabList/TabList.test.tsx +66 -0
- package/src/TabList/__tests__/Tabs.a11y.known-failures.ts +1 -34
- package/src/ToggleButton/ToggleButton.test.tsx +133 -0
- package/src/ToggleButton/ToggleButton.tsx +9 -2
- package/src/ToggleButton/__tests__/ToggleButton.a11y.chromium.spec.ts +209 -0
- package/src/Tokenizer/Tokenizer.spec.md +142 -75
- package/src/Typeahead/BaseTypeahead.spec.md +4 -3
- package/src/Typeahead/BaseTypeahead.tsx +15 -6
- package/src/Typeahead/Typeahead.test.tsx +53 -0
- package/src/__tests__/PressedState.a11y.chromium.spec.ts +813 -0
- package/src/__tests__/pressState.ts +93 -0
- package/src/utils/interactionOverlay.stylex.ts +20 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file ast.ts
|
|
3
|
+
* @input Parsed Markdown structure and optional Astryx extension nodes
|
|
4
|
+
* @output Canonical immutable MDAST-aligned Markdown node types and text projection
|
|
5
|
+
* @position Internal canonical Markdown tree shared by parsing, rendering, and Outline
|
|
6
|
+
*/
|
|
7
|
+
export type MarkdownAstDataValue = null | boolean | number | string | ReadonlyArray<MarkdownAstDataValue> | {
|
|
8
|
+
readonly [key: string]: MarkdownAstDataValue;
|
|
9
|
+
};
|
|
10
|
+
export interface MarkdownAstPoint {
|
|
11
|
+
readonly line?: number;
|
|
12
|
+
readonly column?: number;
|
|
13
|
+
readonly offset?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface MarkdownAstPosition {
|
|
16
|
+
readonly start: MarkdownAstPoint;
|
|
17
|
+
readonly end: MarkdownAstPoint;
|
|
18
|
+
}
|
|
19
|
+
export interface MarkdownAstNodeBase {
|
|
20
|
+
readonly position?: MarkdownAstPosition;
|
|
21
|
+
readonly data?: MarkdownAstDataValue;
|
|
22
|
+
}
|
|
23
|
+
export interface MarkdownAstExtensionNode<Plugin extends string = string, Name extends string = string, Data extends MarkdownAstDataValue = MarkdownAstDataValue, Display extends 'inline' | 'block' = 'inline' | 'block'> extends MarkdownAstNodeBase {
|
|
24
|
+
readonly type: 'extension';
|
|
25
|
+
readonly plugin: Plugin;
|
|
26
|
+
readonly name: Name;
|
|
27
|
+
readonly data: Data;
|
|
28
|
+
readonly display: Display;
|
|
29
|
+
readonly source?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface MarkdownAstText extends MarkdownAstNodeBase {
|
|
32
|
+
readonly type: 'text';
|
|
33
|
+
readonly value: string;
|
|
34
|
+
}
|
|
35
|
+
export interface MarkdownAstParent<Type extends 'strong' | 'emphasis' | 'delete', Extension extends MarkdownAstExtensionNode = never> extends MarkdownAstNodeBase {
|
|
36
|
+
readonly type: Type;
|
|
37
|
+
readonly children: ReadonlyArray<MarkdownAstPhrasingContent<Extension>>;
|
|
38
|
+
}
|
|
39
|
+
export interface MarkdownAstInlineCode extends MarkdownAstNodeBase {
|
|
40
|
+
readonly type: 'inlineCode';
|
|
41
|
+
readonly value: string;
|
|
42
|
+
}
|
|
43
|
+
export interface MarkdownAstInlineMath extends MarkdownAstNodeBase {
|
|
44
|
+
readonly type: 'inlineMath';
|
|
45
|
+
readonly value: string;
|
|
46
|
+
}
|
|
47
|
+
export interface MarkdownAstLink<Extension extends MarkdownAstExtensionNode = never> extends MarkdownAstNodeBase {
|
|
48
|
+
readonly type: 'link';
|
|
49
|
+
readonly url: string;
|
|
50
|
+
readonly children: ReadonlyArray<MarkdownAstPhrasingContent<Extension>>;
|
|
51
|
+
}
|
|
52
|
+
export interface MarkdownAstImage extends MarkdownAstNodeBase {
|
|
53
|
+
readonly type: 'image';
|
|
54
|
+
readonly url: string;
|
|
55
|
+
readonly alt: string;
|
|
56
|
+
}
|
|
57
|
+
export interface MarkdownAstCitation extends MarkdownAstNodeBase {
|
|
58
|
+
readonly type: 'citation';
|
|
59
|
+
readonly sourceId: string;
|
|
60
|
+
}
|
|
61
|
+
export interface MarkdownAstBreak extends MarkdownAstNodeBase {
|
|
62
|
+
readonly type: 'break';
|
|
63
|
+
}
|
|
64
|
+
export type MarkdownAstPhrasingContent<Extension extends MarkdownAstExtensionNode = never> = MarkdownAstText | MarkdownAstParent<'strong', Extension> | MarkdownAstParent<'emphasis', Extension> | MarkdownAstParent<'delete', Extension> | MarkdownAstInlineCode | MarkdownAstInlineMath | MarkdownAstLink<Extension> | MarkdownAstImage | MarkdownAstCitation | MarkdownAstBreak | (Extension & {
|
|
65
|
+
readonly display: 'inline';
|
|
66
|
+
});
|
|
67
|
+
export interface MarkdownAstHeading<Extension extends MarkdownAstExtensionNode = never> extends MarkdownAstNodeBase {
|
|
68
|
+
readonly type: 'heading';
|
|
69
|
+
readonly depth: 1 | 2 | 3 | 4 | 5 | 6;
|
|
70
|
+
readonly children: ReadonlyArray<MarkdownAstPhrasingContent<Extension>>;
|
|
71
|
+
}
|
|
72
|
+
export interface MarkdownAstParagraph<Extension extends MarkdownAstExtensionNode = never> extends MarkdownAstNodeBase {
|
|
73
|
+
readonly type: 'paragraph';
|
|
74
|
+
readonly children: ReadonlyArray<MarkdownAstPhrasingContent<Extension>>;
|
|
75
|
+
}
|
|
76
|
+
export interface MarkdownAstCode extends MarkdownAstNodeBase {
|
|
77
|
+
readonly type: 'code';
|
|
78
|
+
readonly lang: string | null;
|
|
79
|
+
readonly meta?: string;
|
|
80
|
+
readonly value: string;
|
|
81
|
+
}
|
|
82
|
+
/** @internal Preserves the released parser/renderer language projection. */
|
|
83
|
+
export declare function markMarkdownAstLegacyCodeLanguage<Node extends MarkdownAstCode>(node: Node, language: string | null): Node;
|
|
84
|
+
/** @internal Reads the released language projection for a canonical code node. */
|
|
85
|
+
export declare function getMarkdownAstLegacyCodeLanguage(node: MarkdownAstCode): string | null;
|
|
86
|
+
export interface MarkdownAstMath extends MarkdownAstNodeBase {
|
|
87
|
+
readonly type: 'math';
|
|
88
|
+
readonly value: string;
|
|
89
|
+
}
|
|
90
|
+
export interface MarkdownAstBlockquote<Extension extends MarkdownAstExtensionNode = never> extends MarkdownAstNodeBase {
|
|
91
|
+
readonly type: 'blockquote';
|
|
92
|
+
readonly children: ReadonlyArray<MarkdownAstBlockContent<Extension>>;
|
|
93
|
+
}
|
|
94
|
+
export interface MarkdownAstListItem<Extension extends MarkdownAstExtensionNode = never> extends MarkdownAstNodeBase {
|
|
95
|
+
readonly type: 'listItem';
|
|
96
|
+
readonly checked?: boolean;
|
|
97
|
+
readonly children: ReadonlyArray<MarkdownAstBlockContent<Extension>>;
|
|
98
|
+
}
|
|
99
|
+
export interface MarkdownAstList<Extension extends MarkdownAstExtensionNode = never> extends MarkdownAstNodeBase {
|
|
100
|
+
readonly type: 'list';
|
|
101
|
+
readonly ordered: boolean;
|
|
102
|
+
readonly start?: number;
|
|
103
|
+
readonly spread?: boolean;
|
|
104
|
+
/** Astryx-preserved ordered-list marker delimiter. */
|
|
105
|
+
readonly delimiter?: '.' | ')';
|
|
106
|
+
readonly children: ReadonlyArray<MarkdownAstListItem<Extension>>;
|
|
107
|
+
}
|
|
108
|
+
export type MarkdownAstTableAlignment = 'left' | 'center' | 'right' | null;
|
|
109
|
+
export interface MarkdownAstTableCell<Extension extends MarkdownAstExtensionNode = never> extends MarkdownAstNodeBase {
|
|
110
|
+
readonly type: 'tableCell';
|
|
111
|
+
readonly children: ReadonlyArray<MarkdownAstPhrasingContent<Extension>>;
|
|
112
|
+
}
|
|
113
|
+
export interface MarkdownAstTableRow<Extension extends MarkdownAstExtensionNode = never> extends MarkdownAstNodeBase {
|
|
114
|
+
readonly type: 'tableRow';
|
|
115
|
+
readonly children: ReadonlyArray<MarkdownAstTableCell<Extension>>;
|
|
116
|
+
}
|
|
117
|
+
export interface MarkdownAstTable<Extension extends MarkdownAstExtensionNode = never> extends MarkdownAstNodeBase {
|
|
118
|
+
readonly type: 'table';
|
|
119
|
+
readonly align: ReadonlyArray<MarkdownAstTableAlignment>;
|
|
120
|
+
readonly children: ReadonlyArray<MarkdownAstTableRow<Extension>>;
|
|
121
|
+
}
|
|
122
|
+
export interface MarkdownAstThematicBreak extends MarkdownAstNodeBase {
|
|
123
|
+
readonly type: 'thematicBreak';
|
|
124
|
+
}
|
|
125
|
+
export type MarkdownAstBlockContent<Extension extends MarkdownAstExtensionNode = never> = MarkdownAstHeading<Extension> | MarkdownAstParagraph<Extension> | MarkdownAstCode | MarkdownAstMath | MarkdownAstBlockquote<Extension> | MarkdownAstList<Extension> | MarkdownAstTable<Extension> | MarkdownAstThematicBreak | MarkdownAstImage | (Extension & {
|
|
126
|
+
readonly display: 'block';
|
|
127
|
+
});
|
|
128
|
+
export interface MarkdownAstRoot<Extension extends MarkdownAstExtensionNode = never> extends MarkdownAstNodeBase {
|
|
129
|
+
readonly type: 'root';
|
|
130
|
+
readonly children: ReadonlyArray<MarkdownAstBlockContent<Extension>>;
|
|
131
|
+
}
|
|
132
|
+
export interface MarkdownAstNodeMap<Extension extends MarkdownAstExtensionNode = MarkdownAstExtensionNode> {
|
|
133
|
+
readonly root: MarkdownAstRoot<Extension>;
|
|
134
|
+
readonly text: MarkdownAstText;
|
|
135
|
+
readonly strong: MarkdownAstParent<'strong', Extension>;
|
|
136
|
+
readonly emphasis: MarkdownAstParent<'emphasis', Extension>;
|
|
137
|
+
readonly delete: MarkdownAstParent<'delete', Extension>;
|
|
138
|
+
readonly inlineCode: MarkdownAstInlineCode;
|
|
139
|
+
readonly inlineMath: MarkdownAstInlineMath;
|
|
140
|
+
readonly break: MarkdownAstBreak;
|
|
141
|
+
readonly link: MarkdownAstLink<Extension>;
|
|
142
|
+
readonly image: MarkdownAstImage;
|
|
143
|
+
readonly citation: MarkdownAstCitation;
|
|
144
|
+
readonly heading: MarkdownAstHeading<Extension>;
|
|
145
|
+
readonly paragraph: MarkdownAstParagraph<Extension>;
|
|
146
|
+
readonly code: MarkdownAstCode;
|
|
147
|
+
readonly math: MarkdownAstMath;
|
|
148
|
+
readonly blockquote: MarkdownAstBlockquote<Extension>;
|
|
149
|
+
readonly list: MarkdownAstList<Extension>;
|
|
150
|
+
readonly listItem: MarkdownAstListItem<Extension>;
|
|
151
|
+
readonly table: MarkdownAstTable<Extension>;
|
|
152
|
+
readonly tableRow: MarkdownAstTableRow<Extension>;
|
|
153
|
+
readonly tableCell: MarkdownAstTableCell<Extension>;
|
|
154
|
+
readonly thematicBreak: MarkdownAstThematicBreak;
|
|
155
|
+
readonly extension: Extension;
|
|
156
|
+
}
|
|
157
|
+
export type MarkdownAstNode<Extension extends MarkdownAstExtensionNode = MarkdownAstExtensionNode, Type extends keyof MarkdownAstNodeMap<Extension> = keyof MarkdownAstNodeMap<Extension>> = MarkdownAstNodeMap<Extension>[Type];
|
|
158
|
+
export declare function visitMarkdownNodes<Extension extends MarkdownAstExtensionNode, Type extends keyof MarkdownAstNodeMap<Extension>>(root: MarkdownAstRoot<Extension>, type: Type, visitor: (node: MarkdownAstNodeMap<Extension>[Type]) => void): void;
|
|
159
|
+
export declare function markdownAstText<Extension extends MarkdownAstExtensionNode = never>(nodes: ReadonlyArray<MarkdownAstPhrasingContent<Extension>>, extensionText?: (node: Extension & {
|
|
160
|
+
readonly display: 'inline';
|
|
161
|
+
}) => string): string;
|
|
162
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/Markdown/ast.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,MAAM,MAAM,oBAAoB,GAC5B,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,aAAa,CAAC,oBAAoB,CAAC,GACnC;IAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAAA;CAAC,CAAC;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,gBAAg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S,SAAS,wBAAwB,GAAG,wBAAwB,EACrE,IAAI,SAAS,MAAM,kBAAkB,CAAC,SAAS,CAAC,GAC9C,MAAM,kBAAkB,CAAC,SAAS,CAAC,IACnC,kBAAkB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC;AAExC,wBAAgB,kBAAkB,CAChC,SAAS,SAAS,wBAAwB,EAC1C,IAAI,SAAS,MAAM,kBAAkB,CAAC,SAAS,CAAC,EAEhD,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,EAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,CAAC,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,GAC3D,IAAI,CAYN;AAED,wBAAgB,eAAe,CAC7B,SAAS,SAAS,wBAAwB,GAAG,KAAK,EAElD,KAAK,EAAE,aAAa,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC,EAC3D,aAAa,GAAE,CACb,IAAI,EAAE,SAAS,GAAG;IAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAA;CAAC,KAC3C,MAAkC,GACtC,MAAM,CA8BR"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file ast.ts
|
|
5
|
+
* @input Parsed Markdown structure and optional Astryx extension nodes
|
|
6
|
+
* @output Canonical immutable MDAST-aligned Markdown node types and text projection
|
|
7
|
+
* @position Internal canonical Markdown tree shared by parsing, rendering, and Outline
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const markdownAstLegacyCodeLanguage = Symbol('MarkdownAstLegacyCodeLanguage');
|
|
11
|
+
/** @internal Preserves the released parser/renderer language projection. */
|
|
12
|
+
export function markMarkdownAstLegacyCodeLanguage(node, language) {
|
|
13
|
+
if (language === node.lang) {
|
|
14
|
+
return node;
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(node, markdownAstLegacyCodeLanguage, {
|
|
17
|
+
configurable: false,
|
|
18
|
+
enumerable: true,
|
|
19
|
+
value: language,
|
|
20
|
+
writable: false
|
|
21
|
+
});
|
|
22
|
+
return node;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @internal Reads the released language projection for a canonical code node. */
|
|
26
|
+
export function getMarkdownAstLegacyCodeLanguage(node) {
|
|
27
|
+
const legacyLanguage = node[markdownAstLegacyCodeLanguage];
|
|
28
|
+
return legacyLanguage === undefined ? node.lang : legacyLanguage;
|
|
29
|
+
}
|
|
30
|
+
export function visitMarkdownNodes(root, type, visitor) {
|
|
31
|
+
const visit = node => {
|
|
32
|
+
if (node.type === type) {
|
|
33
|
+
visitor(node);
|
|
34
|
+
}
|
|
35
|
+
if ('children' in node) {
|
|
36
|
+
for (const child of node.children) {
|
|
37
|
+
visit(child);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
visit(root);
|
|
42
|
+
}
|
|
43
|
+
export function markdownAstText(nodes, extensionText = node => node.source ?? '') {
|
|
44
|
+
let text = '';
|
|
45
|
+
for (const node of nodes) {
|
|
46
|
+
switch (node.type) {
|
|
47
|
+
case 'text':
|
|
48
|
+
case 'inlineCode':
|
|
49
|
+
case 'inlineMath':
|
|
50
|
+
text += node.value;
|
|
51
|
+
break;
|
|
52
|
+
case 'strong':
|
|
53
|
+
case 'emphasis':
|
|
54
|
+
case 'delete':
|
|
55
|
+
case 'link':
|
|
56
|
+
text += markdownAstText(node.children, extensionText);
|
|
57
|
+
break;
|
|
58
|
+
case 'image':
|
|
59
|
+
text += node.alt;
|
|
60
|
+
break;
|
|
61
|
+
case 'citation':
|
|
62
|
+
case 'break':
|
|
63
|
+
break;
|
|
64
|
+
case 'extension':
|
|
65
|
+
text += extensionText(node);
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
{
|
|
69
|
+
node;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return text;
|
|
74
|
+
}
|
package/dist/Markdown/index.d.ts
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* @output Exports Markdown component, parser functions, and types
|
|
4
4
|
* @position Component entry point; re-exported by /packages/core/src/index.ts
|
|
5
5
|
*/
|
|
6
|
+
export { visitMarkdownNodes } from './ast';
|
|
7
|
+
export type { MarkdownAstPoint, MarkdownAstDataValue, MarkdownAstPosition, MarkdownAstNodeBase, MarkdownAstExtensionNode, MarkdownAstText, MarkdownAstInlineCode, MarkdownAstInlineMath, MarkdownAstLink, MarkdownAstImage, MarkdownAstCitation, MarkdownAstBreak, MarkdownAstPhrasingContent, MarkdownAstHeading, MarkdownAstParagraph, MarkdownAstCode, MarkdownAstMath, MarkdownAstBlockquote, MarkdownAstList, MarkdownAstListItem, MarkdownAstTable, MarkdownAstTableRow, MarkdownAstTableCell, MarkdownAstThematicBreak, MarkdownAstBlockContent, MarkdownAstRoot, MarkdownAstNodeMap, MarkdownAstNode, } from './ast';
|
|
6
8
|
export { Markdown } from './Markdown';
|
|
7
9
|
export type { MarkdownProps, MarkdownSource, MarkdownComponents, MarkdownInlinePlugin, } from './Markdown';
|
|
8
10
|
export { parseMarkdown, parseMarkdownIncremental, createIncrementalState, parseInline, } from './parser';
|
|
9
|
-
export type { BlockNode, BlockNodeWithMath, MathBlockNode, InlineNode, InlineNodeWithMath, MathInlineNode, SourceRange, ListItemNode, TableCellNode, TableAlignment, ParseOptions, MathParseOptions, IncrementalState as IncrementalParseState, } from './parser';
|
|
11
|
+
export type { BlockNode, BlockNodeWithMath, MathBlockNode, InlineNode, InlineNodeWithMath, MathInlineNode, SourceRange, ListItemNode, TableCellNode, TableAlignment, ParseOptions, MathParseOptions, IncrementalParseOptions, IncrementalMathParseOptions, IncrementalState as IncrementalParseState, } from './parser';
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Markdown/index.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,YAAY,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,sBAAsB,EACtB,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,IAAI,qBAAqB,GAC1C,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Markdown/index.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,OAAO,CAAC;AACzC,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,eAAe,GAChB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,YAAY,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,sBAAsB,EACtB,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,uBAAuB,EACvB,2BAA2B,EAC3B,gBAAgB,IAAI,qBAAqB,GAC1C,MAAM,UAAU,CAAC"}
|
package/dist/Markdown/index.js
CHANGED
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
* @output Exports Markdown component, parser functions, and types
|
|
8
8
|
* @position Component entry point; re-exported by /packages/core/src/index.ts
|
|
9
9
|
*/
|
|
10
|
+
export { visitMarkdownNodes } from "./ast.js";
|
|
10
11
|
export { Markdown } from "./Markdown.js";
|
|
11
12
|
export { parseMarkdown, parseMarkdownIncremental, createIncrementalState, parseInline } from "./parser.js";
|
|
@@ -1,32 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @input Markdown string
|
|
4
|
-
* @output Array of MarkdownNode AST nodes, including opt-in math; heading slug
|
|
5
|
-
* helpers
|
|
6
|
-
* (inlineText, slugify, uniqueSlug) shared by Markdown rendering and
|
|
7
|
-
* Outline's parseOutlineFromMarkdown
|
|
8
|
-
* @position Core parser; consumed by Markdown.tsx and Outline
|
|
9
|
-
*/
|
|
1
|
+
import type { MarkdownAstPhrasingContent, MarkdownAstRoot } from './ast';
|
|
2
|
+
import type { MarkdownExtensionNode, MarkdownExtensionsOf, MarkdownPluginData, MarkdownPluginEntry } from './plugins/protocol';
|
|
10
3
|
/** Nodes returned by default and legacy parser calls. */
|
|
11
|
-
export type InlineNode = {
|
|
4
|
+
export type InlineNode<Extension extends MarkdownExtensionNode = never> = {
|
|
12
5
|
type: 'text';
|
|
13
6
|
content: string;
|
|
14
7
|
} | {
|
|
15
8
|
type: 'bold';
|
|
16
|
-
children: InlineNode[];
|
|
9
|
+
children: InlineNode<Extension>[];
|
|
17
10
|
} | {
|
|
18
11
|
type: 'italic';
|
|
19
|
-
children: InlineNode[];
|
|
12
|
+
children: InlineNode<Extension>[];
|
|
20
13
|
} | {
|
|
21
14
|
type: 'strikethrough';
|
|
22
|
-
children: InlineNode[];
|
|
15
|
+
children: InlineNode<Extension>[];
|
|
23
16
|
} | {
|
|
24
17
|
type: 'code';
|
|
25
18
|
content: string;
|
|
26
19
|
} | {
|
|
27
20
|
type: 'link';
|
|
28
21
|
href: string;
|
|
29
|
-
children: InlineNode[];
|
|
22
|
+
children: InlineNode<Extension>[];
|
|
30
23
|
} | {
|
|
31
24
|
type: 'image';
|
|
32
25
|
src: string;
|
|
@@ -36,32 +29,34 @@ export type InlineNode = {
|
|
|
36
29
|
sourceId: string;
|
|
37
30
|
} | {
|
|
38
31
|
type: 'break';
|
|
39
|
-
}
|
|
32
|
+
} | Extract<Extension, {
|
|
33
|
+
display: 'inline';
|
|
34
|
+
}>;
|
|
40
35
|
/** The additional inline node returned only when parsing with `math: true`. */
|
|
41
36
|
export type MathInlineNode = {
|
|
42
37
|
type: 'math';
|
|
43
38
|
value: string;
|
|
44
39
|
};
|
|
45
40
|
/** Nodes returned by an explicitly math-enabled inline parse. */
|
|
46
|
-
export type InlineNodeWithMath = {
|
|
41
|
+
export type InlineNodeWithMath<Extension extends MarkdownExtensionNode = never> = {
|
|
47
42
|
type: 'text';
|
|
48
43
|
content: string;
|
|
49
44
|
} | {
|
|
50
45
|
type: 'bold';
|
|
51
|
-
children: InlineNodeWithMath[];
|
|
46
|
+
children: InlineNodeWithMath<Extension>[];
|
|
52
47
|
} | {
|
|
53
48
|
type: 'italic';
|
|
54
|
-
children: InlineNodeWithMath[];
|
|
49
|
+
children: InlineNodeWithMath<Extension>[];
|
|
55
50
|
} | {
|
|
56
51
|
type: 'strikethrough';
|
|
57
|
-
children: InlineNodeWithMath[];
|
|
52
|
+
children: InlineNodeWithMath<Extension>[];
|
|
58
53
|
} | {
|
|
59
54
|
type: 'code';
|
|
60
55
|
content: string;
|
|
61
56
|
} | MathInlineNode | {
|
|
62
57
|
type: 'link';
|
|
63
58
|
href: string;
|
|
64
|
-
children: InlineNodeWithMath[];
|
|
59
|
+
children: InlineNodeWithMath<Extension>[];
|
|
65
60
|
} | {
|
|
66
61
|
type: 'image';
|
|
67
62
|
src: string;
|
|
@@ -71,7 +66,9 @@ export type InlineNodeWithMath = {
|
|
|
71
66
|
sourceId: string;
|
|
72
67
|
} | {
|
|
73
68
|
type: 'break';
|
|
74
|
-
}
|
|
69
|
+
} | Extract<Extension, {
|
|
70
|
+
display: 'inline';
|
|
71
|
+
}>;
|
|
75
72
|
type BlockMetadata = {
|
|
76
73
|
/**
|
|
77
74
|
* Where this block came from in the source, when parsed with the
|
|
@@ -79,20 +76,20 @@ type BlockMetadata = {
|
|
|
79
76
|
*/
|
|
80
77
|
range?: SourceRange;
|
|
81
78
|
};
|
|
82
|
-
type LegacyBlockNodeKind = {
|
|
79
|
+
type LegacyBlockNodeKind<Extension extends MarkdownExtensionNode = never> = {
|
|
83
80
|
type: 'heading';
|
|
84
81
|
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
85
|
-
children: InlineNode[];
|
|
82
|
+
children: InlineNode<Extension>[];
|
|
86
83
|
} | {
|
|
87
84
|
type: 'paragraph';
|
|
88
|
-
children: InlineNode[];
|
|
85
|
+
children: InlineNode<Extension>[];
|
|
89
86
|
} | {
|
|
90
87
|
type: 'codeblock';
|
|
91
88
|
language: string;
|
|
92
89
|
content: string;
|
|
93
90
|
} | {
|
|
94
91
|
type: 'blockquote';
|
|
95
|
-
children: BlockNode[];
|
|
92
|
+
children: BlockNode<Extension>[];
|
|
96
93
|
} | {
|
|
97
94
|
type: 'list';
|
|
98
95
|
ordered: boolean;
|
|
@@ -100,40 +97,42 @@ type LegacyBlockNodeKind = {
|
|
|
100
97
|
/** Ordered-list marker delimiter ('.' or ')'). Undefined for bullets. */
|
|
101
98
|
delimiter?: '.' | ')';
|
|
102
99
|
loose?: boolean;
|
|
103
|
-
items: ListItemNode[];
|
|
100
|
+
items: ListItemNode<Extension>[];
|
|
104
101
|
} | {
|
|
105
102
|
type: 'table';
|
|
106
|
-
headers: TableCellNode[];
|
|
103
|
+
headers: TableCellNode<Extension>[];
|
|
107
104
|
alignments: TableAlignment[];
|
|
108
|
-
rows: TableCellNode[][];
|
|
105
|
+
rows: TableCellNode<Extension>[][];
|
|
109
106
|
} | {
|
|
110
107
|
type: 'hr';
|
|
111
108
|
} | {
|
|
112
109
|
type: 'image';
|
|
113
110
|
src: string;
|
|
114
111
|
alt: string;
|
|
115
|
-
}
|
|
112
|
+
} | Extract<Extension, {
|
|
113
|
+
display: 'block';
|
|
114
|
+
}>;
|
|
116
115
|
/** Blocks returned by default and legacy parser calls. */
|
|
117
|
-
export type BlockNode = LegacyBlockNodeKind & BlockMetadata;
|
|
116
|
+
export type BlockNode<Extension extends MarkdownExtensionNode = never> = LegacyBlockNodeKind<Extension> & BlockMetadata;
|
|
118
117
|
/** The additional block returned only when parsing with `math: true`. */
|
|
119
118
|
export type MathBlockNode = {
|
|
120
119
|
type: 'math';
|
|
121
120
|
value: string;
|
|
122
121
|
} & BlockMetadata;
|
|
123
|
-
type MathEnabledBlockNodeKind = {
|
|
122
|
+
type MathEnabledBlockNodeKind<Extension extends MarkdownExtensionNode = never> = {
|
|
124
123
|
type: 'heading';
|
|
125
124
|
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
126
|
-
children: InlineNodeWithMath[];
|
|
125
|
+
children: InlineNodeWithMath<Extension>[];
|
|
127
126
|
} | {
|
|
128
127
|
type: 'paragraph';
|
|
129
|
-
children: InlineNodeWithMath[];
|
|
128
|
+
children: InlineNodeWithMath<Extension>[];
|
|
130
129
|
} | {
|
|
131
130
|
type: 'codeblock';
|
|
132
131
|
language: string;
|
|
133
132
|
content: string;
|
|
134
133
|
} | MathBlockNode | {
|
|
135
134
|
type: 'blockquote';
|
|
136
|
-
children: BlockNodeWithMath[];
|
|
135
|
+
children: BlockNodeWithMath<Extension>[];
|
|
137
136
|
} | {
|
|
138
137
|
type: 'list';
|
|
139
138
|
ordered: boolean;
|
|
@@ -141,21 +140,23 @@ type MathEnabledBlockNodeKind = {
|
|
|
141
140
|
/** Ordered-list marker delimiter ('.' or ')'). Undefined for bullets. */
|
|
142
141
|
delimiter?: '.' | ')';
|
|
143
142
|
loose?: boolean;
|
|
144
|
-
items: ListItemNodeWithMath[];
|
|
143
|
+
items: ListItemNodeWithMath<Extension>[];
|
|
145
144
|
} | {
|
|
146
145
|
type: 'table';
|
|
147
|
-
headers: TableCellNodeWithMath[];
|
|
146
|
+
headers: TableCellNodeWithMath<Extension>[];
|
|
148
147
|
alignments: TableAlignment[];
|
|
149
|
-
rows: TableCellNodeWithMath[][];
|
|
148
|
+
rows: TableCellNodeWithMath<Extension>[][];
|
|
150
149
|
} | {
|
|
151
150
|
type: 'hr';
|
|
152
151
|
} | {
|
|
153
152
|
type: 'image';
|
|
154
153
|
src: string;
|
|
155
154
|
alt: string;
|
|
156
|
-
}
|
|
155
|
+
} | Extract<Extension, {
|
|
156
|
+
display: 'block';
|
|
157
|
+
}>;
|
|
157
158
|
/** Blocks returned by an explicitly math-enabled block parse. */
|
|
158
|
-
export type BlockNodeWithMath = MathEnabledBlockNodeKind & BlockMetadata;
|
|
159
|
+
export type BlockNodeWithMath<Extension extends MarkdownExtensionNode = never> = MathEnabledBlockNodeKind<Extension> & BlockMetadata;
|
|
159
160
|
/**
|
|
160
161
|
* Where a block sits in the source string handed to `parseMarkdown`:
|
|
161
162
|
* `source.slice(start, end)` is the block, and `end` excludes the block's
|
|
@@ -169,21 +170,22 @@ export type SourceRange = {
|
|
|
169
170
|
readonly start: number;
|
|
170
171
|
readonly end: number;
|
|
171
172
|
};
|
|
172
|
-
export type ListItemNode = {
|
|
173
|
+
export type ListItemNode<Extension extends MarkdownExtensionNode = never> = {
|
|
173
174
|
checked?: boolean;
|
|
174
|
-
children: BlockNode[];
|
|
175
|
+
children: BlockNode<Extension>[];
|
|
175
176
|
};
|
|
176
|
-
type ListItemNodeWithMath = {
|
|
177
|
+
type ListItemNodeWithMath<Extension extends MarkdownExtensionNode = never> = {
|
|
177
178
|
checked?: boolean;
|
|
178
|
-
children: BlockNodeWithMath[];
|
|
179
|
+
children: BlockNodeWithMath<Extension>[];
|
|
179
180
|
};
|
|
180
|
-
export type TableCellNode = {
|
|
181
|
-
children: InlineNode[];
|
|
181
|
+
export type TableCellNode<Extension extends MarkdownExtensionNode = never> = {
|
|
182
|
+
children: InlineNode<Extension>[];
|
|
182
183
|
};
|
|
183
|
-
type TableCellNodeWithMath = {
|
|
184
|
-
children: InlineNodeWithMath[];
|
|
184
|
+
type TableCellNodeWithMath<Extension extends MarkdownExtensionNode = never> = {
|
|
185
|
+
children: InlineNodeWithMath<Extension>[];
|
|
185
186
|
};
|
|
186
187
|
export type TableAlignment = 'left' | 'center' | 'right' | null;
|
|
188
|
+
type RuntimeExtensionNode = MarkdownExtensionNode<string, string, MarkdownPluginData, 'inline'> | MarkdownExtensionNode<string, string, MarkdownPluginData, 'block'>;
|
|
187
189
|
/**
|
|
188
190
|
* Options for the markdown parser entry points.
|
|
189
191
|
*
|
|
@@ -191,10 +193,12 @@ export type TableAlignment = 'left' | 'center' | 'right' | null;
|
|
|
191
193
|
* `parseMarkdownIncremental` functions also accept the legacy
|
|
192
194
|
* `ReadonlySet<string>` shape as the second argument.
|
|
193
195
|
*/
|
|
194
|
-
type CommonParseOptions = {
|
|
196
|
+
type CommonParseOptions<Plugins extends ReadonlyArray<MarkdownPluginEntry> = readonly []> = {
|
|
195
197
|
/** Set of citation source ids — `[id]` / `【id】` markers in this set
|
|
196
198
|
* become citation nodes instead of plain text / links. */
|
|
197
199
|
sourceIds?: ReadonlySet<string>;
|
|
200
|
+
/** Ordered opt-in Markdown extensions. */
|
|
201
|
+
plugins?: Plugins;
|
|
198
202
|
/**
|
|
199
203
|
* Autolink mode. When set to `'gfm'`, the parser turns bare
|
|
200
204
|
* `https?://…` / `www.…` URLs, `<URL>` / `<email>` angle-bracket
|
|
@@ -219,7 +223,7 @@ type CommonParseOptions = {
|
|
|
219
223
|
sourceRanges?: boolean;
|
|
220
224
|
};
|
|
221
225
|
/** Options for default and legacy parser results. */
|
|
222
|
-
export type ParseOptions = CommonParseOptions & {
|
|
226
|
+
export type ParseOptions<Plugins extends ReadonlyArray<MarkdownPluginEntry> = readonly []> = CommonParseOptions<Plugins> & {
|
|
223
227
|
math?: false | undefined;
|
|
224
228
|
};
|
|
225
229
|
/**
|
|
@@ -227,15 +231,47 @@ export type ParseOptions = CommonParseOptions & {
|
|
|
227
231
|
* unions. Keeping this separate prevents a legacy `ParseOptions` annotation
|
|
228
232
|
* from silently widening an exhaustive node switch.
|
|
229
233
|
*/
|
|
230
|
-
export type MathParseOptions = CommonParseOptions & {
|
|
234
|
+
export type MathParseOptions<Plugins extends ReadonlyArray<MarkdownPluginEntry> = readonly []> = CommonParseOptions<Plugins> & {
|
|
231
235
|
math: true;
|
|
232
236
|
};
|
|
237
|
+
export type IncrementalParseOptions<Plugins extends ReadonlyArray<MarkdownPluginEntry> = readonly []> = ParseOptions<Plugins> & {
|
|
238
|
+
/** False while more source may arrive; true for the terminal snapshot. */
|
|
239
|
+
readonly isFinal?: boolean;
|
|
240
|
+
};
|
|
241
|
+
export type IncrementalMathParseOptions<Plugins extends ReadonlyArray<MarkdownPluginEntry> = readonly []> = MathParseOptions<Plugins> & {
|
|
242
|
+
/** False while more source may arrive; true for the terminal snapshot. */
|
|
243
|
+
readonly isFinal?: boolean;
|
|
244
|
+
};
|
|
245
|
+
type RuntimeParseOptions = CommonParseOptions<ReadonlyArray<MarkdownPluginEntry>> & {
|
|
246
|
+
math?: boolean;
|
|
247
|
+
isFinal?: boolean;
|
|
248
|
+
};
|
|
249
|
+
type ParseOptionsWithoutPlugins = Omit<ParseOptions, 'plugins'>;
|
|
250
|
+
type MathParseOptionsWithoutPlugins = Omit<MathParseOptions, 'plugins'>;
|
|
251
|
+
type IncrementalParseOptionsWithoutPlugins = Omit<IncrementalParseOptions, 'plugins'>;
|
|
252
|
+
type IncrementalMathParseOptionsWithoutPlugins = Omit<IncrementalMathParseOptions, 'plugins'>;
|
|
233
253
|
export declare function parseInline(text: string, sourceIds?: ReadonlySet<string>): InlineNode[];
|
|
234
|
-
export declare function parseInline(text: string, options:
|
|
235
|
-
export declare function parseInline(text: string, options:
|
|
254
|
+
export declare function parseInline(text: string, options: MathParseOptionsWithoutPlugins): InlineNodeWithMath[];
|
|
255
|
+
export declare function parseInline(text: string, options: ParseOptionsWithoutPlugins): InlineNode[];
|
|
256
|
+
export declare function parseInline<const Plugins extends ReadonlyArray<MarkdownPluginEntry>>(text: string, options: ParseOptionsWithoutPlugins & {
|
|
257
|
+
plugins: Plugins;
|
|
258
|
+
}): InlineNode<MarkdownExtensionsOf<Plugins>>[];
|
|
259
|
+
export declare function parseInline<const Plugins extends ReadonlyArray<MarkdownPluginEntry>>(text: string, options: MathParseOptionsWithoutPlugins & {
|
|
260
|
+
plugins: Plugins;
|
|
261
|
+
}): InlineNodeWithMath<MarkdownExtensionsOf<Plugins>>[];
|
|
262
|
+
/** @internal Canonical inline parse used by Markdown rendering. */
|
|
263
|
+
export declare function parseInlineAst(text: string, arg?: ReadonlySet<string> | RuntimeParseOptions): MarkdownAstPhrasingContent<RuntimeExtensionNode>[];
|
|
236
264
|
export declare function parseMarkdown(input: string, sourceIds?: ReadonlySet<string>): BlockNode[];
|
|
237
|
-
export declare function parseMarkdown(input: string, options:
|
|
238
|
-
export declare function parseMarkdown(input: string, options:
|
|
265
|
+
export declare function parseMarkdown(input: string, options: MathParseOptionsWithoutPlugins): BlockNodeWithMath[];
|
|
266
|
+
export declare function parseMarkdown(input: string, options: ParseOptionsWithoutPlugins): BlockNode[];
|
|
267
|
+
export declare function parseMarkdown<const Plugins extends ReadonlyArray<MarkdownPluginEntry>>(input: string, options: ParseOptionsWithoutPlugins & {
|
|
268
|
+
plugins: Plugins;
|
|
269
|
+
}): BlockNode<MarkdownExtensionsOf<Plugins>>[];
|
|
270
|
+
export declare function parseMarkdown<const Plugins extends ReadonlyArray<MarkdownPluginEntry>>(input: string, options: MathParseOptionsWithoutPlugins & {
|
|
271
|
+
plugins: Plugins;
|
|
272
|
+
}): BlockNodeWithMath<MarkdownExtensionsOf<Plugins>>[];
|
|
273
|
+
/** @internal Canonical block parse used by Markdown and Outline rendering. */
|
|
274
|
+
export declare function parseMarkdownAst(input: string, arg?: ReadonlySet<string> | RuntimeParseOptions, isFinal?: boolean): MarkdownAstRoot<RuntimeExtensionNode>;
|
|
239
275
|
type IncrementalBlockNode<MathEnabled extends boolean> = MathEnabled extends true ? BlockNodeWithMath : BlockNode;
|
|
240
276
|
declare const incrementalStateMode: unique symbol;
|
|
241
277
|
export interface IncrementalState<MathEnabled extends boolean = false> {
|
|
@@ -260,6 +296,10 @@ export interface IncrementalState<MathEnabled extends boolean = false> {
|
|
|
260
296
|
* lack the ranges the caller now asks for, or carry ones it did not.
|
|
261
297
|
*/
|
|
262
298
|
sourceRanges?: boolean;
|
|
299
|
+
/** Identity of citation sources used by settled nodes. */
|
|
300
|
+
sourceIdsKey?: string;
|
|
301
|
+
/** Ordered syntax-only identity used by settled nodes. */
|
|
302
|
+
pluginSyntaxIdentity?: string;
|
|
263
303
|
/**
|
|
264
304
|
* Signature of the link reference definitions the cached `settledBlocks`
|
|
265
305
|
* were parsed with. Definitions are document-global and typically arrive
|
|
@@ -307,10 +347,16 @@ export declare function trimStreamingArtifacts(input: string, options?: {
|
|
|
307
347
|
* the cache is discarded and the whole document is re-parsed.
|
|
308
348
|
*/
|
|
309
349
|
export declare function parseMarkdownIncremental(input: string, state: IncrementalState<false>, sourceIds?: ReadonlySet<string>): BlockNode[];
|
|
310
|
-
export declare function parseMarkdownIncremental(input: string, state: IncrementalState<true>, options:
|
|
311
|
-
export declare function parseMarkdownIncremental(input: string, state: IncrementalState<false>, options:
|
|
312
|
-
|
|
313
|
-
|
|
350
|
+
export declare function parseMarkdownIncremental(input: string, state: IncrementalState<true>, options: IncrementalMathParseOptionsWithoutPlugins): BlockNodeWithMath[];
|
|
351
|
+
export declare function parseMarkdownIncremental(input: string, state: IncrementalState<false>, options: IncrementalParseOptionsWithoutPlugins): BlockNode[];
|
|
352
|
+
export declare function parseMarkdownIncremental<const Plugins extends ReadonlyArray<MarkdownPluginEntry>>(input: string, state: IncrementalState<false>, options: IncrementalParseOptionsWithoutPlugins & {
|
|
353
|
+
plugins: Plugins;
|
|
354
|
+
}): BlockNode<MarkdownExtensionsOf<Plugins>>[];
|
|
355
|
+
export declare function parseMarkdownIncremental<const Plugins extends ReadonlyArray<MarkdownPluginEntry>>(input: string, state: IncrementalState<true>, options: IncrementalMathParseOptionsWithoutPlugins & {
|
|
356
|
+
plugins: Plugins;
|
|
357
|
+
}): BlockNodeWithMath<MarkdownExtensionsOf<Plugins>>[];
|
|
358
|
+
/** @internal Canonical incremental parse used by Markdown rendering. */
|
|
359
|
+
export declare function parseMarkdownAstIncremental(input: string, state: IncrementalState<boolean>, arg?: ReadonlySet<string> | RuntimeParseOptions): MarkdownAstRoot<RuntimeExtensionNode>;
|
|
314
360
|
/** Turn heading text into a URL-safe slug (lowercase, hyphen-separated). */
|
|
315
361
|
export declare function slugify(value: string): string;
|
|
316
362
|
/**
|