kramdown-prismic 0.2.0 → 0.2.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 +18 -0
- data/Changelog.md +9 -0
- data/Gemfile.lock +3 -3
- data/LICENSE +1 -0
- data/README.md +17 -7
- data/lib/kramdown-prismic/version.rb +1 -1
- data/lib/kramdown/converter/prismic.rb +5 -0
- data/lib/kramdown/parser/prismic.rb +4 -0
- data/test/converter_test.rb +34 -15
- data/test/parser_test.rb +19 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bb835641c9e7f2e9e600e0307e3bfd6e9eb46e5d83ae257c505c659c20865931
|
4
|
+
data.tar.gz: cba5da2b2d81fff052b24d7921872ec8e9607b726bdbe210ff516b6cf7b6810a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b4e02f18a5dbf5c51f46cc729c8dd2018d1eec8809790e0492ee22f7886627e5bc77d20dabde755f44883f1c062cd7a7dda33ba8acbe9c4dac165218f23ca70
|
7
|
+
data.tar.gz: 5428075b5c8eac073a1729feac6803a378ac55ba330540c46c230f78b5e965caeb95b26ea60be9f059611d182cb0f6c764c2817f9b03c53b1dcde03ec923d86b
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
jobs:
|
5
|
+
test:
|
6
|
+
strategy:
|
7
|
+
fail-fast: false
|
8
|
+
matrix:
|
9
|
+
os: [ubuntu-latest]
|
10
|
+
ruby: [2.5, 2.6, 2.7]
|
11
|
+
runs-on: ${{ matrix.os }}
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: ${{ matrix.ruby }}
|
17
|
+
bundler-cache: true
|
18
|
+
- run: bundle exec rake test
|
data/Changelog.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kramdown-prismic (0.2.
|
4
|
+
kramdown-prismic (0.2.1)
|
5
5
|
kramdown (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
kramdown (1.
|
10
|
+
kramdown (1.17.0)
|
11
11
|
minitest (5.10.3)
|
12
12
|
rake (12.2.1)
|
13
13
|
|
@@ -20,4 +20,4 @@ DEPENDENCIES
|
|
20
20
|
rake (~> 12.0)
|
21
21
|
|
22
22
|
BUNDLED WITH
|
23
|
-
1.
|
23
|
+
1.17.2
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ gem 'kramdown-prismic', '~> 0.1'
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
**Convert kramdown documents to Prismic**
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
require 'kramdown-prismic'
|
@@ -27,7 +27,7 @@ kramdown = '# Hello world'
|
|
27
27
|
Kramdown::Document.new(kramdown).to_prismic
|
28
28
|
```
|
29
29
|
|
30
|
-
|
30
|
+
**Convert markdown documents to Prismic**
|
31
31
|
|
32
32
|
```ruby
|
33
33
|
require 'kramdown-prismic'
|
@@ -36,7 +36,7 @@ markdown = '# Hello world'
|
|
36
36
|
Kramdown::Document.new(markdown, input: :markdown).to_prismic
|
37
37
|
```
|
38
38
|
|
39
|
-
|
39
|
+
**Convert HTML documents to Prismic**
|
40
40
|
|
41
41
|
```ruby
|
42
42
|
require 'kramdown-prismic'
|
@@ -45,7 +45,7 @@ html = '<h1>Hello world</h1>'
|
|
45
45
|
Kramdown::Document.new(html, input: :html).to_prismic
|
46
46
|
```
|
47
47
|
|
48
|
-
|
48
|
+
**Convert Prismic to markdown**
|
49
49
|
|
50
50
|
```ruby
|
51
51
|
require 'kramdown-prismic'
|
@@ -86,6 +86,9 @@ Some elements cannot be converted, due to some Prismic limitations. The table be
|
|
86
86
|
| hr | nothing |
|
87
87
|
| img | moved to the top level |
|
88
88
|
| nested list | moved to the top level |
|
89
|
+
| entity | converted to unicode |
|
90
|
+
| typographic_sym | converted to unicode |
|
91
|
+
| smart_quote | converted to unicode |
|
89
92
|
| dl | not supported |
|
90
93
|
| dt | not supported |
|
91
94
|
| dd | not supported |
|
@@ -97,9 +100,6 @@ Some elements cannot be converted, due to some Prismic limitations. The table be
|
|
97
100
|
| td | not supported |
|
98
101
|
| math | not supported |
|
99
102
|
| footnote | not supported |
|
100
|
-
| entity | converted to unicode |
|
101
|
-
| typographic_sym | converted to unicode |
|
102
|
-
| smart_quote | converted to unicode |
|
103
103
|
| abbreviation | not supported |
|
104
104
|
| html_element | not supported |
|
105
105
|
| xml_comment | not supported |
|
@@ -107,6 +107,16 @@ Some elements cannot be converted, due to some Prismic limitations. The table be
|
|
107
107
|
| comment | not supported |
|
108
108
|
| raw | not supported |
|
109
109
|
|
110
|
+
## Develop
|
111
|
+
|
112
|
+
Install dependencies:
|
113
|
+
|
114
|
+
bundle install
|
115
|
+
|
116
|
+
Run tests:
|
117
|
+
|
118
|
+
bundle exec rake test
|
119
|
+
|
110
120
|
## License
|
111
121
|
|
112
122
|
MIT
|
@@ -212,6 +212,11 @@ module Kramdown
|
|
212
212
|
memo[:text] += "\n"
|
213
213
|
end
|
214
214
|
|
215
|
+
def extract_span_codespan(element, memo)
|
216
|
+
warning('translating inline code is not supported')
|
217
|
+
memo[:text] += element.value
|
218
|
+
end
|
219
|
+
|
215
220
|
def extract_span_html_element(element, memo)
|
216
221
|
warning('translating html elements is not supported')
|
217
222
|
end
|
data/test/converter_test.rb
CHANGED
@@ -1,32 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
require 'minitest/autorun'
|
2
3
|
require 'kramdown-prismic'
|
3
4
|
|
4
5
|
class KramdownPrismicConverterTest < Minitest::Test
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
6.times do |heading|
|
7
|
+
define_method "test_convert_heading_#{heading}" do
|
8
|
+
expected = [
|
9
|
+
{
|
10
|
+
type: "heading#{heading + 1}",
|
11
|
+
content: {
|
12
|
+
text: "This is the document title",
|
13
|
+
spans: []
|
14
|
+
}
|
12
15
|
}
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
]
|
17
|
+
markdown = "#{"#" * (heading + 1)} This is the document title"
|
18
|
+
assert_equal expected, Kramdown::Document.new(markdown, input: :kramdown).to_prismic
|
19
|
+
end
|
17
20
|
end
|
18
21
|
|
19
|
-
def
|
22
|
+
def test_convert_heading7
|
20
23
|
expected = [
|
21
24
|
{
|
22
|
-
type: "
|
25
|
+
type: "heading6",
|
23
26
|
content: {
|
24
|
-
text: "This is
|
27
|
+
text: "# This is the document title",
|
25
28
|
spans: []
|
26
29
|
}
|
27
30
|
}
|
28
31
|
]
|
29
|
-
markdown = "
|
32
|
+
markdown = "####### This is the document title"
|
30
33
|
assert_equal expected, Kramdown::Document.new(markdown, input: :markdown).to_prismic
|
31
34
|
end
|
32
35
|
|
@@ -414,6 +417,22 @@ class KramdownPrismicConverterTest < Minitest::Test
|
|
414
417
|
assert_equal expected, Kramdown::Document.new(markdown, input: :kramdown).to_prismic
|
415
418
|
end
|
416
419
|
|
420
|
+
def test_convert_inline_code
|
421
|
+
expected = [
|
422
|
+
{
|
423
|
+
type: "paragraph",
|
424
|
+
content: {
|
425
|
+
text: "Hello code",
|
426
|
+
spans: []
|
427
|
+
}
|
428
|
+
}
|
429
|
+
]
|
430
|
+
markdown = "Hello `code`"
|
431
|
+
doc = Kramdown::Document.new(markdown)
|
432
|
+
assert_equal expected, doc.to_prismic
|
433
|
+
assert_equal 1, doc.warnings.size
|
434
|
+
end
|
435
|
+
|
417
436
|
def test_convert_br
|
418
437
|
expected = [
|
419
438
|
{type: "paragraph",
|
data/test/parser_test.rb
CHANGED
@@ -182,4 +182,23 @@ class KramdownPrismicParserTest < Minitest::Test
|
|
182
182
|
doc = Kramdown::Document.new(prismic, input: :prismic)
|
183
183
|
assert_equal expected, doc.to_kramdown
|
184
184
|
end
|
185
|
+
|
186
|
+
def test_parse_embed
|
187
|
+
prismic = [
|
188
|
+
{
|
189
|
+
type: "embed",
|
190
|
+
data: {
|
191
|
+
type: "video",
|
192
|
+
embed_url: "https://www.youtube.com/watch?v=y6y_4_b6RS8"
|
193
|
+
},
|
194
|
+
content: {
|
195
|
+
text: "",
|
196
|
+
spans: []
|
197
|
+
}
|
198
|
+
}
|
199
|
+
]
|
200
|
+
expected = "<iframe src=\"https://www.youtube.com/watch?v=y6y_4_b6RS8\"></iframe>\n"
|
201
|
+
doc = Kramdown::Document.new(prismic, input: :prismic)
|
202
|
+
assert_equal expected, doc.to_kramdown
|
203
|
+
end
|
185
204
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.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-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -58,6 +58,7 @@ executables: []
|
|
58
58
|
extensions: []
|
59
59
|
extra_rdoc_files: []
|
60
60
|
files:
|
61
|
+
- ".github/workflows/ci.yml"
|
61
62
|
- ".gitignore"
|
62
63
|
- ".travis.yml"
|
63
64
|
- Changelog.md
|
@@ -92,8 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
93
|
- !ruby/object:Gem::Version
|
93
94
|
version: '0'
|
94
95
|
requirements: []
|
95
|
-
|
96
|
-
rubygems_version: 2.6.11
|
96
|
+
rubygems_version: 3.0.3
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: A Kramdown converter to convert documents into prismic rich text format.
|