notion_to_md 2.2.1 → 2.2.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.
- checksums.yaml +4 -4
- data/lib/notion_to_md/page.rb +9 -54
- data/lib/notion_to_md/page_property.rb +94 -0
- data/lib/notion_to_md/version.rb +1 -1
- data/lib/notion_to_md.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe4b566f6c03367e56e1ec29712a426c00f148fffbfe581834453987dd776b2a
|
4
|
+
data.tar.gz: 79041b5e3825242bfc320ef1d1b1af2e69c1ef31b438ca2c6d867d02ea6265a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd6296ed1211621923c954c5976065dfca3865d98ccea4f8d6f88654006de1732730b9b01782527d43ce2c602a29d3dcce375f4179e4c2c12d88678601d3e54f
|
7
|
+
data.tar.gz: 335658c17ee969c76b8505f1d0b8f56efebd0b0cd38ef495f494bcd602e741390014b97883562c337978c8309f0145eb540801a76ca7ef3effd18ac771a83707
|
data/lib/notion_to_md/page.rb
CHANGED
@@ -10,17 +10,18 @@ module NotionToMd
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def title
|
13
|
-
page.dig(:properties, :Name, :title).
|
13
|
+
title_list = page.dig(:properties, :Name, :title) || page.dig(:properties, :title, :title)
|
14
|
+
title_list.inject('') do |acc, slug|
|
14
15
|
acc + slug[:plain_text]
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
19
|
def cover
|
19
|
-
|
20
|
+
PageProperty.external(page[:cover]) || PageProperty.file(page[:cover])
|
20
21
|
end
|
21
22
|
|
22
23
|
def icon
|
23
|
-
|
24
|
+
PageProperty.emoji(page[:icon]) || PageProperty.external(page[:icon]) || PageProperty.file(page[:icon])
|
24
25
|
end
|
25
26
|
|
26
27
|
def id
|
@@ -51,8 +52,8 @@ module NotionToMd
|
|
51
52
|
@frontmatter ||= <<~CONTENT
|
52
53
|
---
|
53
54
|
#{props.to_a.map do |k, v|
|
54
|
-
|
55
|
-
|
55
|
+
"#{k}: #{v}"
|
56
|
+
end.join("\n")}
|
56
57
|
---
|
57
58
|
CONTENT
|
58
59
|
end
|
@@ -85,55 +86,9 @@ module NotionToMd
|
|
85
86
|
}
|
86
87
|
end
|
87
88
|
|
88
|
-
class
|
89
|
-
|
90
|
-
|
91
|
-
prop.multi_select.map(&:name)
|
92
|
-
end
|
93
|
-
|
94
|
-
def select(prop)
|
95
|
-
prop['select']&.name
|
96
|
-
end
|
97
|
-
|
98
|
-
def people(prop)
|
99
|
-
prop.people.map(&:name)
|
100
|
-
end
|
101
|
-
|
102
|
-
def files(prop)
|
103
|
-
prop.files.map { |f| f.file.url }
|
104
|
-
end
|
105
|
-
|
106
|
-
def phone_number(prop)
|
107
|
-
prop.phone_number
|
108
|
-
end
|
109
|
-
|
110
|
-
def number(prop)
|
111
|
-
prop.number
|
112
|
-
end
|
113
|
-
|
114
|
-
def email(prop)
|
115
|
-
prop.email
|
116
|
-
end
|
117
|
-
|
118
|
-
def checkbox(prop)
|
119
|
-
prop.checkbox.to_s
|
120
|
-
end
|
121
|
-
|
122
|
-
# date type properties not supported:
|
123
|
-
# - end
|
124
|
-
# - time_zone
|
125
|
-
def date(prop)
|
126
|
-
prop.date.start
|
127
|
-
end
|
128
|
-
|
129
|
-
def url(prop)
|
130
|
-
prop.url
|
131
|
-
end
|
132
|
-
|
133
|
-
def rich_text(prop)
|
134
|
-
prop.rich_text.map(&:plain_text).join
|
135
|
-
end
|
136
|
-
end
|
89
|
+
# This class is kept for retro compatibility reasons.
|
90
|
+
# Use instead the PageProperty class.
|
91
|
+
class CustomProperty < PageProperty
|
137
92
|
end
|
138
93
|
end
|
139
94
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NotionToMd
|
4
|
+
class PageProperty
|
5
|
+
class << self
|
6
|
+
def file(prop)
|
7
|
+
prop.dig(:file, :url)
|
8
|
+
rescue NoMethodError
|
9
|
+
nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def external(prop)
|
13
|
+
prop.dig(:external, :url)
|
14
|
+
rescue NoMethodError
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def emoji(prop)
|
19
|
+
prop[:emoji]
|
20
|
+
rescue NoMethodError
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def multi_select(prop)
|
25
|
+
prop[:multi_select].map { |sel| sel[:name] }
|
26
|
+
rescue NoMethodError
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def select(prop)
|
31
|
+
prop.dig(:select, :name)
|
32
|
+
rescue NoMethodError
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def people(prop)
|
37
|
+
prop[:people].map { |sel| sel[:name] }
|
38
|
+
rescue NoMethodError
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def files(prop)
|
43
|
+
prop[:files].map { |f| file(f) || external(f) }
|
44
|
+
rescue NoMethodError
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def phone_number(prop)
|
49
|
+
prop[:phone_number]
|
50
|
+
rescue NoMethodError
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def number(prop)
|
55
|
+
prop[:number]
|
56
|
+
rescue NoMethodError
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def email(prop)
|
61
|
+
prop[:email]
|
62
|
+
rescue NoMethodError
|
63
|
+
nil
|
64
|
+
end
|
65
|
+
|
66
|
+
def checkbox(prop)
|
67
|
+
prop[:checkbox].nil? ? nil : prop[:checkbox].to_s
|
68
|
+
rescue NoMethodError
|
69
|
+
nil
|
70
|
+
end
|
71
|
+
|
72
|
+
# date type properties not supported:
|
73
|
+
# - end
|
74
|
+
# - time_zone
|
75
|
+
def date(prop)
|
76
|
+
prop.dig(:date, :start)
|
77
|
+
rescue NoMethodError
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
|
81
|
+
def url(prop)
|
82
|
+
prop[:url]
|
83
|
+
rescue NoMethodError
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
|
87
|
+
def rich_text(prop)
|
88
|
+
prop[:rich_text].map { |text| text[:plain_text] }.join
|
89
|
+
rescue NoMethodError
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/notion_to_md/version.rb
CHANGED
data/lib/notion_to_md.rb
CHANGED
@@ -7,6 +7,7 @@ require 'active_support/core_ext/object/blank'
|
|
7
7
|
require_relative './notion_to_md/version'
|
8
8
|
require_relative './notion_to_md/converter'
|
9
9
|
require_relative './notion_to_md/logger'
|
10
|
+
require_relative './notion_to_md/page_property'
|
10
11
|
require_relative './notion_to_md/page'
|
11
12
|
require_relative './notion_to_md/blocks'
|
12
13
|
require_relative './notion_to_md/text'
|
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: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Enrique Arias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/notion_to_md/converter.rb
|
125
125
|
- lib/notion_to_md/logger.rb
|
126
126
|
- lib/notion_to_md/page.rb
|
127
|
+
- lib/notion_to_md/page_property.rb
|
127
128
|
- lib/notion_to_md/text.rb
|
128
129
|
- lib/notion_to_md/text_annotation.rb
|
129
130
|
- lib/notion_to_md/version.rb
|