sablon 0.0.19.beta2 → 0.0.19.beta3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d201139ea7689ee5ece96bdb890b1241714863a
4
- data.tar.gz: 43073c128829d00d470669b734ecae7430aaaed6
3
+ metadata.gz: 43e4aa5cc44824e41d65481d0b32a1f97a94ea2c
4
+ data.tar.gz: 9fb8f9890f54cd1169ade7b178a2f995bc12d37b
5
5
  SHA512:
6
- metadata.gz: 822d41137b73c13abd5102b757f9de9814c822fcb0cffde2e57b0bfc07a978791a5f6d2119671e479cc7aa44a4cd9a616ac4df8e1a8f6f76c0bd357ee6968bcb
7
- data.tar.gz: 48a8398f40eebe6df13967b37a413702bee477d245b9c93a7d4375c4be51c39639d861fc18614453a71d5f8ccc71d081457057bb07a9c3f2d4b9c65cea7edc19
6
+ metadata.gz: 04ed4067045f1067cf36f98bc9139b869e66179a75f009d774e547df9a138b029ca2d47266e2e5019c70592b1e3821a921e01d93dfc22e74a377fc7f14647c9f
7
+ data.tar.gz: 40435b0860b374a75e07343793d55d66b6a880b9df3b0951206171cdc961146f79204c5e7fd0988655ad3867a46b26720bfc6874b7cc588ac7852c85ddeeae07
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sablon (0.0.19.beta2)
4
+ sablon (0.0.19.beta3)
5
5
  nokogiri (>= 1.6.0)
6
6
  redcarpet (>= 3.2)
7
7
  rubyzip (>= 1.1)
@@ -69,6 +69,7 @@ module Sablon
69
69
 
70
70
  def processed_ast(input)
71
71
  ast = build_ast(input)
72
+ ast.accept LastNewlineRemoverVisitor.new
72
73
  ast
73
74
  end
74
75
 
@@ -22,5 +22,13 @@ module Sablon
22
22
  end
23
23
  end
24
24
  end
25
+
26
+ class LastNewlineRemoverVisitor < Visitor
27
+ def visit_Paragraph(par)
28
+ if HTMLConverter::Newline === par.runs.nodes.last
29
+ par.runs.nodes.pop
30
+ end
31
+ end
32
+ end
25
33
  end
26
34
  end
@@ -1,3 +1,3 @@
1
1
  module Sablon
2
- VERSION = "0.0.19.beta2"
2
+ VERSION = "0.0.19.beta3"
3
3
  end
@@ -275,6 +275,18 @@ class HTMLConverterASTTest < Sablon::TestCase
275
275
  assert_equal ['Paragraph'], ast.map(&:style)
276
276
  end
277
277
 
278
+ def test_ignore_last_br_in_div
279
+ input = '<div>Lorem ipsum dolor sit amet<br /></div>'
280
+ par = @converter.processed_ast(input).to_a.first
281
+ assert_equal [Sablon::HTMLConverter::Text], par.runs.nodes.map(&:class)
282
+ end
283
+
284
+ def test_ignore_br_in_blank_div
285
+ input = '<div><br /></div>'
286
+ par = @converter.processed_ast(input).to_a.first
287
+ assert_equal [], par.runs.nodes.map(&:class)
288
+ end
289
+
278
290
  def test_ul
279
291
  input = '<ul><li>Lorem</li><li>ipsum</li></ul>'
280
292
  ast = @converter.processed_ast(input).to_a
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sablon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19.beta2
4
+ version: 0.0.19.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Senn