notion-to-md 2.3.2 → 2.4.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 -21
- package/README.md +204 -205
- package/build/index.d.ts +1 -1
- package/build/index.js +17 -17
- package/build/index.js.map +1 -1
- package/build/notion-to-md.d.ts +43 -43
- package/build/notion-to-md.d.ts.map +1 -1
- package/build/notion-to-md.js +355 -306
- package/build/notion-to-md.js.map +1 -1
- package/build/types/index.d.ts +47 -47
- package/build/types/index.js +2 -2
- package/build/types/index.js.map +1 -1
- package/build/utils/md.d.ts +20 -21
- package/build/utils/md.d.ts.map +1 -1
- package/build/utils/md.js +105 -103
- package/build/utils/md.js.map +1 -1
- package/build/utils/md.spec.d.ts +1 -1
- package/build/utils/md.spec.js +80 -16
- package/build/utils/md.spec.js.map +1 -1
- package/build/utils/notion.d.ts +5 -5
- package/build/utils/notion.d.ts.map +1 -1
- package/build/utils/notion.js +26 -25
- package/build/utils/notion.js.map +1 -1
- package/package.json +51 -47
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 Souvik Kar Mahapatra
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Souvik Kar Mahapatra
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,205 +1,204 @@
|
|
|
1
|
-
<img src="https://imgur.com/WgXdz9r.png" />
|
|
2
|
-
|
|
3
|
-
> 💡 For better readability and detailed instructions headover to the [wiki](https://github.com/souvikinator/notion-to-md/wiki)
|
|
4
|
-
|
|
5
|
-
# Notion to Markdown
|
|
6
|
-
|
|
7
|
-
Convert notion pages, block and list of blocks to markdown (supports nesting) using **[notion-sdk-js](https://github.com/makenotion/notion-sdk-js)**
|
|
8
|
-
|
|
9
|
-
> **Note:** Before getting started, create [an integration and find the token](https://www.notion.so/my-integrations).
|
|
10
|
-
|
|
11
|
-
[](https://ko-fi.com/O5O1AFCJR)
|
|
12
|
-
|
|
13
|
-
## Todo
|
|
14
|
-
|
|
15
|
-
- [x] heading
|
|
16
|
-
- [x] images
|
|
17
|
-
- [x] quotes
|
|
18
|
-
- [x] links
|
|
19
|
-
- [x] bullets
|
|
20
|
-
- [x] todo
|
|
21
|
-
- [x] inline code
|
|
22
|
-
- [x] code block
|
|
23
|
-
- [x] strikethrough, underline, bold, italic
|
|
24
|
-
- [x] nested blocks
|
|
25
|
-
- [
|
|
26
|
-
- [x]
|
|
27
|
-
- [x]
|
|
28
|
-
- [x]
|
|
29
|
-
- [x]
|
|
30
|
-
- [x]
|
|
31
|
-
- [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const {
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const {
|
|
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
|
-
const {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
-
|
|
179
|
-
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
[MIT](https://choosealicense.com/licenses/mit/)
|
|
1
|
+
<img src="https://imgur.com/WgXdz9r.png" />
|
|
2
|
+
|
|
3
|
+
> 💡 For better readability and detailed instructions headover to the [wiki](https://github.com/souvikinator/notion-to-md/wiki)
|
|
4
|
+
|
|
5
|
+
# Notion to Markdown
|
|
6
|
+
|
|
7
|
+
Convert notion pages, block and list of blocks to markdown (supports nesting) using **[notion-sdk-js](https://github.com/makenotion/notion-sdk-js)**
|
|
8
|
+
|
|
9
|
+
> **Note:** Before getting started, create [an integration and find the token](https://www.notion.so/my-integrations).
|
|
10
|
+
|
|
11
|
+
[](https://ko-fi.com/O5O1AFCJR)
|
|
12
|
+
|
|
13
|
+
## Todo
|
|
14
|
+
|
|
15
|
+
- [x] heading
|
|
16
|
+
- [x] images
|
|
17
|
+
- [x] quotes
|
|
18
|
+
- [x] links
|
|
19
|
+
- [x] bullets
|
|
20
|
+
- [x] todo
|
|
21
|
+
- [x] inline code
|
|
22
|
+
- [x] code block
|
|
23
|
+
- [x] strikethrough, underline, bold, italic
|
|
24
|
+
- [x] nested blocks
|
|
25
|
+
- [x] embeds, bookmarks, videos, files (converted to links)
|
|
26
|
+
- [x] Simple tables
|
|
27
|
+
- [x] divider
|
|
28
|
+
- [x] equation block (converted to code blocks)
|
|
29
|
+
- [x] convert returned markdown object to string (`toMarkdownString()`)
|
|
30
|
+
- [x] typescript support
|
|
31
|
+
- [ ] add tests
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```Bash
|
|
36
|
+
$ npm install notion-to-md
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
> **Note:** Details on methods can be found in [API section](https://github.com/souvikinator/notion-to-md#api)
|
|
42
|
+
|
|
43
|
+
### converting markdown objects to markdown string
|
|
44
|
+
|
|
45
|
+
This is how the notion page looks for this example:
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
const { Client } = require("@notionhq/client");
|
|
51
|
+
const { NotionToMarkdown } = require("notion-to-md");
|
|
52
|
+
// or
|
|
53
|
+
// import {NotionToMarkdown} from "notion-to-md";
|
|
54
|
+
|
|
55
|
+
const notion = new Client({
|
|
56
|
+
auth: "your integration token",
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// passing notion client to the option
|
|
60
|
+
const n2m = new NotionToMarkdown({ notionClient: notion });
|
|
61
|
+
|
|
62
|
+
(async () => {
|
|
63
|
+
const mdblocks = await n2m.pageToMarkdown("target_page_id");
|
|
64
|
+
const mdString = n2m.toMarkdownString(mdblocks);
|
|
65
|
+
|
|
66
|
+
//writing to file
|
|
67
|
+
fs.writeFile("test.md", mdString, (err) => {
|
|
68
|
+
console.log(err);
|
|
69
|
+
});
|
|
70
|
+
})();
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Output:**
|
|
74
|
+
|
|
75
|
+

|
|
76
|
+
|
|
77
|
+
### converting page to markdown object
|
|
78
|
+
|
|
79
|
+
Example notion page:
|
|
80
|
+
|
|
81
|
+

|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
const { Client } = require("@notionhq/client");
|
|
85
|
+
const { NotionToMarkdown } = require("notion-to-md");
|
|
86
|
+
|
|
87
|
+
const notion = new Client({
|
|
88
|
+
auth: "your integration token",
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// passing notion client to the option
|
|
92
|
+
const n2m = new NotionToMarkdown({ notionClient: notion });
|
|
93
|
+
|
|
94
|
+
(async () => {
|
|
95
|
+
// notice second argument, totalPage.
|
|
96
|
+
const x = await n2m.pageToMarkdown("target_page_id", 2);
|
|
97
|
+
console.log(x);
|
|
98
|
+
})();
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Output:**
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
[
|
|
105
|
+
{
|
|
106
|
+
"parent": "# heading 1",
|
|
107
|
+
"children": []
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"parent": "- bullet 1",
|
|
111
|
+
"children": [
|
|
112
|
+
{
|
|
113
|
+
"parent": "- bullet 1.1",
|
|
114
|
+
"children": []
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"parent": "- bullet 1.2",
|
|
118
|
+
"children": []
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"parent": "- bullet 2",
|
|
124
|
+
"children": []
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"parent": "- [ ] check box 1",
|
|
128
|
+
"children": [
|
|
129
|
+
{
|
|
130
|
+
"parent": "- [x] check box 1.2",
|
|
131
|
+
"children": []
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"parent": "- [ ] check box 1.3",
|
|
135
|
+
"children": []
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"parent": "- [ ] checkbox 2",
|
|
141
|
+
"children": []
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### converting list of blocks to markdown object
|
|
147
|
+
|
|
148
|
+
same notion page as before
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
const { Client } = require("@notionhq/client");
|
|
152
|
+
const { NotionToMarkdown } = require("notion-to-md");
|
|
153
|
+
|
|
154
|
+
const notion = new Client({
|
|
155
|
+
auth: "your integration token",
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// passing notion client to the option
|
|
159
|
+
const n2m = new NotionToMarkdown({ notionClient: notion });
|
|
160
|
+
|
|
161
|
+
(async () => {
|
|
162
|
+
// get all blocks in the page
|
|
163
|
+
const { results } = await notion.blocks.children.list({
|
|
164
|
+
block_id,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
//convert to markdown
|
|
168
|
+
const x = await n2m.blocksToMarkdown(results);
|
|
169
|
+
console.log(x);
|
|
170
|
+
})();
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Output**: same as before
|
|
174
|
+
|
|
175
|
+
### Converting a single block to markdown string
|
|
176
|
+
|
|
177
|
+
- only takes a single notion block and returns corresponding markdown string
|
|
178
|
+
- nesting is ignored
|
|
179
|
+
- depends on @notionhq/client
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
const { NotionToMarkdown } = require("notion-to-md");
|
|
183
|
+
|
|
184
|
+
// passing notion client to the option
|
|
185
|
+
const n2m = new NotionToMarkdown({ notionClient: notion });
|
|
186
|
+
|
|
187
|
+
const result = n2m.blockToMarkdown(block);
|
|
188
|
+
console.log(result);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**result**:
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+

|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Contribution
|
|
198
|
+
|
|
199
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
200
|
+
Please make sure to update tests as appropriate.
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
package/build/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./notion-to-md";
|
|
1
|
+
export * from "./notion-to-md";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./notion-to-md"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./notion-to-md"), exports);
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B","sourcesContent":["export * from \"./notion-to-md\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B","sourcesContent":["export * from \"./notion-to-md\";\r\n"]}
|
package/build/notion-to-md.d.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { Annotations, ListBlockChildrenResponseResult, ListBlockChildrenResponseResults, MdBlock, NotionToMarkdownOptions } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Converts a Notion page to Markdown.
|
|
4
|
-
*/
|
|
5
|
-
export declare class NotionToMarkdown {
|
|
6
|
-
private notionClient;
|
|
7
|
-
constructor(options: NotionToMarkdownOptions);
|
|
8
|
-
/**
|
|
9
|
-
* Converts Markdown Blocks to string
|
|
10
|
-
* @param {MdBlock[]} mdBlocks - Array of markdown blocks
|
|
11
|
-
* @param {number} nestingLevel - Defines max depth of nesting
|
|
12
|
-
* @returns {string} - Returns markdown string
|
|
13
|
-
*/
|
|
14
|
-
toMarkdownString(mdBlocks?: MdBlock[], nestingLevel?: number): string;
|
|
15
|
-
/**
|
|
16
|
-
* Retrieves Notion Blocks based on ID and converts them to Markdown Blocks
|
|
17
|
-
* @param {string} id - notion page id (not database id)
|
|
18
|
-
* @param {number} totalPage - Retrieve block children request number, page_size Maximum = totalPage * 100 (Default=null)
|
|
19
|
-
* @returns {Promise<MdBlock[]>} - List of markdown blocks
|
|
20
|
-
*/
|
|
21
|
-
pageToMarkdown(id: string, totalPage?: number | null): Promise<MdBlock[]>;
|
|
22
|
-
/**
|
|
23
|
-
* Converts list of Notion Blocks to Markdown Blocks
|
|
24
|
-
* @param {ListBlockChildrenResponseResults | undefined} blocks - List of notion blocks
|
|
25
|
-
* @param {number} totalPage - Retrieve block children request number, page_size Maximum = totalPage * 100
|
|
26
|
-
* @param {MdBlock[]} mdBlocks - Defines max depth of nesting
|
|
27
|
-
* @returns {Promise<MdBlock[]>} - Array of markdown blocks with their children
|
|
28
|
-
*/
|
|
29
|
-
blocksToMarkdown(blocks?: ListBlockChildrenResponseResults, totalPage?: number | null, mdBlocks?: MdBlock[]): Promise<MdBlock[]>;
|
|
30
|
-
/**
|
|
31
|
-
* Converts a Notion Block to a Markdown Block
|
|
32
|
-
* @param {ListBlockChildrenResponseResult} block - single notion block
|
|
33
|
-
* @returns {string} corresponding markdown string of the passed block
|
|
34
|
-
*/
|
|
35
|
-
blockToMarkdown(block: ListBlockChildrenResponseResult): Promise<string>;
|
|
36
|
-
/**
|
|
37
|
-
* Annoate text using provided annotations
|
|
38
|
-
* @param {string} text - String to be annotated
|
|
39
|
-
* @param {Annotations} annotations - Annotation object of a notion block
|
|
40
|
-
* @returns {string} - Annotated text
|
|
41
|
-
*/
|
|
42
|
-
annotatePlainText(text: string, annotations: Annotations): string;
|
|
43
|
-
}
|
|
1
|
+
import { Annotations, ListBlockChildrenResponseResult, ListBlockChildrenResponseResults, MdBlock, NotionToMarkdownOptions } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a Notion page to Markdown.
|
|
4
|
+
*/
|
|
5
|
+
export declare class NotionToMarkdown {
|
|
6
|
+
private notionClient;
|
|
7
|
+
constructor(options: NotionToMarkdownOptions);
|
|
8
|
+
/**
|
|
9
|
+
* Converts Markdown Blocks to string
|
|
10
|
+
* @param {MdBlock[]} mdBlocks - Array of markdown blocks
|
|
11
|
+
* @param {number} nestingLevel - Defines max depth of nesting
|
|
12
|
+
* @returns {string} - Returns markdown string
|
|
13
|
+
*/
|
|
14
|
+
toMarkdownString(mdBlocks?: MdBlock[], nestingLevel?: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves Notion Blocks based on ID and converts them to Markdown Blocks
|
|
17
|
+
* @param {string} id - notion page id (not database id)
|
|
18
|
+
* @param {number} totalPage - Retrieve block children request number, page_size Maximum = totalPage * 100 (Default=null)
|
|
19
|
+
* @returns {Promise<MdBlock[]>} - List of markdown blocks
|
|
20
|
+
*/
|
|
21
|
+
pageToMarkdown(id: string, totalPage?: number | null): Promise<MdBlock[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Converts list of Notion Blocks to Markdown Blocks
|
|
24
|
+
* @param {ListBlockChildrenResponseResults | undefined} blocks - List of notion blocks
|
|
25
|
+
* @param {number} totalPage - Retrieve block children request number, page_size Maximum = totalPage * 100
|
|
26
|
+
* @param {MdBlock[]} mdBlocks - Defines max depth of nesting
|
|
27
|
+
* @returns {Promise<MdBlock[]>} - Array of markdown blocks with their children
|
|
28
|
+
*/
|
|
29
|
+
blocksToMarkdown(blocks?: ListBlockChildrenResponseResults, totalPage?: number | null, mdBlocks?: MdBlock[]): Promise<MdBlock[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Converts a Notion Block to a Markdown Block
|
|
32
|
+
* @param {ListBlockChildrenResponseResult} block - single notion block
|
|
33
|
+
* @returns {string} corresponding markdown string of the passed block
|
|
34
|
+
*/
|
|
35
|
+
blockToMarkdown(block: ListBlockChildrenResponseResult): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Annoate text using provided annotations
|
|
38
|
+
* @param {string} text - String to be annotated
|
|
39
|
+
* @param {Annotations} annotations - Annotation object of a notion block
|
|
40
|
+
* @returns {string} - Annotated text
|
|
41
|
+
*/
|
|
42
|
+
annotatePlainText(text: string, annotations: Annotations): string;
|
|
43
|
+
}
|
|
44
44
|
//# sourceMappingURL=notion-to-md.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notion-to-md.d.ts","sourceRoot":"","sources":["../src/notion-to-md.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,gCAAgC,EAChC,OAAO,EAEP,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAIjB;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,YAAY,CAAS;gBAEjB,OAAO,EAAE,uBAAuB;IAI5C;;;;;OAKG;IACH,gBAAgB,CAAC,QAAQ,GAAE,OAAO,EAAO,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM;IAe5E;;;;;OAKG;IACG,cAAc,CAClB,EAAE,EAAE,MAAM,EACV,SAAS,GAAE,MAAM,GAAG,IAAW,GAC9B,OAAO,CAAC,OAAO,EAAE,CAAC;IAarB;;;;;;OAMG;IACG,gBAAgB,CACpB,MAAM,CAAC,EAAE,gCAAgC,EACzC,SAAS,GAAE,MAAM,GAAG,IAAW,EAC/B,QAAQ,GAAE,OAAO,EAAO,GACvB,OAAO,CAAC,OAAO,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"notion-to-md.d.ts","sourceRoot":"","sources":["../src/notion-to-md.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,gCAAgC,EAChC,OAAO,EAEP,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAIjB;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,YAAY,CAAS;gBAEjB,OAAO,EAAE,uBAAuB;IAI5C;;;;;OAKG;IACH,gBAAgB,CAAC,QAAQ,GAAE,OAAO,EAAO,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM;IAe5E;;;;;OAKG;IACG,cAAc,CAClB,EAAE,EAAE,MAAM,EACV,SAAS,GAAE,MAAM,GAAG,IAAW,GAC9B,OAAO,CAAC,OAAO,EAAE,CAAC;IAarB;;;;;;OAMG;IACG,gBAAgB,CACpB,MAAM,CAAC,EAAE,gCAAgC,EACzC,SAAS,GAAE,MAAM,GAAG,IAAW,EAC/B,QAAQ,GAAE,OAAO,EAAO,GACvB,OAAO,CAAC,OAAO,EAAE,CAAC;IA0CrB;;;;OAIG;IACG,eAAe,CAAC,KAAK,EAAE,+BAA+B;IAmR5D;;;;;OAKG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,MAAM;CAsBlE"}
|