kramdown-prismic 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +39 -0
- data/CHANGELOG.md +36 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +8 -6
- data/LICENSE +1 -0
- data/README.md +36 -9
- data/Rakefile +3 -2
- data/bin/html2prismic +6 -0
- data/bin/markdown2prismic +6 -0
- data/bin/prismic2markdown +8 -0
- data/kramdown-prismic.gemspec +12 -8
- data/kramdown1.gemfile +6 -0
- data/kramdown2.gemfile +6 -0
- data/lib/kramdown-prismic.rb +2 -0
- data/lib/kramdown-prismic/version.rb +3 -1
- data/lib/kramdown/converter/prismic.rb +82 -39
- data/lib/kramdown/parser/prismic.rb +23 -19
- data/test/converter_test.rb +190 -124
- data/test/parser_test.rb +56 -48
- metadata +30 -15
- data/.travis.yml +0 -6
- data/Changelog.md +0 -13
data/test/parser_test.rb
CHANGED
@@ -1,43 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'minitest/autorun'
|
2
4
|
require 'kramdown-prismic'
|
3
5
|
|
4
6
|
class KramdownPrismicParserTest < Minitest::Test
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
6.times do |heading|
|
8
|
+
define_method "test_parse_heading_#{heading}" do
|
9
|
+
prismic = [
|
10
|
+
{
|
11
|
+
type: "heading#{heading + 1}",
|
12
|
+
content: {
|
13
|
+
text: 'This is the document title',
|
14
|
+
spans: []
|
15
|
+
}
|
12
16
|
}
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_parse_heading2
|
21
|
-
prismic = [
|
22
|
-
{
|
23
|
-
type: "heading2",
|
24
|
-
content: {
|
25
|
-
text: "This is an h2 title",
|
26
|
-
spans: []
|
27
|
-
}
|
28
|
-
}
|
29
|
-
]
|
30
|
-
expected = "## This is an h2 title\n\n"
|
31
|
-
doc = Kramdown::Document.new(prismic, input: :prismic)
|
32
|
-
assert_equal expected, doc.to_kramdown
|
17
|
+
]
|
18
|
+
expected = "#{'#' * (heading + 1)} This is the document title\n\n"
|
19
|
+
doc = Kramdown::Document.new(prismic, input: :prismic)
|
20
|
+
assert_equal expected, doc.to_kramdown
|
21
|
+
end
|
33
22
|
end
|
34
23
|
|
35
24
|
def test_parse_paragraph
|
36
25
|
prismic = [
|
37
26
|
{
|
38
|
-
type:
|
27
|
+
type: 'paragraph',
|
39
28
|
content: {
|
40
|
-
text:
|
29
|
+
text: 'This is a paragraph',
|
41
30
|
spans: []
|
42
31
|
}
|
43
32
|
}
|
@@ -50,12 +39,12 @@ class KramdownPrismicParserTest < Minitest::Test
|
|
50
39
|
def test_parse_paragraph_with_spans
|
51
40
|
prismic = [
|
52
41
|
{
|
53
|
-
type:
|
42
|
+
type: 'paragraph',
|
54
43
|
content: {
|
55
|
-
text:
|
44
|
+
text: 'This is a paragraph',
|
56
45
|
spans: [
|
57
46
|
{
|
58
|
-
type:
|
47
|
+
type: 'em',
|
59
48
|
start: 0,
|
60
49
|
end: 4
|
61
50
|
}
|
@@ -71,17 +60,17 @@ class KramdownPrismicParserTest < Minitest::Test
|
|
71
60
|
def test_parse_paragraph_with_multiple_spans
|
72
61
|
prismic = [
|
73
62
|
{
|
74
|
-
type:
|
63
|
+
type: 'paragraph',
|
75
64
|
content: {
|
76
|
-
text:
|
65
|
+
text: 'This is a paragraph',
|
77
66
|
spans: [
|
78
67
|
{
|
79
|
-
type:
|
68
|
+
type: 'em',
|
80
69
|
start: 0,
|
81
70
|
end: 4
|
82
71
|
},
|
83
72
|
{
|
84
|
-
type:
|
73
|
+
type: 'strong',
|
85
74
|
start: 5,
|
86
75
|
end: 7
|
87
76
|
}
|
@@ -97,16 +86,16 @@ class KramdownPrismicParserTest < Minitest::Test
|
|
97
86
|
def test_parse_paragraph_with_link
|
98
87
|
prismic = [
|
99
88
|
{
|
100
|
-
type:
|
89
|
+
type: 'paragraph',
|
101
90
|
content: {
|
102
|
-
text:
|
91
|
+
text: 'This is a paragraph',
|
103
92
|
spans: [
|
104
93
|
{
|
105
|
-
type:
|
94
|
+
type: 'hyperlink',
|
106
95
|
start: 0,
|
107
96
|
end: 19,
|
108
97
|
data: {
|
109
|
-
url:
|
98
|
+
url: 'https://prismic.io'
|
110
99
|
}
|
111
100
|
}
|
112
101
|
]
|
@@ -121,21 +110,21 @@ class KramdownPrismicParserTest < Minitest::Test
|
|
121
110
|
def test_parse_paragraph_with_nested_spans
|
122
111
|
prismic = [
|
123
112
|
{
|
124
|
-
type:
|
113
|
+
type: 'paragraph',
|
125
114
|
content: {
|
126
|
-
text:
|
115
|
+
text: 'This is a paragraph',
|
127
116
|
spans: [
|
128
117
|
{
|
129
|
-
type:
|
118
|
+
type: 'em',
|
130
119
|
start: 0,
|
131
120
|
end: 4
|
132
121
|
},
|
133
122
|
{
|
134
|
-
type:
|
123
|
+
type: 'hyperlink',
|
135
124
|
start: 0,
|
136
125
|
end: 19,
|
137
126
|
data: {
|
138
|
-
url:
|
127
|
+
url: 'https://prismic.io'
|
139
128
|
}
|
140
129
|
}
|
141
130
|
]
|
@@ -150,9 +139,9 @@ class KramdownPrismicParserTest < Minitest::Test
|
|
150
139
|
def test_parse_image
|
151
140
|
prismic = [
|
152
141
|
{
|
153
|
-
type:
|
142
|
+
type: 'image',
|
154
143
|
content: {
|
155
|
-
text:
|
144
|
+
text: '',
|
156
145
|
spans: []
|
157
146
|
},
|
158
147
|
data: {
|
@@ -171,7 +160,7 @@ class KramdownPrismicParserTest < Minitest::Test
|
|
171
160
|
def test_parse_preformatted
|
172
161
|
prismic = [
|
173
162
|
{
|
174
|
-
type:
|
163
|
+
type: 'preformatted',
|
175
164
|
content: {
|
176
165
|
text: "This is a pre block\n",
|
177
166
|
spans: []
|
@@ -182,4 +171,23 @@ class KramdownPrismicParserTest < Minitest::Test
|
|
182
171
|
doc = Kramdown::Document.new(prismic, input: :prismic)
|
183
172
|
assert_equal expected, doc.to_kramdown
|
184
173
|
end
|
174
|
+
|
175
|
+
def test_parse_embed
|
176
|
+
prismic = [
|
177
|
+
{
|
178
|
+
type: 'embed',
|
179
|
+
data: {
|
180
|
+
type: 'video',
|
181
|
+
embed_url: 'https://www.youtube.com/watch?v=y6y_4_b6RS8'
|
182
|
+
},
|
183
|
+
content: {
|
184
|
+
text: '',
|
185
|
+
spans: []
|
186
|
+
}
|
187
|
+
}
|
188
|
+
]
|
189
|
+
expected = "<iframe src=\"https://www.youtube.com/watch?v=y6y_4_b6RS8\"></iframe>\n"
|
190
|
+
doc = Kramdown::Document.new(prismic, input: :prismic)
|
191
|
+
assert_equal expected, doc.to_kramdown
|
192
|
+
end
|
185
193
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kramdown-prismic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- François de Metz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1'
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '3'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1'
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
32
|
+
version: '3'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: minitest
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,29 +50,38 @@ dependencies:
|
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
53
|
+
version: '13.0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
description: A Kramdown converter to convert documents into prismic rich text format
|
60
|
+
version: '13.0'
|
61
|
+
description: A Kramdown converter to convert documents into prismic rich text format
|
62
|
+
and the other way around.
|
56
63
|
email: francois@2metz.fr
|
57
|
-
executables:
|
64
|
+
executables:
|
65
|
+
- markdown2prismic
|
66
|
+
- html2prismic
|
67
|
+
- prismic2markdown
|
58
68
|
extensions: []
|
59
69
|
extra_rdoc_files: []
|
60
70
|
files:
|
71
|
+
- ".github/workflows/ci.yml"
|
61
72
|
- ".gitignore"
|
62
|
-
-
|
63
|
-
- Changelog.md
|
73
|
+
- CHANGELOG.md
|
64
74
|
- Gemfile
|
65
75
|
- Gemfile.lock
|
66
76
|
- LICENSE
|
67
77
|
- README.md
|
68
78
|
- Rakefile
|
79
|
+
- bin/html2prismic
|
80
|
+
- bin/markdown2prismic
|
81
|
+
- bin/prismic2markdown
|
69
82
|
- kramdown-prismic.gemspec
|
83
|
+
- kramdown1.gemfile
|
84
|
+
- kramdown2.gemfile
|
70
85
|
- lib/kramdown-prismic.rb
|
71
86
|
- lib/kramdown-prismic/version.rb
|
72
87
|
- lib/kramdown/converter/prismic.rb
|
@@ -92,11 +107,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
107
|
- !ruby/object:Gem::Version
|
93
108
|
version: '0'
|
94
109
|
requirements: []
|
95
|
-
|
96
|
-
rubygems_version: 2.6.11
|
110
|
+
rubygems_version: 3.0.3
|
97
111
|
signing_key:
|
98
112
|
specification_version: 4
|
99
|
-
summary: A Kramdown converter to convert documents into prismic rich text format
|
113
|
+
summary: A Kramdown converter to convert documents into prismic rich text format and
|
114
|
+
the other way around.
|
100
115
|
test_files:
|
101
116
|
- test/converter_test.rb
|
102
117
|
- test/parser_test.rb
|
data/.travis.yml
DELETED