notion_to_md 2.3.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/notion_to_md/blocks/types.rb +2 -2
- data/lib/notion_to_md/page.rb +25 -7
- data/lib/notion_to_md/page_property.rb +12 -5
- data/lib/notion_to_md/version.rb +1 -1
- data/lib/notion_to_md.rb +0 -1
- metadata +2 -4
- data/lib/notion_to_md/helpers/yaml_sanitizer.rb +0 -17
- data/lib/notion_to_md/helpers.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb94bccdf9dca4374bfaeb42164cce77f3a1963048a96b83a53e238ff9768163
|
4
|
+
data.tar.gz: '039b7d197fc03a6a04ffaf1cb90f3f758dd597a7381a2002da677065d48f2d76'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce0dd31c6a1eb871468b151e2374311799b802b0f58e6e450bcc24aaa76f586f9755ad63953f3b61b45e0102d1440fa3d8f66538c014dbc921fc8ecf01a69a6f
|
7
|
+
data.tar.gz: 1a008da641c3c449b401ede3e2d65608a47192cae908888bcebd96eba7162e70f7640e549a881c459e9010cd1703248c49fa8d65d3a516489601a80c48e0e87d
|
data/README.md
CHANGED
@@ -102,6 +102,10 @@ created_time: 2022-01-23T12:31:00.000Z
|
|
102
102
|
last_edited_time: 2022-01-23T12:31:00.000Z
|
103
103
|
icon: 💥
|
104
104
|
archived: false
|
105
|
+
created_by_id: db313571-0280-411f-a6de-70e826421d16
|
106
|
+
created_by_object: user
|
107
|
+
last_edited_by_id: db313571-0280-411f-a6de-70e826421d16
|
108
|
+
last_edited_by_object: user
|
105
109
|
---
|
106
110
|
```
|
107
111
|
|
@@ -5,7 +5,7 @@ module NotionToMd
|
|
5
5
|
class Types
|
6
6
|
class << self
|
7
7
|
def paragraph(block)
|
8
|
-
return blank if block
|
8
|
+
return blank if block[:rich_text].empty?
|
9
9
|
|
10
10
|
convert_text(block)
|
11
11
|
end
|
@@ -124,7 +124,7 @@ module NotionToMd
|
|
124
124
|
href = text[:href]
|
125
125
|
return content if href.nil?
|
126
126
|
|
127
|
-
"[#{content}](#{href})"
|
127
|
+
"[#{content}](#{CGI.unescape(href)})"
|
128
128
|
end
|
129
129
|
|
130
130
|
def add_annotations(text, content)
|
data/lib/notion_to_md/page.rb
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
module NotionToMd
|
4
4
|
class Page
|
5
|
-
include Helpers::YamlSanitizer
|
6
|
-
|
7
5
|
attr_reader :page, :blocks
|
8
6
|
|
9
7
|
def initialize(page:, blocks:)
|
@@ -31,11 +29,27 @@ module NotionToMd
|
|
31
29
|
end
|
32
30
|
|
33
31
|
def created_time
|
34
|
-
|
32
|
+
page['created_time']
|
33
|
+
end
|
34
|
+
|
35
|
+
def created_by_object
|
36
|
+
page.dig(:created_by, :object)
|
37
|
+
end
|
38
|
+
|
39
|
+
def created_by_id
|
40
|
+
page.dig(:created_by, :id)
|
35
41
|
end
|
36
42
|
|
37
43
|
def last_edited_time
|
38
|
-
|
44
|
+
page['last_edited_time']
|
45
|
+
end
|
46
|
+
|
47
|
+
def last_edited_by_object
|
48
|
+
page.dig(:last_edited_by, :object)
|
49
|
+
end
|
50
|
+
|
51
|
+
def last_edited_by_id
|
52
|
+
page.dig(:last_edited_by, :id)
|
39
53
|
end
|
40
54
|
|
41
55
|
def url
|
@@ -79,12 +93,16 @@ module NotionToMd
|
|
79
93
|
def default_props
|
80
94
|
@default_props ||= {
|
81
95
|
'id' => id,
|
82
|
-
'title' =>
|
96
|
+
'title' => title.dump,
|
83
97
|
'created_time' => created_time,
|
84
98
|
'cover' => cover,
|
85
99
|
'icon' => icon,
|
86
|
-
'last_edited_time' => last_edited_time
|
87
|
-
'archived' => archived
|
100
|
+
'last_edited_time' => last_edited_time,
|
101
|
+
'archived' => archived,
|
102
|
+
'created_by_object' => created_by_object,
|
103
|
+
'created_by_id' => created_by_id,
|
104
|
+
'last_edited_by_object' => last_edited_by_object,
|
105
|
+
'last_edited_by_id' => last_edited_by_id
|
88
106
|
}
|
89
107
|
end
|
90
108
|
|
@@ -3,8 +3,6 @@
|
|
3
3
|
module NotionToMd
|
4
4
|
class PageProperty
|
5
5
|
class << self
|
6
|
-
include Helpers::YamlSanitizer
|
7
|
-
|
8
6
|
def file(prop)
|
9
7
|
prop.dig(:file, :url)
|
10
8
|
rescue NoMethodError
|
@@ -30,7 +28,7 @@ module NotionToMd
|
|
30
28
|
end
|
31
29
|
|
32
30
|
def select(prop)
|
33
|
-
|
31
|
+
prop.dig(:select, :name).dump
|
34
32
|
rescue NoMethodError
|
35
33
|
nil
|
36
34
|
end
|
@@ -75,7 +73,16 @@ module NotionToMd
|
|
75
73
|
# - end
|
76
74
|
# - time_zone
|
77
75
|
def date(prop)
|
78
|
-
prop.dig(:date, :start)
|
76
|
+
date = prop.dig(:date, :start)
|
77
|
+
|
78
|
+
case date
|
79
|
+
when Date
|
80
|
+
date.to_time
|
81
|
+
when String
|
82
|
+
Time.parse(date)
|
83
|
+
else
|
84
|
+
date # Time or nil
|
85
|
+
end
|
79
86
|
rescue NoMethodError
|
80
87
|
nil
|
81
88
|
end
|
@@ -88,7 +95,7 @@ module NotionToMd
|
|
88
95
|
|
89
96
|
def rich_text(prop)
|
90
97
|
text = prop[:rich_text].map { |text| text[:plain_text] }.join
|
91
|
-
text.blank? ? nil :
|
98
|
+
text.blank? ? nil : text.dump
|
92
99
|
rescue NoMethodError
|
93
100
|
nil
|
94
101
|
end
|
data/lib/notion_to_md/version.rb
CHANGED
data/lib/notion_to_md.rb
CHANGED
@@ -4,7 +4,6 @@ require 'notion'
|
|
4
4
|
require 'logger'
|
5
5
|
require 'active_support/inflector'
|
6
6
|
require 'active_support/core_ext/object/blank'
|
7
|
-
require_relative './notion_to_md/helpers'
|
8
7
|
require_relative './notion_to_md/version'
|
9
8
|
require_relative './notion_to_md/converter'
|
10
9
|
require_relative './notion_to_md/logger'
|
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.
|
4
|
+
version: 2.4.0
|
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-12-
|
11
|
+
date: 2023-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -145,8 +145,6 @@ files:
|
|
145
145
|
- lib/notion_to_md/blocks/to_do_list_item_block.rb
|
146
146
|
- lib/notion_to_md/blocks/types.rb
|
147
147
|
- lib/notion_to_md/converter.rb
|
148
|
-
- lib/notion_to_md/helpers.rb
|
149
|
-
- lib/notion_to_md/helpers/yaml_sanitizer.rb
|
150
148
|
- lib/notion_to_md/logger.rb
|
151
149
|
- lib/notion_to_md/page.rb
|
152
150
|
- lib/notion_to_md/page_property.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module NotionToMd
|
2
|
-
module Helpers
|
3
|
-
module YamlSanitizer
|
4
|
-
# Escape the frontmatter value if it contains a colon or a dash followed by a space
|
5
|
-
# @param value [String] the value to escape
|
6
|
-
# @return [String] the escaped value
|
7
|
-
def escape_frontmatter_value(value)
|
8
|
-
if value.match?(/: |-\s/)
|
9
|
-
# Escape the double quotes inside the string
|
10
|
-
"\"#{value.gsub('"', '\"')}\""
|
11
|
-
else
|
12
|
-
value
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/notion_to_md/helpers.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require_relative './helpers/yaml_sanitizer'
|