bible270 1.6.1 → 1.6.2

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
  SHA256:
3
- metadata.gz: c39318054ec3245ba579a3c7f14ece0d8749cfd6bcf4209e90338ac48fe0294c
4
- data.tar.gz: 05cfa41ce39280c39c6a278503a1f89248a2a057b96cda3c9e994dd831840864
3
+ metadata.gz: 10dd20a51ceee2f549e465ad8826eaa1211c6722c08f2ecf6e81f5ec885eeb90
4
+ data.tar.gz: 598254caeb9eb32a2464663895c64ec0c3eec85cc98705b8da0ed05facb10141
5
5
  SHA512:
6
- metadata.gz: 759bbd980b0f1994719f0323b487bd86270fc3b0ae6489899c849a807f5cef9e0c528da104881a3602b68ab8d734aa9ff8b507019ebbd427641128bff4f55db6
7
- data.tar.gz: 7c2c28f53b206dba13947676da4b7c9d2468fcfa7a1e202f2c0850602732fa11a0185462b37a6ee1965000d60dab5b7463b8f8e58a1552bf9ec0ea825c282470
6
+ metadata.gz: 3e587617e2a3d06e1e26cead51a0b96c87a6468b93e53bb03b60ab7a87931cc602f4b3ec5fb72c6b712a0b01a1dffc44a2d15422510e8064b7da881d44d9d31b
7
+ data.tar.gz: b64e61b9682538bf19be6aa6dc428ebc67b8e43808192e29fa6cb04aeac8747e6264ba320c18c6cdc800b6c7a14fafb6eafc1f352fbf7f55b4572248a1699922
@@ -26,8 +26,11 @@ module Bible270
26
26
  source = body.to_s
27
27
  rendered = format == MARKDOWN ? markdown_html(source) : plain_html(source)
28
28
  fragment = fragment_for(sanitize(rendered))
29
- hard_wrap(fragment) if format == MARKDOWN
30
- link_urls(fragment) if format == MARKDOWN
29
+ if format == MARKDOWN
30
+ normalize_lists(fragment)
31
+ hard_wrap(fragment)
32
+ link_urls(fragment)
33
+ end
31
34
  decorate_links(fragment)
32
35
  link_mentions(fragment, &mention_path) if mention_path
33
36
  fragment.to_html
@@ -82,6 +85,20 @@ module Bible270
82
85
  end
83
86
  private_class_method :fragment_for
84
87
 
88
+ # Blank lines between Markdown list items make Kramdown wrap each item's
89
+ # content in a paragraph. For a simple item, remove that structural wrapper
90
+ # and its indentation so loose and compact lists render identically.
91
+ def normalize_lists(fragment)
92
+ fragment.xpath('.//li/text()[normalize-space(.) = ""]').remove
93
+ fragment.css('li').each do |item|
94
+ children = item.element_children
95
+ next unless children.one? && children.first.name == 'p'
96
+
97
+ children.first.replace(children.first.children)
98
+ end
99
+ end
100
+ private_class_method :normalize_lists
101
+
85
102
  def hard_wrap(fragment)
86
103
  fragment.xpath('.//p//text() | .//li//text()').to_a.each do |node|
87
104
  next unless node.text.include?("\n")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bible270
4
- VERSION = '1.6.1'
4
+ VERSION = '1.6.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bible270
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew vonderLuft