text_helpers 0.1.7 → 0.1.8
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 +13 -2
- 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: e580b82c75e3cf43132b59a8ad149e2d390d8be7
|
4
|
+
data.tar.gz: df4a31f298410004501ab0dad411f901e9394be4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65bee9783a1513a997add55402ee2dcef6da947f79cbe7ea893571aae457b47cd99501a2500a6add832c1321c89ecfa4d1e35554d68dfc382cf84d94eb8abc39
|
7
|
+
data.tar.gz: 383ee4e7373779411aa47b22dbb62e08897305c2c6c1e51f99dd0d4350f909e7b43c6bf019c74d04ec310483cc5c583120dad5b63b2b63c14f38ddb5f094f63a
|
@@ -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.gsub(/\s(\S+\s*<\/p>)/, ' \1')
|
46
|
+
rendered = options[:orphans] ? rendered : rendered.gsub(/\s(\S+\s*<\/(?:p|li)>)/, ' \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,7 +8,7 @@ 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]
|
11
|
+
@multiline_text = <<-MULTI.gsub(/^[ \t]+/, '')
|
12
12
|
This is some multiline text.
|
13
13
|
|
14
14
|
It should include multiple paragraphs.
|
@@ -22,6 +22,7 @@ describe TextHelpers::Translation do
|
|
22
22
|
multiline_key: @multiline_text,
|
23
23
|
test: {
|
24
24
|
test_key: "*#{@scoped_text}*",
|
25
|
+
list_key: "* #{@scoped_text}",
|
25
26
|
interpolated_key: "Global? (!test_key!)"
|
26
27
|
}
|
27
28
|
}
|
@@ -46,12 +47,22 @@ describe TextHelpers::Translation do
|
|
46
47
|
assert_equal "<p><em>#{@nb_scoped_text}</em></p>\n", @helper.html(:test_key)
|
47
48
|
end
|
48
49
|
|
50
|
+
it "handles orphans within HTML list items" do
|
51
|
+
expected = <<-EXPECTED.gsub(/^[ \t]+/, '')
|
52
|
+
<ul>
|
53
|
+
<li>#{@nb_scoped_text}</li>
|
54
|
+
</ul>
|
55
|
+
EXPECTED
|
56
|
+
|
57
|
+
assert_equal expected, @helper.html(:list_key)
|
58
|
+
end
|
59
|
+
|
49
60
|
it "allows orphaned text with :orphans" do
|
50
61
|
assert_equal "<p><em>#{@scoped_text}</em></p>\n", @helper.html(:test_key, orphans: true)
|
51
62
|
end
|
52
63
|
|
53
64
|
it "correctly eliminates orphans across multiple paragraphs" do
|
54
|
-
expected = <<-EXPECTED.gsub(/^[ \t]
|
65
|
+
expected = <<-EXPECTED.gsub(/^[ \t]+/, '')
|
55
66
|
<p>This is some multiline text.</p>
|
56
67
|
|
57
68
|
<p>It should include multiple paragraphs.</p>
|