bookify 1.1.0 → 1.2.0

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: fafe9996998273e97ffd7874c18db4077c9c2bea
4
- data.tar.gz: 8a4ffbb249602607ecf7a0e4b9d38d8dc626218f
3
+ metadata.gz: a1f11d3d92553b316f41606cd35f26783f956ae6
4
+ data.tar.gz: fbcf7c3f7b4f8ae8451eef3f7b195b63f9d07c77
5
5
  SHA512:
6
- metadata.gz: 013c6addb1e03b7c993c614ec1225e4876b90e9b47c1aca4611ae3440629817f1a6f81e128a1dd2df0aea68af80d923880059b45fe153dce7ea4f5039c1d1366
7
- data.tar.gz: c8b96c72d3f625d310c7ab85cff8d71f2ffa223d1fd3623d972e30f5d8603db20e09f13f1581bd30cf50d41477463a4b6f5be205dd6dc2b674f703d48e2ec840
6
+ metadata.gz: 983b4923d424cc8872f6b60609da3fca51ff2f1e5183ea728bca3c2b07230181a78040cb779fa9cd742b9a6dc505eb27fa6c72de33696c97c712273b0f24c383
7
+ data.tar.gz: 3be515fa5dc0bf9eee840f61368d83f372ab21dd536e6762c68ed4379857bb4543a0b97f2cae2d803df9f225bf0e0b56effb8b46a689bd4b9c753604c15d4b0c
@@ -38,5 +38,9 @@ module Bookify::Node
38
38
  def decode_html(html)
39
39
  HTMLEntities.new.decode(html)
40
40
  end
41
+
42
+ def break_if_close_to_bottom(tolerance = 100)
43
+ bounds.move_past_bottom if pdf.y <= tolerance
44
+ end
41
45
  end
42
46
  end
@@ -1,11 +1,16 @@
1
1
  module Bookify::Node
2
2
  class H1 < Base
3
3
  def render
4
- move_down 20 unless pdf.bounds.top == 0.0
4
+ break_if_close_to_bottom(250)
5
+ move_down 20 unless pdf.y == page_top
5
6
  font :h1
6
7
  html = decode_html(node.inner_html.strip)
7
8
  text html, align: :center
8
9
  move_down 10
9
10
  end
11
+
12
+ def page_top
13
+ pdf.bounds.parent.height + 50
14
+ end
10
15
  end
11
16
  end
@@ -3,6 +3,7 @@ module Bookify::Node
3
3
  def render
4
4
  font :h2
5
5
  move_down 5
6
+ break_if_close_to_bottom
6
7
  text decode_html(node.inner_html.strip)
7
8
  move_down 1
8
9
  stroke { horizontal_rule }
@@ -3,6 +3,7 @@ module Bookify::Node
3
3
  def render
4
4
  font :h3
5
5
  move_down 5
6
+ break_if_close_to_bottom
6
7
  text decode_html(node.inner_html.strip)
7
8
  move_down 2
8
9
  end
@@ -2,6 +2,7 @@ module Bookify::Node
2
2
  class H4 < Base
3
3
  def render
4
4
  move_down 5
5
+ break_if_close_to_bottom
5
6
  font :h4
6
7
  text decode_html(node.inner_html.strip)
7
8
  move_down 2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joey Schoblaska