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 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
- - [ ] embeds
21
+ - [ ] pages inside pages/child page
22
+ - [x] embeds, bookmarks, videos, files (converted to links)
22
23
  - [ ] tables
23
- - [ ] videos
24
- - [x] convert returned markdown object to string
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
- // console.log(">>parsed data=", tmp, block);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notion-to-md",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "notion-to-md.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/utils/md.js CHANGED
@@ -61,3 +61,7 @@ exports.addTabSpace = (text, n = 0) => {
61
61
  for (i = 0; i < n; i++) text = tab + text;
62
62
  return text;
63
63
  };
64
+
65
+ exports.divider = () => {
66
+ return "---";
67
+ };