notion-to-md 1.0.2 → 1.0.3
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/README.md +2 -2
- package/notion-to-md.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ const n2m = new notion2md({ notionClient: notion });
|
|
|
51
51
|
|
|
52
52
|
(async () => {
|
|
53
53
|
const mdblocks = await n2m.pageToMarkdown("target_page_id");
|
|
54
|
-
const mdString = n2m.
|
|
54
|
+
const mdString = n2m.toMarkdownString(mdblocks);
|
|
55
55
|
|
|
56
56
|
//writing to file
|
|
57
57
|
fs.writeFile("test.md", mdString, (err) => {
|
|
@@ -181,7 +181,7 @@ console.log(result);
|
|
|
181
181
|
|
|
182
182
|
## API
|
|
183
183
|
|
|
184
|
-
### `
|
|
184
|
+
### `toMarkdownString(markdownObjects)`
|
|
185
185
|
|
|
186
186
|
- takes output of `pageToMarkdown` or `blocksToMarkdown` as argument
|
|
187
187
|
- convert to markdown string.
|
package/notion-to-md.js
CHANGED
|
@@ -10,7 +10,7 @@ class notion2md {
|
|
|
10
10
|
this.notionClient = options.notionClient;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
toMarkdownString(mdBlocks = [], nestingLevel = 0) {
|
|
14
14
|
let mdString = "";
|
|
15
15
|
mdBlocks.forEach((mdBlocks) => {
|
|
16
16
|
if (mdBlocks.parent) {
|
|
@@ -19,7 +19,7 @@ ${md.addTabSpace(mdBlocks.parent, nestingLevel)}
|
|
|
19
19
|
`;
|
|
20
20
|
}
|
|
21
21
|
if (mdBlocks.children && mdBlocks.children.length > 0) {
|
|
22
|
-
mdString += this.
|
|
22
|
+
mdString += this.toMarkdownString(mdBlocks.children, nestingLevel + 1);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
return mdString;
|