notion-to-md 1.0.3 → 1.0.4
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 +5 -3
- package/notion-to-md.js +18 -2
- package/package.json +1 -1
- package/utils/md.js +4 -0
package/README.md
CHANGED
|
@@ -18,10 +18,12 @@ Convert notion pages, block and list of blocks to markdown (supports nesting) us
|
|
|
18
18
|
- [x] code block
|
|
19
19
|
- [x] strikethrough, underline, bold, italic
|
|
20
20
|
- [x] nested blocks
|
|
21
|
-
- [ ]
|
|
21
|
+
- [ ] pages inside pages/child page
|
|
22
|
+
- [x] embeds, bookmarks, videos, files (converted to links)
|
|
22
23
|
- [ ] tables
|
|
23
|
-
- [
|
|
24
|
-
- [x]
|
|
24
|
+
- [x] divider
|
|
25
|
+
- [x] equation block (converted to code blocks)
|
|
26
|
+
- [x] convert returned markdown object to string (`toMarkdownString()`)
|
|
25
27
|
- [ ] add tests
|
|
26
28
|
|
|
27
29
|
## Install
|
package/notion-to-md.js
CHANGED
|
@@ -47,7 +47,7 @@ ${md.addTabSpace(mdBlocks.parent, nestingLevel)}
|
|
|
47
47
|
continue;
|
|
48
48
|
}
|
|
49
49
|
let tmp = this.blockToMarkdown(block);
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
mdBlocks.push({ parent: tmp, children: [] });
|
|
52
52
|
}
|
|
53
53
|
return mdBlocks;
|
|
@@ -66,6 +66,23 @@ ${md.addTabSpace(mdBlocks.parent, nestingLevel)}
|
|
|
66
66
|
const image_type = blockContent["type"];
|
|
67
67
|
|
|
68
68
|
return md.image("image", blockContent[image_type].url);
|
|
69
|
+
} else if (type === "divider") {
|
|
70
|
+
return md.divider();
|
|
71
|
+
} else if (type === "equation") {
|
|
72
|
+
return md.codeBlock(block[type].expression);
|
|
73
|
+
} else if (type === "video" || type === "file" || type === "pdf") {
|
|
74
|
+
blockContent = block[type];
|
|
75
|
+
const urlType = blockContent["type"];
|
|
76
|
+
|
|
77
|
+
return md.link(type, blockContent[urlType].url);
|
|
78
|
+
} else if (
|
|
79
|
+
type === "bookmark" ||
|
|
80
|
+
type === "embed" ||
|
|
81
|
+
type === "link_preview"
|
|
82
|
+
) {
|
|
83
|
+
blockContent = block[type];
|
|
84
|
+
|
|
85
|
+
return md.link(type, blockContent.url);
|
|
69
86
|
} else {
|
|
70
87
|
blockContent = block[type]["text"] || [];
|
|
71
88
|
blockContent.map((content) => {
|
|
@@ -80,7 +97,6 @@ ${md.addTabSpace(mdBlocks.parent, nestingLevel)}
|
|
|
80
97
|
});
|
|
81
98
|
}
|
|
82
99
|
|
|
83
|
-
// TODO: need to take care of escape sequences
|
|
84
100
|
if (type === "code") parsedData = md.codeBlock(parsedData);
|
|
85
101
|
if (type === "heading_1") parsedData = md.heading1(parsedData);
|
|
86
102
|
if (type === "heading_2") parsedData = md.heading2(parsedData);
|
package/package.json
CHANGED