notion_to_md 1.1.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edaf453c97dcc2d166335f7179ea81845b44da0991e07b75f2e230288b141655
4
- data.tar.gz: ff82f6e0a124195467797f10472bb3ce6e7460f43da2a5ff5f55cbdf0ae74cd6
3
+ metadata.gz: 7269cbbe0632eb45943dee04bef8468268febf92c483750e03533715886b4afa
4
+ data.tar.gz: 11c7825d9d91499a0f70b2ec094012726a999d9831107a6bb2cd4bcc212c71dc
5
5
  SHA512:
6
- metadata.gz: 9f6c340abef5d82806618e3e4a30abaa320b1bc996760cc0f1a80211277a313009367b7f74c271ff27b668c2fc7402819a87c3c45408a70d41fc515db0afb47c
7
- data.tar.gz: 764f05022696b17c425784ae8aa7ba7a1648b9fc4172914b21c0c7c7165bbded342596edad993e51ee78ed6e512985a9fa5c21e1b31d0746e5363896c86ee3e7
6
+ metadata.gz: bca9ebf93794910679e87cf1b049a740ee8ffd4666d45a2ae036c997bc7de408610611dd3fa627e8104ce56674cd1951bef962c96dd6a0b252c7a0619fb01ecb
7
+ data.tar.gz: b689e769dc0f1c19e5291316266e9db6bb52cac9db67e2e7b76b4a845868c0e91cd8b47a3aa0b3bcc635731f0457909830a14ddf3a19db47c4f69309678cfa90
data/README.md CHANGED
@@ -40,8 +40,24 @@ md = notion_converter.convert
40
40
 
41
41
  And that's all. The `md` is a string variable containing the notion page formatted in markdown.
42
42
 
43
+ ## Blocks
43
44
 
44
- ### Front matter
45
+ Everything in a notion page body is a [block object](https://developers.notion.com/reference/block#block-object-keys). Therefore, not every type can be mapped to Markdown. Below there's a list of current supported blocks types.
46
+
47
+ * `paragraph`
48
+ * `heading_1`
49
+ * `heading_2`
50
+ * `heading_3`
51
+ * `bulleted_list_item`
52
+ * `numbered_list_item` as `bulleted_list_item`
53
+ * `to_do`
54
+ * `image`
55
+ * `bookmark`
56
+ * `callout`
57
+ * `quote`
58
+ * `divider`
59
+
60
+ ## Front matter
45
61
 
46
62
  From version 0.2.0, notion_to_md supports front matter in markdown files.
47
63
 
@@ -51,7 +67,7 @@ By default, the front matter section is not included to the document. To do so,
51
67
  NotionToMd::Converter.new(page_id: 'b91d5...').convert(frontmatter: tue)
52
68
  ```
53
69
 
54
- Default notion properties are page `id`, `title`, `created_time`, `last_edited_time`, `icon`, `archived` and `cover`.
70
+ Default notion [properties](https://developers.notion.com/reference/page#all-pages) are page `id`, `title`, `created_time`, `last_edited_time`, `icon`, `archived` and `cover`.
55
71
 
56
72
  ```yml
57
73
  ---
@@ -33,7 +33,6 @@ module NotionToMd
33
33
  "- #{convert_text(block)}"
34
34
  end
35
35
 
36
- # TODO: numbered_list_item
37
36
  def numbered_list_item(block)
38
37
  Logger.info('numbered_list_item type not supported. Shown as bulleted_list_item.')
39
38
  bulleted_list_item(block)
@@ -50,7 +49,7 @@ module NotionToMd
50
49
  language = block[:language]
51
50
  text = convert_text(block)
52
51
 
53
- "```#{language}\n\t#{text}\n```"
52
+ "```#{language}\n#{text}\n```"
54
53
  end
55
54
 
56
55
  def embed(block)
@@ -81,14 +80,14 @@ module NotionToMd
81
80
  end
82
81
 
83
82
  def convert_text(block)
84
- block[:text].map do |text|
83
+ block[:rich_text].map do |text|
85
84
  content = Text.send(text[:type], text)
86
85
  enrich_text_content(text, content)
87
86
  end.join
88
87
  end
89
88
 
90
89
  def convert_caption(block)
91
- convert_text(text: block[:caption])
90
+ convert_text(rich_text: block[:caption])
92
91
  end
93
92
 
94
93
  def get_icon(block)
@@ -20,11 +20,11 @@ module NotionToMd
20
20
  private
21
21
 
22
22
  def page
23
- @page ||= @notion.page(id: page_id)
23
+ @page ||= @notion.page(page_id: page_id)
24
24
  end
25
25
 
26
26
  def page_blocks
27
- @page_blocks ||= @notion.block_children(id: page_id)
27
+ @page_blocks ||= @notion.block_children(block_id: page_id)
28
28
  end
29
29
  end
30
30
  end
@@ -20,7 +20,7 @@ module NotionToMd
20
20
  end
21
21
 
22
22
  def icon
23
- page.dig(:icon, :emoji)
23
+ page.dig(:icon, :file, :url) || page.dig(:icon, :emoji)
24
24
  end
25
25
 
26
26
  def id
@@ -45,7 +45,7 @@ module NotionToMd
45
45
 
46
46
  def body
47
47
  @body ||= blocks[:results].map do |block|
48
- next Block.blank if block[:type] == 'paragraph' && block.dig(:paragraph, :text).empty?
48
+ next Block.blank if block[:type] == 'paragraph' && block.dig(:paragraph, :rich_text).empty?
49
49
 
50
50
  block_type = block[:type].to_sym
51
51
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NotionToMd
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notion_to_md
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Enrique Arias
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-09 00:00:00.000000000 Z
11
+ date: 2022-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '6'
19
+ version: '7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '6'
26
+ version: '7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: notion-ruby-client
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.8
33
+ version: '1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.8
40
+ version: '1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hashie
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Notion Markdown Exporter in Ruby
84
98
  email: emoriarty81@gmail.com
85
99
  executables: []