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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76310dc21b93fc2bb4aace8b18ce91e1712e6b9b
4
- data.tar.gz: 7c5d2386b6c74204ce86b538ace393019227dff5
3
+ metadata.gz: e580b82c75e3cf43132b59a8ad149e2d390d8be7
4
+ data.tar.gz: df4a31f298410004501ab0dad411f901e9394be4
5
5
  SHA512:
6
- metadata.gz: b6e92e7ca7d97ca96efa12a38dddaf9b29339e8f1b3c24624c51b572f6016dcb4b81ca1a10d871e968dec96b488c397c2c4b64ab498d1fc212dddd7335226763
7
- data.tar.gz: 563d9f78a6c41ac2a824510295e3fade5d671c95a261e97974fbbba5ee66f93da99f2530cfab7f1cde02611d7fb262596a11ecc93f99635bfc9cec9629172b25
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>)/, '&nbsp;\1')
46
+ rendered = options[:orphans] ? rendered : rendered.gsub(/\s(\S+\s*<\/(?:p|li)>)/, '&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.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -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&nbsp;text.</p>
56
67
 
57
68
  <p>It should include multiple&nbsp;paragraphs.</p>
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.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Horner