-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
162 lines (136 loc) · 3.58 KB
/
Copy pathtypes.ts
File metadata and controls
162 lines (136 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types.ts :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dlesieur <dlesieur@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/28 22:27:54 by dlesieur #+# #+# */
/* Updated: 2026/05/11 20:31:35 by dlesieur ### ########.fr */
/* */
/* ************************************************************************** */
export type BlockKind =
| "document"
| "paragraph"
| "heading"
| "code_block"
| "list"
| "list_item"
| "blockquote"
| "thematic_break";
export type InlineKind = "text" | "emphasis" | "strong" | "code_span" | "link";
export interface SourceSpan {
startLine: number;
endLine: number;
startOffset: number;
endOffset: number;
}
export interface BaseNode {
id: string;
kind: BlockKind | InlineKind;
span: SourceSpan;
}
export interface TextNode extends BaseNode {
kind: "text";
value: string;
}
export interface EmphasisNode extends BaseNode {
kind: "emphasis";
children: InlineNode[];
}
export interface StrongNode extends BaseNode {
kind: "strong";
children: InlineNode[];
}
export interface CodeSpanNode extends BaseNode {
kind: "code_span";
value: string;
}
export interface LinkNode extends BaseNode {
kind: "link";
href: string;
children: InlineNode[];
}
export type InlineNode =
| TextNode
| EmphasisNode
| StrongNode
| CodeSpanNode
| LinkNode;
export interface ParagraphNode extends BaseNode {
kind: "paragraph";
children: InlineNode[];
}
export interface HeadingNode extends BaseNode {
kind: "heading";
depth: 1 | 2 | 3 | 4 | 5 | 6;
children: InlineNode[];
}
export interface CodeBlockNode extends BaseNode {
kind: "code_block";
language: string | null;
value: string;
}
export interface ListNode extends BaseNode {
kind: "list";
ordered: boolean;
start: number;
items: ListItemNode[];
}
export interface ListItemNode extends BaseNode {
kind: "list_item";
checked?: boolean;
children: BlockNode[];
}
export interface BlockquoteNode extends BaseNode {
kind: "blockquote";
children: BlockNode[];
}
export interface ThematicBreakNode extends BaseNode {
kind: "thematic_break";
}
export interface DocumentNode extends BaseNode {
kind: "document";
children: BlockNode[];
version: number;
}
export type BlockNode =
| ParagraphNode
| HeadingNode
| CodeBlockNode
| ListNode
| ListItemNode
| BlockquoteNode
| ThematicBreakNode;
export interface ParseOptions {
documentVersion?: number;
}
export type DiagnosticSeverity = "warning" | "error";
export interface ParseDiagnostic {
code: string;
message: string;
severity: DiagnosticSeverity;
span: SourceSpan;
}
export interface ParseResult {
ast: DocumentNode;
blockIndex: BlockRange[];
diagnostics: ParseDiagnostic[];
}
export interface BlockRange {
id: string;
startLine: number;
endLine: number;
}
export interface IncrementalPatch {
fromLine: number;
toLine: number;
text: string;
}
export interface IncrementalParseResult {
text: string;
ast: DocumentNode;
blockIndex: BlockRange[];
changedNodeIds: string[];
diagnostics: ParseDiagnostic[];
}