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 +4 -4
- data/lib/text_helpers/translation.rb +1 -1
- data/lib/text_helpers/version.rb +1 -1
- data/test/lib/text_helpers/translation_test.rb +15 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76310dc21b93fc2bb4aace8b18ce91e1712e6b9b
|
4
|
+
data.tar.gz: 7c5d2386b6c74204ce86b538ace393019227dff5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
46
|
+
rendered = options[:orphans] ? rendered : rendered.gsub(/\s(\S+\s*<\/p>)/, ' \1')
|
47
47
|
rendered = rendered.gsub(/<\/?p>/, '') if options[:inline]
|
48
48
|
rendered.html_safe
|
49
49
|
end
|
data/lib/text_helpers/version.rb
CHANGED
@@ -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 lookup"
|
13
18
|
@nb_global_text = "Global 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 text.</p>
|
56
|
+
|
57
|
+
<p>It should include multiple 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
|