kramdown-prismic 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +4 -0
- data/Gemfile.lock +3 -3
- data/kramdown-prismic.gemspec +1 -1
- data/lib/kramdown-prismic/version.rb +1 -1
- data/lib/kramdown/converter/prismic.rb +24 -1
- data/test/converter_test.rb +25 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3229f319815e16e39608a957bb9f596e623a6ef605be3955c46723de2aedbb98
|
4
|
+
data.tar.gz: '08f9b62d41e583e99d51373ddb875352abec6226f2a584c6f9d21b61c15ed26f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c3bf867920d85af049006027d70f156cca4c0863cd8c40784eb473121153652acc368906e1100fabdb90d36a04f73c9a966090c8a68e7d55fc8c55f0e3610e7
|
7
|
+
data.tar.gz: e4daf1cfe1886f809f0234d7a181b22e677be78401f06c4f4657d89a519e61b13d56ce1dcabcad11ed13bbe782f359c3214c5650da098b8b72c65fccdeb230b4
|
data/Changelog.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kramdown-prismic (0.2.
|
4
|
+
kramdown-prismic (0.2.2)
|
5
5
|
kramdown (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -9,7 +9,7 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
kramdown (1.17.0)
|
11
11
|
minitest (5.10.3)
|
12
|
-
rake (
|
12
|
+
rake (13.0.6)
|
13
13
|
|
14
14
|
PLATFORMS
|
15
15
|
ruby
|
@@ -17,7 +17,7 @@ PLATFORMS
|
|
17
17
|
DEPENDENCIES
|
18
18
|
kramdown-prismic!
|
19
19
|
minitest (~> 5.0)
|
20
|
-
rake (~>
|
20
|
+
rake (~> 13.0)
|
21
21
|
|
22
22
|
BUNDLED WITH
|
23
23
|
1.17.2
|
data/kramdown-prismic.gemspec
CHANGED
@@ -32,7 +32,9 @@ module Kramdown
|
|
32
32
|
|
33
33
|
def extract_non_nestable_elements(child, elements)
|
34
34
|
child.children = child.children.inject([]) do |memo, element|
|
35
|
-
if element.type == :img
|
35
|
+
if element.type == :a && element.children.size === 1 && element.children.first.type == :img
|
36
|
+
elements << element
|
37
|
+
elsif element.type == :img
|
36
38
|
elements << element
|
37
39
|
warning('images inside content will be moved to the top level and may be rendered differently') if child.children.size > 1
|
38
40
|
elsif element.type == :ul
|
@@ -123,6 +125,27 @@ module Kramdown
|
|
123
125
|
}
|
124
126
|
end
|
125
127
|
|
128
|
+
# This can only apply when an link with an image inside has been detected
|
129
|
+
def convert_a(element)
|
130
|
+
image = element.children.first
|
131
|
+
{
|
132
|
+
type: 'image',
|
133
|
+
content: {
|
134
|
+
text: '',
|
135
|
+
spans: []
|
136
|
+
},
|
137
|
+
data: {
|
138
|
+
origin: {
|
139
|
+
url: image.attr['src']
|
140
|
+
},
|
141
|
+
alt: image.attr['alt'],
|
142
|
+
linkTo: {
|
143
|
+
url: element.attr['href']
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
126
149
|
def convert_html_element(element)
|
127
150
|
warning('translating html elements is not supported')
|
128
151
|
nil
|
data/test/converter_test.rb
CHANGED
@@ -367,6 +367,31 @@ class KramdownPrismicConverterTest < Minitest::Test
|
|
367
367
|
assert_equal 2, doc.warnings.size
|
368
368
|
end
|
369
369
|
|
370
|
+
def test_convert_img_with_link
|
371
|
+
expected = [
|
372
|
+
{
|
373
|
+
type: "image",
|
374
|
+
content: {
|
375
|
+
text: "",
|
376
|
+
spans: []
|
377
|
+
},
|
378
|
+
data: {
|
379
|
+
origin: {
|
380
|
+
url: '/img.png'
|
381
|
+
},
|
382
|
+
alt: 'alt text',
|
383
|
+
linkTo: {
|
384
|
+
url: "https://example.net/"
|
385
|
+
}
|
386
|
+
}
|
387
|
+
}
|
388
|
+
]
|
389
|
+
markdown = "[![alt text](/img.png)](https://example.net/)"
|
390
|
+
doc = Kramdown::Document.new(markdown)
|
391
|
+
assert_equal expected, doc.to_prismic
|
392
|
+
assert_equal 0, doc.warnings.size
|
393
|
+
end
|
394
|
+
|
370
395
|
def test_convert_entity
|
371
396
|
expected = [
|
372
397
|
{
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kramdown-prismic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- François de Metz
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
description: A Kramdown converter to convert documents into prismic rich text format.
|
56
56
|
email: francois@2metz.fr
|
57
57
|
executables: []
|