kramdown-prismic 0.3.7 → 0.3.8

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: b7a99099eccb44fd82519a9894193733e143af6fbe445a88db2f805cb44fd58d
4
+ data.tar.gz: 68f3628a12418f3b49db676257266100c54a8a5962e88c5a5dd38bae7ac33ec5
5
5
  SHA512:
6
- metadata.gz: 7da022135525388a0fb64b091804e65cef0e1307e7ff2cfb0203f3c007fc736393d600dd3119441073fcb73fed956ad45b015d90d4b720ecfacc8851d7132a4e
7
- data.tar.gz: 7fbf4b233127d8bba128bcad4624ca13008f1a0dbc6e8c8a7121ac87c8fd72e11f90b046a738cb516965da42ef9c228fcab13fee2bbbc931e98ebbc5a3871701
6
+ metadata.gz: 6c98ec156b50ac771e18415a770068c2a84911d34fe2b2fe083c7eab4a3f0e311d0aad0a71ed625e4a4d85da49fb6f9cb612f317a2a87814dbca93505cb2a977
7
+ data.tar.gz: 65f6a3250e46ec0e6d256fa42cebd6feb5036ca4564ee5d3ff172bf911a7b520119451fec8bde608108f57d79850b3a7a7619adc29a4119b61553ba91d59d08a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.3.8
4
+
5
+ - Convert nested html_elements when converting from HTML.
6
+
3
7
  ## Version 0.3.7
4
8
 
5
9
  - 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.8)
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.3.2)
11
11
  rexml
12
12
  minitest (5.10.3)
13
13
  rake (13.0.6)
@@ -282,8 +282,12 @@ module Kramdown
282
282
  memo[:text] += element.value
283
283
  end
284
284
 
285
- def extract_span_html_element(_element, _memo)
286
- warning('translating html elements is not supported')
285
+ def extract_span_html_element(element, memo)
286
+ if respond_to?("extract_span_#{element.value}", true)
287
+ send("extract_span_#{element.value}", element, memo)
288
+ else
289
+ warning("translating html element '#{element.value}' is not supported")
290
+ end
287
291
  end
288
292
 
289
293
  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.8'
5
5
  end
@@ -322,7 +322,7 @@ class KramdownPrismicConverterTest < Minitest::Test
322
322
  assert_equal 2, doc.warnings.size
323
323
  end
324
324
 
325
- def test_convert_heading_in_list
325
+ def test_convert_heading_in_list
326
326
  expected = [
327
327
  {
328
328
  type: 'list-item',
@@ -576,11 +576,16 @@ class KramdownPrismicConverterTest < Minitest::Test
576
576
  end
577
577
 
578
578
  def test_convert_html_with_no_tags
579
+ expected_text = if Gem::Version.new(Kramdown::VERSION) >= Gem::Version.new("2.3.2")
580
+ "Test "
581
+ else
582
+ "Test\n"
583
+ end
579
584
  expected = [
580
585
  {
581
586
  type: 'paragraph',
582
587
  content: {
583
- text: "Test\n",
588
+ text: expected_text,
584
589
  spans: []
585
590
  }
586
591
  }
@@ -616,12 +621,34 @@ class KramdownPrismicConverterTest < Minitest::Test
616
621
  assert_equal 1, doc.warnings.size
617
622
  end
618
623
 
619
- def test_convert_span_html
624
+ def test_convert_span_html_strong
620
625
  expected = [
621
626
  {
622
627
  type: 'paragraph',
623
628
  content: {
624
- text: '',
629
+ text: 'This is a paragraph',
630
+ spans: [
631
+ {
632
+ type: 'strong',
633
+ start: 10,
634
+ end: 20
635
+ }
636
+ ]
637
+ }
638
+ }
639
+ ]
640
+ html = '<p>This is a <strong> paragraph</strong></p>'
641
+ doc = Kramdown::Document.new(html, input: :html)
642
+ assert_equal expected, doc.to_prismic
643
+ assert_equal 0, doc.warnings.size
644
+ end
645
+
646
+ def test_convert_span_html_br
647
+ expected = [
648
+ {
649
+ type: 'paragraph',
650
+ content: {
651
+ text: "\n",
625
652
  spans: []
626
653
  }
627
654
  }
@@ -629,7 +656,24 @@ class KramdownPrismicConverterTest < Minitest::Test
629
656
  html = '<br>'
630
657
  doc = Kramdown::Document.new(html, input: :markdown)
631
658
  assert_equal expected, doc.to_prismic
659
+ assert_equal 0, doc.warnings.size
660
+ end
661
+
662
+ def test_convert_span_html_unknown
663
+ expected = [
664
+ {
665
+ type: 'paragraph',
666
+ content: {
667
+ text: 'This is a ',
668
+ spans: []
669
+ }
670
+ }
671
+ ]
672
+ html = '<p>This is a <details>detail</details></p>'
673
+ doc = Kramdown::Document.new(html, input: :html)
674
+ assert_equal expected, doc.to_prismic
632
675
  assert_equal 1, doc.warnings.size
676
+ assert_equal "translating html element 'details' is not supported", doc.warnings.first
633
677
  end
634
678
 
635
679
  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.8
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-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown