prawndown-ext 0.1.11 → 0.1.13
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/prawndown/parser.rb +13 -7
- data/lib/prawndown/version.rb +1 -1
- data/lib/prawndown-ext.rb +58 -8
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b801f60832b999e3876e1acc12b7a2067c43a5f275c512aa03833fec873aa4e
|
|
4
|
+
data.tar.gz: 7d7fba659b4abe19cc9b379f2de8eb617d1318cd8905569fdffe3044e3a96d2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f093e4377fbd489000b88ebde6ccd95b5ebda6ce241b3687befc479ac6d84e51764640590ff81eaae91f6d565661988c3d8b32eeb30bd4fcac7aaa097cdd9c49
|
|
7
|
+
data.tar.gz: 1151c3d86e726b7095f8444152ea7b155f5c6421322d2a6bc1589ec04a54e8e2d0b116acdcbaebf17f9c58877aa04bce69d2cbfdbfd689810dfd0dbde9091d61
|
data/lib/prawndown/parser.rb
CHANGED
|
@@ -15,6 +15,12 @@ module PrawndownExt
|
|
|
15
15
|
]
|
|
16
16
|
|
|
17
17
|
DEFAULT_OPTIONS = {
|
|
18
|
+
"header1_line_space" => 5,
|
|
19
|
+
"header2_line_space" => 5,
|
|
20
|
+
"header3_line_space" => 5,
|
|
21
|
+
"header4_line_space" => 5,
|
|
22
|
+
"header5_line_space" => 5,
|
|
23
|
+
"header6_line_space" => 5,
|
|
18
24
|
"header1_size" => 28,
|
|
19
25
|
"header2_size" => 24,
|
|
20
26
|
"header3_size" => 20,
|
|
@@ -23,13 +29,13 @@ module PrawndownExt
|
|
|
23
29
|
"header6_size" => 14,
|
|
24
30
|
"quote_size" => 14,
|
|
25
31
|
"quote_font_spacing" => nil,
|
|
26
|
-
"quote_font" =>
|
|
27
|
-
"header1_font" =>
|
|
28
|
-
"header2_font" =>
|
|
29
|
-
"header3_font" =>
|
|
30
|
-
"header4_font" =>
|
|
31
|
-
"header5_font" =>
|
|
32
|
-
"header6_font" =>
|
|
32
|
+
"quote_font" => "quote",
|
|
33
|
+
"header1_font" => "header1",
|
|
34
|
+
"header2_font" => "header2",
|
|
35
|
+
"header3_font" => "header3",
|
|
36
|
+
"header4_font" => "header4",
|
|
37
|
+
"header5_font" => "header5",
|
|
38
|
+
"header6_font" => "header6",
|
|
33
39
|
"quote_margin" => 20,
|
|
34
40
|
"header1_margin" => 4,
|
|
35
41
|
"header2_margin" => 4,
|
data/lib/prawndown/version.rb
CHANGED
data/lib/prawndown-ext.rb
CHANGED
|
@@ -33,12 +33,19 @@ module PrawndownExt
|
|
|
33
33
|
options[args["command"] + "_line_spacing"] = 0
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
if !options.key?("
|
|
37
|
-
args["
|
|
36
|
+
if !options.key?(args["command"] + "_horizontal_margin")
|
|
37
|
+
options[args["command"] + "_horizontal_margin"] = 0
|
|
38
38
|
end
|
|
39
|
+
|
|
40
|
+
if !options.key?(args["command"] + "_vertical_margin")
|
|
41
|
+
options[args["command"] + "_vertical_margin"] = 0
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
margin = (options[args["command"] + "_horizontal_margin"] * 0.5).floor
|
|
45
|
+
half_margin = (options[args["command"] + "_vertical_margin"] * 0.5).floor
|
|
39
46
|
|
|
40
|
-
pdf.pad
|
|
41
|
-
pdf.indent
|
|
47
|
+
pdf.pad half_margin do
|
|
48
|
+
pdf.indent margin, margin do
|
|
42
49
|
pdf.text args["text"], inline_format: true, leading: options[args["command"] + "_line_spacing"].to_f
|
|
43
50
|
end
|
|
44
51
|
end
|
|
@@ -52,6 +59,25 @@ module PrawndownExt
|
|
|
52
59
|
end
|
|
53
60
|
end
|
|
54
61
|
|
|
62
|
+
width = nil
|
|
63
|
+
height = nil
|
|
64
|
+
|
|
65
|
+
if options.key?("image_width")
|
|
66
|
+
width = options["image_width"].to_i
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
if options.key?("image_height")
|
|
70
|
+
height = options["image_height"].to_i
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
if width.nil? && height.nil?
|
|
74
|
+
width = pdf.bounds.width
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
if !width.nil?
|
|
78
|
+
width = [pdf.bounds.width, width].min
|
|
79
|
+
end
|
|
80
|
+
|
|
55
81
|
if args["path"][0] == "/"
|
|
56
82
|
args["path"] = args["path"][1..-1]
|
|
57
83
|
end
|
|
@@ -63,14 +89,38 @@ module PrawndownExt
|
|
|
63
89
|
end
|
|
64
90
|
|
|
65
91
|
if File.extname(file) != ".gif"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
92
|
+
if !(height.nil? && width.nil?)
|
|
93
|
+
|
|
94
|
+
if !options.key?("image_pad")
|
|
95
|
+
options["image_pad"] = 0
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
pdf.pad options["image_pad"] do
|
|
99
|
+
if height.nil? && !width.nil?
|
|
100
|
+
pdf.image(file,
|
|
101
|
+
width: [pdf.bounds.width, width].min,
|
|
102
|
+
position: :center)
|
|
103
|
+
elsif !height.nil? && width.nil?
|
|
104
|
+
pdf.image(file,
|
|
105
|
+
height: height,
|
|
106
|
+
position: :center)
|
|
107
|
+
else
|
|
108
|
+
pdf.image(file,
|
|
109
|
+
width: [pdf.bounds.width, width].min,
|
|
110
|
+
height: height,
|
|
111
|
+
position: :center)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
69
115
|
end
|
|
70
116
|
end
|
|
71
117
|
|
|
72
118
|
def self.cl_newline args, pdf, options
|
|
73
|
-
pdf.
|
|
119
|
+
if pdf.bounds.instance_of? Prawn::Document::ColumnBox
|
|
120
|
+
pdf.bounds.move_past_bottom
|
|
121
|
+
else
|
|
122
|
+
pdf.start_new_page
|
|
123
|
+
end
|
|
74
124
|
end
|
|
75
125
|
|
|
76
126
|
|