structured_text_renderer 0.0.1 → 0.0.2

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: d51d294c923676f4c5663d139b9b33a6f4e1991c454777d4ea7294352d8bdcf2
4
- data.tar.gz: 38103cd1b5ed95db1638932d859e9e8d8e5f292b1c19ec9d1819dbf05cd82349
3
+ metadata.gz: ff486ce1ca970aeaa56f4a3b3b7f07b4da32e97994572b4385599bd95829454d
4
+ data.tar.gz: 21f37a8f370e260a9e55db4629cce77a79e0a1b30e83ababe458bcfdc37e4bd1
5
5
  SHA512:
6
- metadata.gz: dc77f8c124c2dc9d1dfc1a96355091223f94e44bb5ead763d0fa0ad58bd66038bbde2f132a6626bc598d63573753584f4e452b2092348f8947bd7cb9843337b1
7
- data.tar.gz: 6d6c075c0a1980e50b034a919ac7c96ba09ab79cbc5ca55f09c2861662b96c0489008aefea8d38ce46a51a637c835f9a5449cfaba29f97cd8b9f1b4a6379d5ee
6
+ metadata.gz: 239694eff6e0eb957ca0c4c0983c19204cdd73e2c83842d6013cec5808c81b9c8c553961d56ca19a9a9d3b0af6b9b51e034c18765d70fd9ecbe05108110929b1
7
+ data.tar.gz: 0d060f82f28032661089c29930756522ef8a6b4d5311596573b6761150e57ab92fa41ad10f59ecbb5256c210d2f04495efbb8cd931894875977f0acd6bc8310c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## Unreleased
4
+
5
+ ## v0.0.2
6
+
7
+ ### Fixed
8
+ * Fixed rendering logic for block type nodes
9
+
3
10
  ## v0.0.1
4
11
 
5
12
  * Initial Release
@@ -5,14 +5,18 @@ module StructuredTextRenderer
5
5
  class BaseBlockRenderer < BaseNodeRenderer
6
6
  # Renders block type nodes.
7
7
  def render(node)
8
- node['content'].each_with_object([]) do |content_node, result|
9
- renderer = find_renderer(content_node)
10
- result << "<#{render_tag}>#{renderer.render(content_node)}</#{render_tag}>"
11
- end.join("\n")
8
+ "<#{render_tag}>#{render_content(node)}</#{render_tag}>"
12
9
  end
13
10
 
14
11
  protected
15
12
 
13
+ def render_content(node)
14
+ node['content'].each_with_object([]) do |content_node, result|
15
+ renderer = find_renderer(content_node)
16
+ result << renderer.render(content_node)
17
+ end.join
18
+ end
19
+
16
20
  def render_tag
17
21
  'div'
18
22
  end
@@ -5,11 +5,7 @@ module StructuredTextRenderer
5
5
  class HyperlinkRenderer < BaseBlockRenderer
6
6
  # Renders hyperlink
7
7
  def render(node)
8
- content = node['content'].each_with_object([]) do |content_node, result|
9
- renderer = find_renderer(content_node)
10
- result << renderer.render(content_node)
11
- end.join
12
- "<a href=\"#{node['data']['uri']}\">#{content}</a>"
8
+ "<a href=\"#{node['data']['uri']}\">#{render_content(node)}</a>"
13
9
  end
14
10
  end
15
11
  end
@@ -1,4 +1,4 @@
1
1
  module StructuredTextRenderer
2
2
  # Gem Version
3
- VERSION = '0.0.1'.freeze
3
+ VERSION = '0.0.2'.freeze
4
4
  end
@@ -4,6 +4,8 @@ mock_node = {"content" => [{"value" => "foo", "nodeType" => "text"}]}
4
4
 
5
5
  mock_node_with_marks = {"content" => [{"value" => "foo", "nodeType" => "text", "marks" => [{"type" => "bold"}]}]}
6
6
 
7
+ mock_node_with_multiple_content_nodes = {"content" => [{"value" => "foo", "nodeType" => "text"}, {"value" => " bar", "nodeType" => "text", "marks" => [{"type" => "bold"}]}]}
8
+
7
9
  describe StructuredTextRenderer::ParagraphRenderer do
8
10
  subject do
9
11
  described_class.new(
@@ -20,5 +22,9 @@ describe StructuredTextRenderer::ParagraphRenderer do
20
22
  it 'will propagate marks to text renderers' do
21
23
  expect(subject.render(mock_node_with_marks)).to eq "<p><b>foo</b></p>"
22
24
  end
25
+
26
+ it 'will properly render multiple content nodes' do
27
+ expect(subject.render(mock_node_with_multiple_content_nodes)).to eq "<p>foo<b> bar</b></p>"
28
+ end
23
29
  end
24
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structured_text_renderer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Contentful GmbH (David Litvak Bruno)