kramdown-prismic 0.2.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,54 +1,84 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kramdown
2
4
  module Parser
3
5
  class Prismic < Base
4
6
  def parse
5
7
  @root.options[:encoding] = 'UTF-8'
6
- @root.children = @source.map do |block|
7
- type = block[:type]
8
- if type.match(/heading/)
9
- type = 'heading'
10
- end
11
- element = send("parse_#{type}", block)
12
- parse_spans(element, block)
13
- element
8
+ @root.children = @source.reduce([]) do |memo, block|
9
+ parse_element(block, memo)
14
10
  end
15
11
  end
16
12
 
17
13
  private
18
14
 
15
+ def parse_element(block, memo)
16
+ type = block[:type].gsub('-', '_')
17
+ type = 'heading' if type.match(/heading/)
18
+ if type == 'list_item'
19
+ parse_list(:ul, block, memo)
20
+ memo
21
+ elsif type == 'o_list_item'
22
+ parse_list(:ol, block, memo)
23
+ memo
24
+ else
25
+ element = send("parse_#{type}", block)
26
+ parse_spans(element, block)
27
+ memo << element
28
+ end
29
+ end
30
+
19
31
  def parse_heading(block)
20
32
  level = block[:type].match(/heading([1-6])/)[1].to_i
21
- Kramdown::Element.new(:header, nil, nil, {level: level, raw_text: ''})
33
+ Element.new(:header, nil, nil, { level: level, raw_text: '' })
22
34
  end
23
35
 
24
- def parse_paragraph(block)
25
- Kramdown::Element.new(:p)
36
+ def parse_paragraph(_block)
37
+ Element.new(:p)
26
38
  end
27
39
 
28
40
  def parse_image(block)
29
- p = Kramdown::Element.new(:p)
30
- img = Kramdown::Element.new(:img, nil, {"src" => block[:data][:origin][:url], "alt" => block[:data][:alt]})
31
- p.children << img
41
+ p = Element.new(:p)
42
+ img = Element.new(:img, nil, { 'src' => block[:data][:origin][:url], 'alt' => block[:data][:alt] })
43
+ if block[:data][:linkTo]
44
+ a = Element.new(:a, nil, { 'href' => block[:data][:linkTo][:url] })
45
+ a.children << img
46
+ p.children << a
47
+ else
48
+ p.children << img
49
+ end
32
50
  p
33
51
  end
34
52
 
35
- def parse_preformatted(block)
36
- Kramdown::Element.new(:blockquote)
53
+ def parse_preformatted(_block)
54
+ Element.new(:blockquote)
55
+ end
56
+
57
+ def parse_list(type, block, memo)
58
+ list = memo.last
59
+ unless list && list.type == type
60
+ list = Element.new(type)
61
+ memo << list
62
+ end
63
+ li = Element.new(:li, nil, nil)
64
+ list.children << li
65
+ p = Element.new(:p, nil, nil, transparent: true)
66
+ li.children << p
67
+ parse_spans(p, block)
37
68
  end
38
69
 
39
70
  def parse_embed(block)
40
- Kramdown::Element.new(:html_element, 'iframe', { src: block[:data][:embed_url] })
71
+ Element.new(:html_element, 'iframe', { src: block[:data][:embed_url] })
41
72
  end
42
73
 
43
74
  def parse_spans(element, block)
44
75
  stack = []
45
76
 
46
77
  (block[:content][:text].size + 1).times do |index|
47
-
48
78
  starting_spans = find_starting_spans_for(block, index)
49
79
  ending_spans = find_ending_spans_for(block, index)
50
80
 
51
- ending_spans.each do |ending_span|
81
+ ending_spans.each do |_ending_span|
52
82
  el = stack.pop
53
83
  if stack.empty?
54
84
  element.children << el
@@ -57,22 +87,23 @@ module Kramdown
57
87
  end
58
88
  end
59
89
  starting_spans.each do |starting_span|
60
- stack << if starting_span[:type] == "hyperlink"
61
- Element.new(:a, nil, {'href' => starting_span[:data][:url]})
62
- else
63
- Element.new(starting_span[:type].to_sym)
64
- end
90
+ stack << if starting_span[:type] == 'hyperlink'
91
+ Element.new(:a, nil, { 'href' => starting_span[:data][:url] })
92
+ else
93
+ Element.new(starting_span[:type].to_sym)
94
+ end
65
95
  end
66
96
 
67
97
  char = block[:content][:text][index]
68
98
  next if char.nil?
99
+
69
100
  current_text = if stack.empty?
70
- element.children.last
71
- else
72
- stack[-1].children.last
73
- end
101
+ element.children.last
102
+ else
103
+ stack[-1].children.last
104
+ end
74
105
  if current_text.nil? || current_text.type != :text
75
- current_text = Element.new(:text, "")
106
+ current_text = Element.new(:text, '')
76
107
  if stack.empty?
77
108
  element.children << current_text
78
109
  else
@@ -1,4 +1,6 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'minitest/autorun'
3
5
  require 'kramdown-prismic'
4
6
 
@@ -9,12 +11,12 @@ class KramdownPrismicConverterTest < Minitest::Test
9
11
  {
10
12
  type: "heading#{heading + 1}",
11
13
  content: {
12
- text: "This is the document title",
14
+ text: 'This is the document title',
13
15
  spans: []
14
16
  }
15
17
  }
16
18
  ]
17
- markdown = "#{"#" * (heading + 1)} This is the document title"
19
+ markdown = "#{'#' * (heading + 1)} This is the document title"
18
20
  assert_equal expected, Kramdown::Document.new(markdown, input: :kramdown).to_prismic
19
21
  end
20
22
  end
@@ -22,26 +24,26 @@ class KramdownPrismicConverterTest < Minitest::Test
22
24
  def test_convert_heading7
23
25
  expected = [
24
26
  {
25
- type: "heading6",
27
+ type: 'heading6',
26
28
  content: {
27
- text: "# This is the document title",
29
+ text: '# This is the document title',
28
30
  spans: []
29
31
  }
30
32
  }
31
33
  ]
32
- markdown = "####### This is the document title"
34
+ markdown = '####### This is the document title'
33
35
  assert_equal expected, Kramdown::Document.new(markdown, input: :markdown).to_prismic
34
36
  end
35
37
 
36
38
  def test_convert_heading_with_spans
37
39
  expected = [
38
40
  {
39
- type: "heading2",
41
+ type: 'heading2',
40
42
  content: {
41
- text: "This is a document title",
43
+ text: 'This is a document title',
42
44
  spans: [
43
45
  {
44
- type: "em",
46
+ type: 'em',
45
47
  start: 0,
46
48
  end: 4
47
49
  }
@@ -49,56 +51,56 @@ class KramdownPrismicConverterTest < Minitest::Test
49
51
  }
50
52
  }
51
53
  ]
52
- markdown = "## *This* is a document title"
54
+ markdown = '## *This* is a document title'
53
55
  assert_equal expected, Kramdown::Document.new(markdown, input: :markdown).to_prismic
54
56
  end
55
57
 
56
58
  def test_convert_paragraph
57
59
  expected = [
58
60
  {
59
- type: "paragraph",
61
+ type: 'paragraph',
60
62
  content: {
61
- text: "This is a paragraph",
63
+ text: 'This is a paragraph',
62
64
  spans: []
63
65
  }
64
66
  }
65
67
  ]
66
- markdown = "This is a paragraph"
68
+ markdown = 'This is a paragraph'
67
69
  assert_equal expected, Kramdown::Document.new(markdown, input: :markdown).to_prismic
68
70
  end
69
71
 
70
72
  def test_convert_paragraph_with_spans
71
73
  expected = [
72
74
  {
73
- type: "paragraph",
75
+ type: 'paragraph',
74
76
  content: {
75
- text: "This is a paragraph",
77
+ text: 'This is a paragraph',
76
78
  spans: [
77
79
  {
78
- type: "hyperlink",
80
+ type: 'hyperlink',
79
81
  start: 0,
80
82
  end: 19,
81
83
  data: {
82
- url: "https://prismic.io"
84
+ url: 'https://prismic.io'
83
85
  }
84
86
  }
85
87
  ]
86
88
  }
87
89
  }
88
90
  ]
89
- markdown = "[This is a paragraph](https://prismic.io)"
91
+ markdown = '[This is a paragraph](https://prismic.io)'
90
92
  assert_equal expected, Kramdown::Document.new(markdown, input: :markdown).to_prismic
91
93
  end
92
94
 
93
95
  def test_convert_paragraph_with_strong
94
96
  expected = [
95
97
  {
96
- type: "paragraph",
98
+ type: 'paragraph',
97
99
  content: {
98
- text: "This is a paragraph",
100
+ text: 'This is a paragraph',
99
101
  spans: [
100
102
  {
101
- type: "strong",
103
+ type: 'strong',
102
104
  start: 0,
103
105
  end: 19
104
106
  }
@@ -106,19 +108,19 @@ class KramdownPrismicConverterTest < Minitest::Test
106
108
  }
107
109
  }
108
110
  ]
109
- markdown = "**This is a paragraph**"
111
+ markdown = '**This is a paragraph**'
110
112
  assert_equal expected, Kramdown::Document.new(markdown, input: :markdown).to_prismic
111
113
  end
112
114
 
113
115
  def test_convert_paragraph_with_strong2
114
116
  expected = [
115
117
  {
116
- type: "paragraph",
118
+ type: 'paragraph',
117
119
  content: {
118
- text: "This is a paragraph",
120
+ text: 'This is a paragraph',
119
121
  spans: [
120
122
  {
121
- type: "strong",
123
+ type: 'strong',
122
124
  start: 0,
123
125
  end: 4
124
126
  }
@@ -126,19 +128,19 @@ class KramdownPrismicConverterTest < Minitest::Test
126
128
  }
127
129
  }
128
130
  ]
129
- markdown = "**This** is a paragraph"
131
+ markdown = '**This** is a paragraph'
130
132
  assert_equal expected, Kramdown::Document.new(markdown, input: :markdown).to_prismic
131
133
  end
132
134
 
133
135
  def test_convert_paragraph_with_em
134
136
  expected = [
135
137
  {
136
- type: "paragraph",
138
+ type: 'paragraph',
137
139
  content: {
138
- text: "This is a paragraph",
140
+ text: 'This is a paragraph',
139
141
  spans: [
140
142
  {
141
- type: "em",
143
+ type: 'em',
142
144
  start: 0,
143
145
  end: 4
144
146
  }
@@ -146,19 +148,19 @@ class KramdownPrismicConverterTest < Minitest::Test
146
148
  }
147
149
  }
148
150
  ]
149
- markdown = "*This* is a paragraph"
151
+ markdown = '*This* is a paragraph'
150
152
  assert_equal expected, Kramdown::Document.new(markdown, input: :markdown).to_prismic
151
153
  end
152
154
 
153
155
  def test_convert_list_o
154
156
  expected = [
155
157
  {
156
- type: "o-list-item",
158
+ type: 'o-list-item',
157
159
  content: {
158
- text: "This is a list item",
160
+ text: 'This is a list item',
159
161
  spans: [
160
162
  {
161
- type: "em",
163
+ type: 'em',
162
164
  start: 0,
163
165
  end: 4
164
166
  }
@@ -166,9 +168,9 @@ class KramdownPrismicConverterTest < Minitest::Test
166
168
  }
167
169
  },
168
170
  {
169
- type: "o-list-item",
171
+ type: 'o-list-item',
170
172
  content: {
171
- text: "This is a second list item",
173
+ text: 'This is a second list item',
172
174
  spans: []
173
175
  }
174
176
  }
@@ -180,12 +182,12 @@ class KramdownPrismicConverterTest < Minitest::Test
180
182
  def test_convert_list_u
181
183
  expected = [
182
184
  {
183
- type: "list-item",
185
+ type: 'list-item',
184
186
  content: {
185
- text: "This is a list item",
187
+ text: 'This is a list item',
186
188
  spans: [
187
189
  {
188
- type: "em",
190
+ type: 'em',
189
191
  start: 0,
190
192
  end: 4
191
193
  }
@@ -193,9 +195,9 @@ class KramdownPrismicConverterTest < Minitest::Test
193
195
  }
194
196
  },
195
197
  {
196
- type: "list-item",
198
+ type: 'list-item',
197
199
  content: {
198
- text: "This is a second list item",
200
+ text: 'This is a second list item',
199
201
  spans: []
200
202
  }
201
203
  }
@@ -207,16 +209,16 @@ class KramdownPrismicConverterTest < Minitest::Test
207
209
  def test_convert_nested_ul
208
210
  expected = [
209
211
  {
210
- type: "list-item",
212
+ type: 'list-item',
211
213
  content: {
212
214
  text: "item1\n",
213
215
  spans: []
214
216
  }
215
217
  },
216
218
  {
217
- type: "list-item",
219
+ type: 'list-item',
218
220
  content: {
219
- text: "item2",
221
+ text: 'item2',
220
222
  spans: []
221
223
  }
222
224
  }
@@ -230,23 +232,23 @@ class KramdownPrismicConverterTest < Minitest::Test
230
232
  def test_convert_nested_nested_ul
231
233
  expected = [
232
234
  {
233
- type: "list-item",
235
+ type: 'list-item',
234
236
  content: {
235
237
  text: "item1\n",
236
238
  spans: []
237
239
  }
238
240
  },
239
241
  {
240
- type: "list-item",
242
+ type: 'list-item',
241
243
  content: {
242
244
  text: "item2\n",
243
245
  spans: []
244
246
  }
245
247
  },
246
248
  {
247
- type: "list-item",
249
+ type: 'list-item',
248
250
  content: {
249
- text: "item3",
251
+ text: 'item3',
250
252
  spans: []
251
253
  }
252
254
  }
@@ -260,7 +262,7 @@ class KramdownPrismicConverterTest < Minitest::Test
260
262
  def test_convert_preformatted
261
263
  expected = [
262
264
  {
263
- type: "preformatted",
265
+ type: 'preformatted',
264
266
  content: {
265
267
  text: "This is a pre block\n",
266
268
  spans: []
@@ -274,9 +276,9 @@ class KramdownPrismicConverterTest < Minitest::Test
274
276
  def test_convert_blockquote
275
277
  expected = [
276
278
  {
277
- type: "preformatted",
279
+ type: 'preformatted',
278
280
  content: {
279
- text: "This is a blockquote",
281
+ text: 'This is a blockquote',
280
282
  spans: []
281
283
  }
282
284
  }
@@ -287,17 +289,18 @@ class KramdownPrismicConverterTest < Minitest::Test
287
289
 
288
290
  def test_convert_empty
289
291
  expected = []
290
- markdown = ""
292
+ markdown = ''
291
293
  assert_equal expected, Kramdown::Document.new(markdown, input: :markdown).to_prismic
292
294
  end
293
295
 
294
296
  def test_convert_span_blank
295
297
  expected = [
296
- {type: "o-list-item",
297
- content: {
298
- text: "Testtest",
299
- spans: []
300
- }
298
+ {
299
+ type: 'o-list-item',
300
+ content: {
301
+ text: 'Testtest',
302
+ spans: []
303
+ }
301
304
  }
302
305
  ]
303
306
  markdown = "\n1. Test\n\n test\n"
@@ -306,16 +309,16 @@ class KramdownPrismicConverterTest < Minitest::Test
306
309
 
307
310
  def test_convert_hr
308
311
  expected = []
309
- markdown = "---"
312
+ markdown = '---'
310
313
  assert_equal expected, Kramdown::Document.new(markdown, input: :markdown).to_prismic
311
314
  end
312
315
 
313
316
  def test_convert_img
314
317
  expected = [
315
318
  {
316
- type: "image",
319
+ type: 'image',
317
320
  content: {
318
- text: "",
321
+ text: '',
319
322
  spans: []
320
323
  },
321
324
  data: {
@@ -326,7 +329,7 @@ class KramdownPrismicConverterTest < Minitest::Test
326
329
  }
327
330
  }
328
331
  ]
329
- markdown = "![alt text](/img.png)"
332
+ markdown = '![alt text](/img.png)'
330
333
  doc = Kramdown::Document.new(markdown)
331
334
  assert_equal expected, doc.to_prismic
332
335
  assert_equal 0, doc.warnings.size
@@ -335,9 +338,9 @@ class KramdownPrismicConverterTest < Minitest::Test
335
338
  def test_convert_double_img
336
339
  expected = [
337
340
  {
338
- type: "image",
341
+ type: 'image',
339
342
  content: {
340
- text: "",
343
+ text: '',
341
344
  spans: []
342
345
  },
343
346
  data: {
@@ -348,9 +351,9 @@ class KramdownPrismicConverterTest < Minitest::Test
348
351
  }
349
352
  },
350
353
  {
351
- type: "image",
354
+ type: 'image',
352
355
  content: {
353
- text: "",
356
+ text: '',
354
357
  spans: []
355
358
  },
356
359
  data: {
@@ -361,7 +364,7 @@ class KramdownPrismicConverterTest < Minitest::Test
361
364
  }
362
365
  }
363
366
  ]
364
- markdown = "![](/img.png)![](/img2.png)"
367
+ markdown = '![](/img.png)![](/img2.png)'
365
368
  doc = Kramdown::Document.new(markdown)
366
369
  assert_equal expected, doc.to_prismic
367
370
  assert_equal 2, doc.warnings.size
@@ -370,9 +373,9 @@ class KramdownPrismicConverterTest < Minitest::Test
370
373
  def test_convert_img_with_link
371
374
  expected = [
372
375
  {
373
- type: "image",
376
+ type: 'image',
374
377
  content: {
375
- text: "",
378
+ text: '',
376
379
  spans: []
377
380
  },
378
381
  data: {
@@ -381,12 +384,12 @@ class KramdownPrismicConverterTest < Minitest::Test
381
384
  },
382
385
  alt: 'alt text',
383
386
  linkTo: {
384
- url: "https://example.net/"
387
+ url: 'https://example.net/'
385
388
  }
386
389
  }
387
390
  }
388
391
  ]
389
- markdown = "[![alt text](/img.png)](https://example.net/)"
392
+ markdown = '[![alt text](/img.png)](https://example.net/)'
390
393
  doc = Kramdown::Document.new(markdown)
391
394
  assert_equal expected, doc.to_prismic
392
395
  assert_equal 0, doc.warnings.size
@@ -395,29 +398,28 @@ class KramdownPrismicConverterTest < Minitest::Test
395
398
  def test_convert_entity
396
399
  expected = [
397
400
  {
398
- type: "paragraph",
401
+ type: 'paragraph',
399
402
  content: {
400
403
  text: "\u00a0",
401
404
  spans: []
402
405
  }
403
406
  }
404
407
  ]
405
- markdown = "&nbsp;"
408
+ markdown = '&nbsp;'
406
409
  assert_equal expected, Kramdown::Document.new(markdown, input: :markdown).to_prismic
407
410
  end
408
411
 
409
- [['mdash' , ' ---', ' —'],
410
- ['ndash' , ' --', ' –'],
411
- ['hellip' , ' ...', ' …'],
412
- ['laquo' , ' <<', ' «'],
413
- ['raquo' , '>>', '»'],
414
- ['laquo_space' , ' << T', ' « T'],
415
- ['raquo_space' , ' >>', ' »']
416
- ].each do |symbol|
412
+ [['mdash', ' ---', ' —'],
413
+ ['ndash', ' --', ' –'],
414
+ ['hellip', ' ...', ' …'],
415
+ ['laquo', ' <<', ' «'],
416
+ ['raquo', '>>', '»'],
417
+ ['laquo_space', ' << T', ' « T'],
418
+ ['raquo_space', ' >>', ' »']].each do |symbol|
417
419
  define_method "test_convert_typographic_symbols_#{symbol[0]}" do
418
420
  expected = [
419
421
  {
420
- type: "paragraph",
422
+ type: 'paragraph',
421
423
  content: {
422
424
  text: "Hello#{symbol[2]}",
423
425
  spans: []
@@ -431,11 +433,12 @@ class KramdownPrismicConverterTest < Minitest::Test
431
433
 
432
434
  def test_convert_smart_quote
433
435
  expected = [
434
- {type: "paragraph",
435
- content: {
436
- text: "Test\u2019",
437
- spans: []
438
- }
436
+ {
437
+ type: 'paragraph',
438
+ content: {
439
+ text: "Test\u2019",
440
+ spans: []
441
+ }
439
442
  }
440
443
  ]
441
444
  markdown = "Test'"
@@ -445,14 +448,14 @@ class KramdownPrismicConverterTest < Minitest::Test
445
448
  def test_convert_inline_code
446
449
  expected = [
447
450
  {
448
- type: "paragraph",
451
+ type: 'paragraph',
449
452
  content: {
450
- text: "Hello code",
453
+ text: 'Hello code',
451
454
  spans: []
452
455
  }
453
456
  }
454
457
  ]
455
- markdown = "Hello `code`"
458
+ markdown = 'Hello `code`'
456
459
  doc = Kramdown::Document.new(markdown)
457
460
  assert_equal expected, doc.to_prismic
458
461
  assert_equal 1, doc.warnings.size
@@ -460,20 +463,54 @@ class KramdownPrismicConverterTest < Minitest::Test
460
463
 
461
464
  def test_convert_br
462
465
  expected = [
463
- {type: "paragraph",
464
- content: {
465
- text: "Test\n",
466
- spans: []
467
- }
466
+ {
467
+ type: 'paragraph',
468
+ content: {
469
+ text: "Test\n",
470
+ spans: []
471
+ }
468
472
  }
469
473
  ]
470
- html = "<p>Test<br></p>"
474
+ html = '<p>Test<br></p>'
471
475
  assert_equal expected, Kramdown::Document.new(html, input: :html).to_prismic
472
476
  end
473
477
 
478
+ def test_convert_html_with_no_tags
479
+ expected = [
480
+ {
481
+ type: 'paragraph',
482
+ content: {
483
+ text: "Test\n",
484
+ spans: []
485
+ }
486
+ }
487
+ ]
488
+ html = 'Test'
489
+ assert_equal expected, Kramdown::Document.new(html, input: :html).to_prismic
490
+ end
491
+
492
+ def test_convert_iframe
493
+ expected = [
494
+ {
495
+ type: 'embed',
496
+ content: {
497
+ text: '',
498
+ spans: []
499
+ },
500
+ data: {
501
+ embed_url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
502
+ type: 'link'
503
+ }
504
+ }
505
+ ]
506
+ html = '<iframe src="https://www.youtube.com/watch?v=dQw4w9WgXcQ"></iframe>'
507
+ doc = Kramdown::Document.new(html, input: :markdown)
508
+ assert_equal expected, doc.to_prismic
509
+ end
510
+
474
511
  def test_convert_html
475
512
  expected = []
476
- html = "<div></div>"
513
+ html = '<div></div>'
477
514
  doc = Kramdown::Document.new(html, input: :markdown)
478
515
  assert_equal expected, doc.to_prismic
479
516
  assert_equal 1, doc.warnings.size
@@ -482,14 +519,14 @@ class KramdownPrismicConverterTest < Minitest::Test
482
519
  def test_convert_span_html
483
520
  expected = [
484
521
  {
485
- type: "paragraph",
522
+ type: 'paragraph',
486
523
  content: {
487
- text: "",
524
+ text: '',
488
525
  spans: []
489
526
  }
490
527
  }
491
528
  ]
492
- html = "<br>"
529
+ html = '<br>'
493
530
  doc = Kramdown::Document.new(html, input: :markdown)
494
531
  assert_equal expected, doc.to_prismic
495
532
  assert_equal 1, doc.warnings.size
@@ -497,7 +534,7 @@ class KramdownPrismicConverterTest < Minitest::Test
497
534
 
498
535
  def test_convert_table
499
536
  expected = []
500
- markdown = "| First cell|Second cell|Third cell|"
537
+ markdown = '| First cell|Second cell|Third cell|'
501
538
  doc = Kramdown::Document.new(markdown, input: :kramdown)
502
539
  assert_equal expected, doc.to_prismic
503
540
  assert_equal 1, doc.warnings.size
@@ -513,7 +550,7 @@ class KramdownPrismicConverterTest < Minitest::Test
513
550
 
514
551
  def test_convert_math
515
552
  expected = []
516
- markdown = "$$ 5 + 5 $$"
553
+ markdown = '$$ 5 + 5 $$'
517
554
  doc = Kramdown::Document.new(markdown, input: :kramdown)
518
555
  assert_equal expected, doc.to_prismic
519
556
  assert_equal 1, doc.warnings.size
@@ -522,12 +559,13 @@ class KramdownPrismicConverterTest < Minitest::Test
522
559
  def test_convert_footnote
523
560
  expected = [
524
561
  {
525
- type: "paragraph",
562
+ type: 'paragraph',
526
563
  content: {
527
- text: "test",
564
+ text: 'test',
528
565
  spans: []
529
566
  }
530
- }]
567
+ }
568
+ ]
531
569
  markdown = "test[^1]\n\n[^1]: test"
532
570
  doc = Kramdown::Document.new(markdown, input: :kramdown)
533
571
  assert_equal expected, doc.to_prismic
@@ -537,37 +575,46 @@ class KramdownPrismicConverterTest < Minitest::Test
537
575
  def test_convert_abbreviation
538
576
  expected = [
539
577
  {
540
- type: "paragraph",
578
+ type: 'paragraph',
541
579
  content: {
542
- text: "HTML",
580
+ text: 'HTML',
543
581
  spans: []
544
582
  }
545
- }]
583
+ }
584
+ ]
546
585
  markdown = "HTML\n\n*[HTML]: test"
547
586
  doc = Kramdown::Document.new(markdown, input: :kramdown)
548
587
  assert_equal expected, doc.to_prismic
549
588
  assert_equal 1, doc.warnings.size
550
589
  end
551
590
 
552
- def test_convert_comment
591
+ def test_convert_xml_comment
553
592
  expected = []
554
- markdown = "{::comment}\nComment\n{:/comment}"
593
+ markdown = "<!-- Main -->"
555
594
  doc = Kramdown::Document.new(markdown, input: :kramdown)
556
595
  assert_equal expected, doc.to_prismic
557
596
  assert_equal 1, doc.warnings.size
558
597
  end
559
598
 
560
- def test_convert_xml_comment
561
- expected = []
562
- markdown = "<!-- a *comment* -->"
599
+ def test_convert_span_xml_comment
600
+ expected = [
601
+ {
602
+ type: 'paragraph',
603
+ content: {
604
+ text: 'test test',
605
+ spans: []
606
+ }
607
+ }
608
+ ]
609
+ markdown = "test <!-- Main --> test"
563
610
  doc = Kramdown::Document.new(markdown, input: :kramdown)
564
611
  assert_equal expected, doc.to_prismic
565
612
  assert_equal 1, doc.warnings.size
566
613
  end
567
614
 
568
- def test_convert_xml_pi
615
+ def test_convert_comment
569
616
  expected = []
570
- markdown = "<? a processing `instruction`?>"
617
+ markdown = "{::comment}\nComment\n{:/comment}"
571
618
  doc = Kramdown::Document.new(markdown, input: :kramdown)
572
619
  assert_equal expected, doc.to_prismic
573
620
  assert_equal 1, doc.warnings.size