prawndown-ext 0.1.9 → 0.1.10
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 +5 -0
- 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: 01be81f1ee2b7abfc146e5965bd1c70cf70c4194070ca69c6be11c51bb492a84
|
4
|
+
data.tar.gz: 63a75b0bdffb9d985b45895201e6b4edd9e3f76d2da934be413153331409858d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 356e6b501c171868581103a98614f4ac5ffc1975712833d06ad818c67155e093b9468bc1c8f8810d261b70a3c1dc2191a0d65554c15887cef99f08bd2a25e206
|
7
|
+
data.tar.gz: 9bc56bc6ce9444aa13e63b0c4d4471d2f66ffbbc22a1d82c3d475c7c3d6dc38fd02df746ac3d789d64e72b3450ee01769f9c9c8f13f6528ba300c312212890a8
|
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
|
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")
|