prawndown-ext 0.1.9 → 0.1.11
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 +8 -4
- data/lib/prawndown/version.rb +1 -1
- data/lib/prawndown-ext.rb +13 -4
- 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: cde2a748cc80534bf28bcb5540cd5788eb3d2690b64fec3c0357f72edfaa25bf
|
4
|
+
data.tar.gz: dfcc6a5c1d475d660e3c8502e5351c91907bb5872a637f0a229e9f828c530945
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 756968bf80dfc61824d0a6825aaf966132b0a25fc4c62879cc32dfdba3454ab2e0f900b55f8c7658e4588d8631f9bcfa13cf065f1d117157f5bb41c0d6ed25ae
|
7
|
+
data.tar.gz: 443c379f6e4d49bcbaea754a6775d5099a74c1d0ccdba2a5e762c7923252f7716e4a1bb722e4f688ee3a16b41fb22e402664cbfec1ed95fde5ebc8e9e5c1dd3f
|
data/lib/prawndown/parser.rb
CHANGED
@@ -37,6 +37,7 @@ module PrawndownExt
|
|
37
37
|
"header4_margin" => 4,
|
38
38
|
"header5_margin" => 4,
|
39
39
|
"header6_margin" => 4,
|
40
|
+
"img_dir" => "",
|
40
41
|
}
|
41
42
|
|
42
43
|
MATCHERS = {
|
@@ -69,6 +70,10 @@ module PrawndownExt
|
|
69
70
|
|
70
71
|
# Stuff to process last
|
71
72
|
/\[([^\[]+)\]\(([^\)]+)\)/ => '<link href="\2">\1</link>', # Link
|
73
|
+
|
74
|
+
# Special commands exclusive to prawndown-ext to control output
|
75
|
+
# Two breaks in a row signifies a new page
|
76
|
+
/<br><br>/ => '<command_break>{"command":"newpage"}<command_break>'
|
72
77
|
}
|
73
78
|
|
74
79
|
def escape_text text
|
@@ -93,7 +98,7 @@ module PrawndownExt
|
|
93
98
|
|
94
99
|
def replace_options text
|
95
100
|
# remove nil options if it doesnt exist
|
96
|
-
|
101
|
+
|
97
102
|
DELETE_NAMES.each do |option|
|
98
103
|
if @options.key?(option)
|
99
104
|
if @options[option].nil?
|
@@ -101,6 +106,7 @@ module PrawndownExt
|
|
101
106
|
@options.delete(option)
|
102
107
|
end
|
103
108
|
end
|
109
|
+
|
104
110
|
end
|
105
111
|
|
106
112
|
# remove quote spacing if it doesnt exist
|
@@ -110,9 +116,7 @@ module PrawndownExt
|
|
110
116
|
end
|
111
117
|
|
112
118
|
DEFAULT_OPTIONS.keys.each do |replacer|
|
113
|
-
|
114
|
-
text = text.gsub(replacer.upcase, @options[replacer].to_s)
|
115
|
-
end
|
119
|
+
text = text.gsub(replacer.upcase, @options[replacer].to_s)
|
116
120
|
end
|
117
121
|
|
118
122
|
text
|
data/lib/prawndown/version.rb
CHANGED
data/lib/prawndown-ext.rb
CHANGED
@@ -19,6 +19,7 @@ module PrawndownExt
|
|
19
19
|
"header4" => -> (args,pdf, options) { cl_text_box(args, pdf, options) },
|
20
20
|
"header5" => -> (args,pdf, options) { cl_text_box(args, pdf, options) },
|
21
21
|
"header6" => -> (args,pdf, options) { cl_text_box(args, pdf, options) },
|
22
|
+
"newpage" => -> (args,pdf, options) { cl_newline(args, pdf, options) }
|
22
23
|
}
|
23
24
|
|
24
25
|
def self.cl_text args, pdf, options
|
@@ -50,13 +51,17 @@ module PrawndownExt
|
|
50
51
|
return
|
51
52
|
end
|
52
53
|
end
|
53
|
-
|
54
|
-
|
54
|
+
|
55
|
+
if args["path"][0] == "/"
|
56
|
+
args["path"] = args["path"][1..-1]
|
57
|
+
end
|
58
|
+
|
59
|
+
file = options["image_dir"] + "/" + args["path"]
|
55
60
|
|
56
61
|
if !File.file?(file)
|
57
|
-
file = "." +
|
62
|
+
file = "." + options["image_dir"] + "/" + args["path"]
|
58
63
|
end
|
59
|
-
|
64
|
+
|
60
65
|
if File.extname(file) != ".gif"
|
61
66
|
pdf.image(file,
|
62
67
|
width: pdf.bounds.width,
|
@@ -64,6 +69,10 @@ module PrawndownExt
|
|
64
69
|
end
|
65
70
|
end
|
66
71
|
|
72
|
+
def self.cl_newline args, pdf, options
|
73
|
+
pdf.start_new_page()
|
74
|
+
end
|
75
|
+
|
67
76
|
|
68
77
|
def exec args, pdf, options
|
69
78
|
if args.key?("command")
|