kramdown-prismic 0.3.7 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c409891cb5fb66652154697c053d2f4898c2bdbdb40f90a42df53eb2c41994f2
4
- data.tar.gz: aa59f8c4ea6b262abbadea2a810e91901a3bb719bf28dd94206b17d2f46a5204
3
+ metadata.gz: 9fe817ad7275c3d276c64cd35609274de82861b51dd33a96b91b712681c3ccec
4
+ data.tar.gz: 86564f1a73cecc37c72584f01d028fcc477479e8256c6d5d8c70e456811267c5
5
5
  SHA512:
6
- metadata.gz: 7da022135525388a0fb64b091804e65cef0e1307e7ff2cfb0203f3c007fc736393d600dd3119441073fcb73fed956ad45b015d90d4b720ecfacc8851d7132a4e
7
- data.tar.gz: 7fbf4b233127d8bba128bcad4624ca13008f1a0dbc6e8c8a7121ac87c8fd72e11f90b046a738cb516965da42ef9c228fcab13fee2bbbc931e98ebbc5a3871701
6
+ metadata.gz: 5b08711e01100c77f6ba4aac0034cf44a08ce04cabfc7bccf9ffe5687670f2156bc3ee9d07c5ba3990b0df38982b50e3c16bd2807b93b6805987d0baa3103ecc
7
+ data.tar.gz: 43c728bbaad8e7edd47e287d615b152179ebde1b6255464f0f9d2b489c96a416932abae1c813fc3dbf430ae6f841baa3912b7f8113d23a5074a2166287525095
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.3.10
4
+
5
+ - Fix the embed_url conversion
6
+
7
+ ## Version 0.3.9
8
+
9
+ - Convert the target attribute on links
10
+
11
+ ## Version 0.3.8
12
+
13
+ - Convert nested html_elements when converting from HTML.
14
+
3
15
  ## Version 0.3.7
4
16
 
5
17
  - Fix converting nested headers
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kramdown-prismic (0.3.7)
4
+ kramdown-prismic (0.3.10)
5
5
  kramdown (>= 1, < 3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- kramdown (2.3.1)
10
+ kramdown (2.4.0)
11
11
  rexml
12
12
  minitest (5.10.3)
13
13
  rake (13.0.6)
@@ -179,7 +179,7 @@ module Kramdown
179
179
  },
180
180
  type: 'embed',
181
181
  data: {
182
- embed_url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
182
+ embed_url: element.attr['src'],
183
183
  type: 'link'
184
184
  }
185
185
  }
@@ -249,10 +249,12 @@ module Kramdown
249
249
  end
250
250
 
251
251
  def extract_span_a(element, memo)
252
+ target = element.attr['target']
252
253
  insert_span(element, memo, {
253
254
  type: 'hyperlink',
254
255
  data: {
255
- url: element.attr['href']
256
+ url: element.attr['href'],
257
+ **(target ? { target: target } : {}),
256
258
  }
257
259
  })
258
260
  end
@@ -282,8 +284,12 @@ module Kramdown
282
284
  memo[:text] += element.value
283
285
  end
284
286
 
285
- def extract_span_html_element(_element, _memo)
286
- warning('translating html elements is not supported')
287
+ def extract_span_html_element(element, memo)
288
+ if respond_to?("extract_span_#{element.value}", true)
289
+ send("extract_span_#{element.value}", element, memo)
290
+ else
291
+ warning("translating html element '#{element.value}' is not supported")
292
+ end
287
293
  end
288
294
 
289
295
  def extract_span_footnote(_element, _memo)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KramdownPrismic
4
- VERSION = '0.3.7'
4
+ VERSION = '0.3.10'
5
5
  end
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'minitest/autorun'
@@ -322,7 +321,7 @@ class KramdownPrismicConverterTest < Minitest::Test
322
321
  assert_equal 2, doc.warnings.size
323
322
  end
324
323
 
325
- def test_convert_heading_in_list
324
+ def test_convert_heading_in_list
326
325
  expected = [
327
326
  {
328
327
  type: 'list-item',
@@ -576,11 +575,16 @@ class KramdownPrismicConverterTest < Minitest::Test
576
575
  end
577
576
 
578
577
  def test_convert_html_with_no_tags
578
+ expected_text = if Gem::Version.new(Kramdown::VERSION) >= Gem::Version.new("2.3.2")
579
+ "Test "
580
+ else
581
+ "Test\n"
582
+ end
579
583
  expected = [
580
584
  {
581
585
  type: 'paragraph',
582
586
  content: {
583
- text: "Test\n",
587
+ text: expected_text,
584
588
  spans: []
585
589
  }
586
590
  }
@@ -608,6 +612,21 @@ class KramdownPrismicConverterTest < Minitest::Test
608
612
  assert_equal expected, doc.to_prismic
609
613
  end
610
614
 
615
+ def test_convert_link
616
+ expected = [
617
+ {
618
+ type: 'paragraph',
619
+ content: {
620
+ text: 'Test',
621
+ spans: [{type: 'hyperlink', data: {url: 'http://example.net', target: '_blank'}, start: 0, end: 4}]
622
+ }
623
+ }
624
+ ]
625
+ html = '<a href="http://example.net" target="_blank">Test</a>'
626
+ doc = Kramdown::Document.new(html, input: :markdown)
627
+ assert_equal expected, doc.to_prismic
628
+ end
629
+
611
630
  def test_convert_html
612
631
  expected = []
613
632
  html = '<div></div>'
@@ -616,12 +635,34 @@ class KramdownPrismicConverterTest < Minitest::Test
616
635
  assert_equal 1, doc.warnings.size
617
636
  end
618
637
 
619
- def test_convert_span_html
638
+ def test_convert_span_html_strong
620
639
  expected = [
621
640
  {
622
641
  type: 'paragraph',
623
642
  content: {
624
- text: '',
643
+ text: 'This is a paragraph',
644
+ spans: [
645
+ {
646
+ type: 'strong',
647
+ start: 10,
648
+ end: 20
649
+ }
650
+ ]
651
+ }
652
+ }
653
+ ]
654
+ html = '<p>This is a <strong> paragraph</strong></p>'
655
+ doc = Kramdown::Document.new(html, input: :html)
656
+ assert_equal expected, doc.to_prismic
657
+ assert_equal 0, doc.warnings.size
658
+ end
659
+
660
+ def test_convert_span_html_br
661
+ expected = [
662
+ {
663
+ type: 'paragraph',
664
+ content: {
665
+ text: "\n",
625
666
  spans: []
626
667
  }
627
668
  }
@@ -629,7 +670,24 @@ class KramdownPrismicConverterTest < Minitest::Test
629
670
  html = '<br>'
630
671
  doc = Kramdown::Document.new(html, input: :markdown)
631
672
  assert_equal expected, doc.to_prismic
673
+ assert_equal 0, doc.warnings.size
674
+ end
675
+
676
+ def test_convert_span_html_unknown
677
+ expected = [
678
+ {
679
+ type: 'paragraph',
680
+ content: {
681
+ text: 'This is a ',
682
+ spans: []
683
+ }
684
+ }
685
+ ]
686
+ html = '<p>This is a <details>detail</details></p>'
687
+ doc = Kramdown::Document.new(html, input: :html)
688
+ assert_equal expected, doc.to_prismic
632
689
  assert_equal 1, doc.warnings.size
690
+ assert_equal "translating html element 'details' is not supported", doc.warnings.first
633
691
  end
634
692
 
635
693
  def test_convert_table
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.3.7
4
+ version: 0.3.10
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: 2021-10-13 00:00:00.000000000 Z
11
+ date: 2022-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown