@nast/nast2typst 0.2.0 → 0.3.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/{index-CgBLzCnj.d.ts → index.d.ts} +213 -103
- package/dist/index.js +1 -1
- package/package.json +4 -3
|
@@ -1,112 +1,94 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region ../types/dist/nast.d.ts
|
|
2
|
+
//#region src/nast.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* NAST (Notion Abstract Syntax Tree) Types
|
|
5
|
+
*
|
|
6
|
+
* NAST is a unified-like AST format for representing Notion content.
|
|
7
|
+
* It's designed to be easily converted to various output formats (Markdown, Typst, etc.)
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Root node of a NAST document
|
|
11
|
+
*/
|
|
2
12
|
interface NASTRoot {
|
|
3
|
-
type:
|
|
13
|
+
type: 'root';
|
|
4
14
|
children: NASTNode[];
|
|
5
15
|
data: {
|
|
6
16
|
pageId: string;
|
|
7
17
|
title: string;
|
|
8
18
|
icon?: {
|
|
9
|
-
type:
|
|
19
|
+
type: 'emoji' | 'file' | 'external';
|
|
10
20
|
value: string;
|
|
11
21
|
};
|
|
12
22
|
processedAt: string;
|
|
13
23
|
};
|
|
14
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Union of all NAST node types
|
|
27
|
+
*/
|
|
15
28
|
type NASTNode = NASTParagraph | NASTHeading | NASTText | NASTStrong | NASTEmphasis | NASTUnderline | NASTDelete | NASTInlineCode | NASTLink | NASTMention | NASTMath | NASTInlineMath | NASTCode | NASTBlockquote | NASTCallout | NASTToggle | NASTList | NASTListItem | NASTColumnList | NASTColumn | NASTImage | NASTThematicBreak | NASTTable | NASTTableRow | NASTTableCell | NASTChildPage | NASTVideo | NASTFile | NASTPDF | NASTBookmark | NASTEmbed;
|
|
29
|
+
/**
|
|
30
|
+
* Paragraph block
|
|
31
|
+
*/
|
|
16
32
|
interface NASTParagraph {
|
|
17
|
-
type:
|
|
33
|
+
type: 'paragraph';
|
|
18
34
|
children: NASTNode[];
|
|
19
35
|
data?: {
|
|
20
36
|
blockId?: string;
|
|
21
37
|
};
|
|
22
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Heading block (h1, h2, h3)
|
|
41
|
+
*/
|
|
23
42
|
interface NASTHeading {
|
|
24
|
-
type:
|
|
43
|
+
type: 'heading';
|
|
25
44
|
depth: 1 | 2 | 3;
|
|
26
45
|
children: NASTNode[];
|
|
46
|
+
/** Indicates if this heading is also a toggle (collapsible) */
|
|
27
47
|
isToggleable?: boolean;
|
|
28
48
|
data?: {
|
|
29
49
|
blockId?: string;
|
|
30
50
|
};
|
|
31
51
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
interface NASTStrong {
|
|
41
|
-
type: "strong";
|
|
42
|
-
children: NASTNode[];
|
|
43
|
-
}
|
|
44
|
-
interface NASTEmphasis {
|
|
45
|
-
type: "emphasis";
|
|
46
|
-
children: NASTNode[];
|
|
47
|
-
}
|
|
48
|
-
interface NASTUnderline {
|
|
49
|
-
type: "underline";
|
|
50
|
-
children: NASTNode[];
|
|
51
|
-
}
|
|
52
|
-
interface NASTDelete {
|
|
53
|
-
type: "delete";
|
|
54
|
-
children: NASTNode[];
|
|
55
|
-
}
|
|
56
|
-
interface NASTInlineCode {
|
|
57
|
-
type: "inlineCode";
|
|
58
|
-
value: string;
|
|
59
|
-
}
|
|
60
|
-
interface NASTLink {
|
|
61
|
-
type: "link";
|
|
62
|
-
url: string;
|
|
63
|
-
children: NASTNode[];
|
|
64
|
-
data?: {
|
|
65
|
-
title?: string;
|
|
66
|
-
iconUrl?: string;
|
|
67
|
-
description?: string;
|
|
68
|
-
provider?: string;
|
|
69
|
-
thumbnailUrl?: string;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
interface NASTMention {
|
|
73
|
-
type: "mention";
|
|
74
|
-
mentionType: "user" | "date" | "page" | "database";
|
|
75
|
-
value: string;
|
|
76
|
-
data: unknown;
|
|
77
|
-
}
|
|
78
|
-
interface NASTMath {
|
|
79
|
-
type: "math";
|
|
52
|
+
/**
|
|
53
|
+
* Code block with syntax highlighting
|
|
54
|
+
*/
|
|
55
|
+
interface NASTCode {
|
|
56
|
+
type: 'code';
|
|
57
|
+
lang: string;
|
|
80
58
|
value: string;
|
|
81
59
|
data?: {
|
|
60
|
+
caption?: NASTNode[];
|
|
82
61
|
blockId?: string;
|
|
83
62
|
};
|
|
84
63
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
type: "code";
|
|
91
|
-
lang: string;
|
|
64
|
+
/**
|
|
65
|
+
* Block math equation
|
|
66
|
+
*/
|
|
67
|
+
interface NASTMath {
|
|
68
|
+
type: 'math';
|
|
92
69
|
value: string;
|
|
93
70
|
data?: {
|
|
94
|
-
caption?: NASTNode[];
|
|
95
71
|
blockId?: string;
|
|
96
72
|
};
|
|
97
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Blockquote
|
|
76
|
+
*/
|
|
98
77
|
interface NASTBlockquote {
|
|
99
|
-
type:
|
|
78
|
+
type: 'blockquote';
|
|
100
79
|
children: NASTNode[];
|
|
101
80
|
data?: {
|
|
102
81
|
blockId?: string;
|
|
103
82
|
};
|
|
104
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Callout block (with icon and color)
|
|
86
|
+
*/
|
|
105
87
|
interface NASTCallout {
|
|
106
|
-
type:
|
|
88
|
+
type: 'callout';
|
|
107
89
|
data: {
|
|
108
90
|
icon: {
|
|
109
|
-
type:
|
|
91
|
+
type: 'emoji';
|
|
110
92
|
value: string;
|
|
111
93
|
} | null;
|
|
112
94
|
color: string;
|
|
@@ -114,61 +96,72 @@ interface NASTCallout {
|
|
|
114
96
|
};
|
|
115
97
|
children: NASTNode[];
|
|
116
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Toggle block (collapsible content)
|
|
101
|
+
*/
|
|
117
102
|
interface NASTToggle {
|
|
118
|
-
type:
|
|
103
|
+
type: 'toggle';
|
|
119
104
|
children: NASTNode[];
|
|
120
105
|
data?: {
|
|
121
106
|
blockId?: string;
|
|
122
107
|
};
|
|
123
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Thematic break / divider
|
|
111
|
+
*/
|
|
112
|
+
interface NASTThematicBreak {
|
|
113
|
+
type: 'thematicBreak';
|
|
114
|
+
data?: {
|
|
115
|
+
blockId?: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* List (ordered or unordered)
|
|
120
|
+
*/
|
|
124
121
|
interface NASTList {
|
|
125
|
-
type:
|
|
122
|
+
type: 'list';
|
|
126
123
|
ordered: boolean;
|
|
127
124
|
children: NASTListItem[];
|
|
128
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* List item (can be a checklist item if checked is defined)
|
|
128
|
+
*/
|
|
129
129
|
interface NASTListItem {
|
|
130
|
-
type:
|
|
130
|
+
type: 'listItem';
|
|
131
|
+
/** undefined = not a checklist, true/false = checked state */
|
|
132
|
+
checked?: boolean;
|
|
131
133
|
children: NASTNode[];
|
|
132
|
-
checked?: boolean | undefined;
|
|
133
134
|
data?: {
|
|
134
135
|
blockId?: string;
|
|
135
136
|
};
|
|
136
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Column list (container for columns)
|
|
140
|
+
*/
|
|
137
141
|
interface NASTColumnList {
|
|
138
|
-
type:
|
|
142
|
+
type: 'columnList';
|
|
139
143
|
children: NASTColumn[];
|
|
140
144
|
data?: {
|
|
141
145
|
blockId?: string;
|
|
142
146
|
};
|
|
143
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Column within a column list
|
|
150
|
+
*/
|
|
144
151
|
interface NASTColumn {
|
|
145
|
-
type:
|
|
152
|
+
type: 'column';
|
|
153
|
+
/** Width ratio (0.5 = 50%, matches NBT format) */
|
|
146
154
|
widthRatio: number;
|
|
147
155
|
children: NASTNode[];
|
|
148
156
|
data?: {
|
|
149
157
|
blockId?: string;
|
|
150
158
|
};
|
|
151
159
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
title: string | null | undefined;
|
|
156
|
-
alt: string | null | undefined;
|
|
157
|
-
data: {
|
|
158
|
-
fileType: "file" | "external";
|
|
159
|
-
expiryTime?: string;
|
|
160
|
-
caption?: NASTNode[];
|
|
161
|
-
blockId?: string;
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
interface NASTThematicBreak {
|
|
165
|
-
type: "thematicBreak";
|
|
166
|
-
data?: {
|
|
167
|
-
blockId?: string;
|
|
168
|
-
};
|
|
169
|
-
}
|
|
160
|
+
/**
|
|
161
|
+
* Table
|
|
162
|
+
*/
|
|
170
163
|
interface NASTTable {
|
|
171
|
-
type:
|
|
164
|
+
type: 'table';
|
|
172
165
|
hasColumnHeader: boolean;
|
|
173
166
|
hasRowHeader: boolean;
|
|
174
167
|
children: NASTTableRow[];
|
|
@@ -176,69 +169,186 @@ interface NASTTable {
|
|
|
176
169
|
blockId?: string;
|
|
177
170
|
};
|
|
178
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Table row
|
|
174
|
+
*/
|
|
179
175
|
interface NASTTableRow {
|
|
180
|
-
type:
|
|
176
|
+
type: 'tableRow';
|
|
181
177
|
children: NASTTableCell[];
|
|
182
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Table cell
|
|
181
|
+
*/
|
|
183
182
|
interface NASTTableCell {
|
|
184
|
-
type:
|
|
183
|
+
type: 'tableCell';
|
|
185
184
|
children: NASTNode[];
|
|
186
185
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Plain text
|
|
188
|
+
*/
|
|
189
|
+
interface NASTText {
|
|
190
|
+
type: 'text';
|
|
191
|
+
value: string;
|
|
191
192
|
data?: {
|
|
193
|
+
color?: string;
|
|
194
|
+
backgroundColor?: string;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Bold text
|
|
199
|
+
*/
|
|
200
|
+
interface NASTStrong {
|
|
201
|
+
type: 'strong';
|
|
202
|
+
children: NASTNode[];
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Italic text
|
|
206
|
+
*/
|
|
207
|
+
interface NASTEmphasis {
|
|
208
|
+
type: 'emphasis';
|
|
209
|
+
children: NASTNode[];
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Underlined text
|
|
213
|
+
*/
|
|
214
|
+
interface NASTUnderline {
|
|
215
|
+
type: 'underline';
|
|
216
|
+
children: NASTNode[];
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Strikethrough text
|
|
220
|
+
*/
|
|
221
|
+
interface NASTDelete {
|
|
222
|
+
type: 'delete';
|
|
223
|
+
children: NASTNode[];
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Inline code
|
|
227
|
+
*/
|
|
228
|
+
interface NASTInlineCode {
|
|
229
|
+
type: 'inlineCode';
|
|
230
|
+
value: string;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Inline math equation
|
|
234
|
+
*/
|
|
235
|
+
interface NASTInlineMath {
|
|
236
|
+
type: 'inlineMath';
|
|
237
|
+
value: string;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Link
|
|
241
|
+
*/
|
|
242
|
+
interface NASTLink {
|
|
243
|
+
type: 'link';
|
|
244
|
+
url: string;
|
|
245
|
+
children: NASTNode[];
|
|
246
|
+
data?: {
|
|
247
|
+
title?: string;
|
|
248
|
+
iconUrl?: string;
|
|
249
|
+
description?: string;
|
|
250
|
+
provider?: string;
|
|
251
|
+
thumbnailUrl?: string;
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Mention (@user, date, page, database)
|
|
256
|
+
*/
|
|
257
|
+
interface NASTMention {
|
|
258
|
+
type: 'mention';
|
|
259
|
+
mentionType: 'user' | 'date' | 'page' | 'database';
|
|
260
|
+
value: string;
|
|
261
|
+
data: unknown;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Image
|
|
265
|
+
*/
|
|
266
|
+
interface NASTImage {
|
|
267
|
+
type: 'image';
|
|
268
|
+
url: string;
|
|
269
|
+
title: string | null | undefined;
|
|
270
|
+
alt: string | null | undefined;
|
|
271
|
+
data: {
|
|
272
|
+
fileType: 'file' | 'external';
|
|
273
|
+
expiryTime?: string;
|
|
274
|
+
caption?: NASTNode[];
|
|
192
275
|
blockId?: string;
|
|
193
276
|
};
|
|
194
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Video
|
|
280
|
+
*/
|
|
195
281
|
interface NASTVideo {
|
|
196
|
-
type:
|
|
282
|
+
type: 'video';
|
|
197
283
|
url: string;
|
|
198
284
|
data: {
|
|
199
|
-
fileType:
|
|
285
|
+
fileType: 'file' | 'external';
|
|
200
286
|
expiryTime?: string;
|
|
201
287
|
caption?: NASTNode[];
|
|
202
288
|
blockId?: string;
|
|
203
289
|
};
|
|
204
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* File attachment
|
|
293
|
+
*/
|
|
205
294
|
interface NASTFile {
|
|
206
|
-
type:
|
|
295
|
+
type: 'file';
|
|
207
296
|
url: string;
|
|
208
297
|
name: string;
|
|
209
298
|
data: {
|
|
210
|
-
fileType:
|
|
299
|
+
fileType: 'file' | 'external';
|
|
211
300
|
expiryTime?: string;
|
|
212
301
|
caption?: NASTNode[];
|
|
213
302
|
blockId?: string;
|
|
214
303
|
};
|
|
215
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* PDF embed
|
|
307
|
+
*/
|
|
216
308
|
interface NASTPDF {
|
|
217
|
-
type:
|
|
309
|
+
type: 'pdf';
|
|
218
310
|
url: string;
|
|
219
311
|
data: {
|
|
220
|
-
fileType:
|
|
312
|
+
fileType: 'file' | 'external';
|
|
221
313
|
expiryTime?: string;
|
|
222
314
|
caption?: NASTNode[];
|
|
223
315
|
blockId?: string;
|
|
224
316
|
};
|
|
225
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Bookmark (link with preview)
|
|
320
|
+
*/
|
|
226
321
|
interface NASTBookmark {
|
|
227
|
-
type:
|
|
322
|
+
type: 'bookmark';
|
|
228
323
|
url: string;
|
|
229
324
|
data?: {
|
|
230
325
|
caption?: NASTNode[];
|
|
231
326
|
blockId?: string;
|
|
232
327
|
};
|
|
233
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Generic embed
|
|
331
|
+
*/
|
|
234
332
|
interface NASTEmbed {
|
|
235
|
-
type:
|
|
333
|
+
type: 'embed';
|
|
236
334
|
url: string;
|
|
237
335
|
data?: {
|
|
238
336
|
caption?: NASTNode[];
|
|
239
337
|
blockId?: string;
|
|
240
338
|
};
|
|
241
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Child page reference
|
|
342
|
+
*/
|
|
343
|
+
interface NASTChildPage {
|
|
344
|
+
type: 'childPage';
|
|
345
|
+
title: string;
|
|
346
|
+
pageId: string;
|
|
347
|
+
data?: {
|
|
348
|
+
blockId?: string;
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
//#endregion
|
|
242
352
|
//#endregion
|
|
243
353
|
//#region src/index.d.ts
|
|
244
354
|
/**
|
package/dist/index.js
CHANGED
|
@@ -258,7 +258,7 @@ function handleToggle(node, context) {
|
|
|
258
258
|
}
|
|
259
259
|
const toggleBody = node.children.slice(bodyStartIndex).map((child) => processNode(child, context)).join("");
|
|
260
260
|
const toggleParams = headingParam ? `${headingParam}` : "";
|
|
261
|
-
return `// Toggle block\n${toggleParams ? `#toggle(${toggleParams})` : "#toggle"}[${toggleTitle}${isHeadingToggle ? "\n" : ""}][${toggleBody}]`;
|
|
261
|
+
return `// Toggle block\n${toggleParams ? `#toggle(${toggleParams})` : "#toggle"}[${toggleTitle}${isHeadingToggle ? "\n" : ""}][${toggleBody}]\n`;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nast/nast2typst",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"description": "Converts NAST (unified-like Notion Abstract Syntax Tree) to Typst markup language.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"notion",
|
|
@@ -31,13 +31,14 @@
|
|
|
31
31
|
},
|
|
32
32
|
"main": "./dist/index.js",
|
|
33
33
|
"module": "./dist/index.js",
|
|
34
|
-
"types": "./dist/index
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
35
|
"files": [
|
|
36
36
|
"dist",
|
|
37
37
|
"README.md"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"tex2typst": "^0.5.6"
|
|
40
|
+
"tex2typst": "^0.5.6",
|
|
41
|
+
"@nast/types": "0.1.0"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"build": "tsdown",
|