text_helpers 0.1.6 → 0.1.7

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
  SHA1:
3
- metadata.gz: 776df8d7a9be3cdd18ae750affd047db2054a54d
4
- data.tar.gz: de1b56e9e926fd136d4f21b83d5f2bd32aca3945
3
+ metadata.gz: 76310dc21b93fc2bb4aace8b18ce91e1712e6b9b
4
+ data.tar.gz: 7c5d2386b6c74204ce86b538ace393019227dff5
5
5
  SHA512:
6
- metadata.gz: 297235af410582b99cd195e5cd9d5c0e6a7d75bf2605ba5919cb863a0bd30f761c9aa8d987ebb074660a0d3dfd44e8b905d5573ad39cb544226d889086a9e82c
7
- data.tar.gz: 8ab0165dcd09fc8a1f60d20f7a1b7f2f47331e2e65c20204ae397b2a60e4fafe2550b131491df80674b26e10eb4c2d7991129186703d8703c5d845cf3ac6316e
6
+ metadata.gz: b6e92e7ca7d97ca96efa12a38dddaf9b29339e8f1b3c24624c51b572f6016dcb4b81ca1a10d871e968dec96b488c397c2c4b64ab498d1fc212dddd7335226763
7
+ data.tar.gz: 563d9f78a6c41ac2a824510295e3fade5d671c95a261e97974fbbba5ee66f93da99f2530cfab7f1cde02611d7fb262596a11ecc93f99635bfc9cec9629172b25
@@ -43,7 +43,7 @@ module TextHelpers
43
43
  def html(key, options = {})
44
44
  rendered = GitHub::Markdown.render(text(key, options.merge(orphans: true)))
45
45
 
46
- rendered = options[:orphans] ? rendered : rendered.sub(/\s(\S+\s*<\/p>)/, '&nbsp;\1')
46
+ rendered = options[:orphans] ? rendered : rendered.gsub(/\s(\S+\s*<\/p>)/, '&nbsp;\1')
47
47
  rendered = rendered.gsub(/<\/?p>/, '') if options[:inline]
48
48
  rendered.html_safe
49
49
  end
@@ -1,3 +1,3 @@
1
1
  module TextHelpers
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -8,12 +8,18 @@ describe TextHelpers::Translation do
8
8
  before do
9
9
  @scoped_text = "Scoped lookup"
10
10
  @global_text = "Global lookup"
11
+ @multiline_text = <<-MULTI.gsub(/^[ \t]*/, '')
12
+ This is some multiline text.
13
+
14
+ It should include multiple paragraphs.
15
+ MULTI
11
16
 
12
17
  @nb_scoped_text = "Scoped&nbsp;lookup"
13
18
  @nb_global_text = "Global&nbsp;lookup"
14
19
 
15
20
  I18n.backend.store_translations :en, {
16
21
  test_key: @global_text,
22
+ multiline_key: @multiline_text,
17
23
  test: {
18
24
  test_key: "*#{@scoped_text}*",
19
25
  interpolated_key: "Global? (!test_key!)"
@@ -44,6 +50,15 @@ describe TextHelpers::Translation do
44
50
  assert_equal "<p><em>#{@scoped_text}</em></p>\n", @helper.html(:test_key, orphans: true)
45
51
  end
46
52
 
53
+ it "correctly eliminates orphans across multiple paragraphs" do
54
+ expected = <<-EXPECTED.gsub(/^[ \t]*/, '')
55
+ <p>This is some multiline&nbsp;text.</p>
56
+
57
+ <p>It should include multiple&nbsp;paragraphs.</p>
58
+ EXPECTED
59
+ assert_equal expected, @helper.html(:multiline_key)
60
+ end
61
+
47
62
  it "removes the enclosing paragraph with :inline" do
48
63
  assert_equal "<em>#{@nb_scoped_text}</em>\n", @helper.html(:test_key, inline: true)
49
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Horner