bookify 2.0.0 → 2.1.0
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 +4 -4
- data/lib/bookify/renderer.rb +6 -4
- 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: f23a775e5028eaf16b107b248c9dffa70db37f9a
|
4
|
+
data.tar.gz: e7d2856954ca690cd95eabeee2fa5fe6813bcb7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe2864dff4466b630ea3bda1c62801da54ade54536c1c5b708303a19dfb64383bb3bea17ae9e1d5d228803b1902e9d01d8026fe85338dc106838808bf529d437
|
7
|
+
data.tar.gz: 414358a289aed313ab20f212e9d811045e26f194c9df23a40d801bc0125157ac937b45b3a2beccfc957eb1fcc0269e2946d1dad9d2a51ab41fbc822695aa3b5c
|
data/lib/bookify/renderer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Bookify::Renderer
|
2
2
|
MARKDOWN_CONVERTER = Redcarpet::Markdown.new(Redcarpet::Render::HTML, tables: true)
|
3
3
|
|
4
|
-
attr_accessor :input_file, :output_file, :layout, :columns, :input_text
|
4
|
+
attr_accessor :input_file, :output_file, :layout, :columns, :input_text, :column_spacer, :margin
|
5
5
|
|
6
6
|
def self.from_args(args)
|
7
7
|
if ["-l", "--landscape"].include?(args[0])
|
@@ -19,16 +19,18 @@ class Bookify::Renderer
|
|
19
19
|
new(layout: layout, columns: columns, input_file: input_file, output_file: output_file)
|
20
20
|
end
|
21
21
|
|
22
|
-
def initialize(layout: :landscape, columns: 2, output_file:, input_file: nil, input_text: nil)
|
22
|
+
def initialize(layout: :landscape, columns: 2, output_file:, input_file: nil, input_text: nil, column_spacer: nil, margin: 50)
|
23
23
|
@layout = layout
|
24
24
|
@columns = columns
|
25
25
|
@output_file = output_file
|
26
26
|
@input_file = input_file
|
27
27
|
@input_text = input_text
|
28
|
+
@column_spacer = column_spacer
|
29
|
+
@margin = margin
|
28
30
|
end
|
29
31
|
|
30
32
|
def render
|
31
|
-
Prawn::Document.generate(output_file, margin:
|
33
|
+
Prawn::Document.generate(output_file, margin: margin, page_layout: layout) do |pdf|
|
32
34
|
font_path = "#{File.dirname(__FILE__)}/../../fonts"
|
33
35
|
|
34
36
|
pdf.font_families["Book Antiqua"] = {
|
@@ -43,7 +45,7 @@ class Bookify::Renderer
|
|
43
45
|
pdf.line_width(0.5)
|
44
46
|
pdf.default_leading 0.5
|
45
47
|
|
46
|
-
pdf.column_box [0, pdf.cursor], columns: columns, width: pdf.bounds.width do
|
48
|
+
pdf.column_box [0, pdf.cursor], columns: columns, width: pdf.bounds.width, spacer: (column_spacer || pdf.font_size) do
|
47
49
|
doc.children.each { |c| Bookify::Node.render(c, pdf) }
|
48
50
|
end
|
49
51
|
end
|