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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cde96e249677d9a8796584e537c0466f30cf98764c16eafe3fd08b82fcecebee
4
- data.tar.gz: 664c9251c77bfe9a783d2ac26ecaf4a506c0f87e604a097ba49c6ae4c613015a
3
+ metadata.gz: 01be81f1ee2b7abfc146e5965bd1c70cf70c4194070ca69c6be11c51bb492a84
4
+ data.tar.gz: 63a75b0bdffb9d985b45895201e6b4edd9e3f76d2da934be413153331409858d
5
5
  SHA512:
6
- metadata.gz: a2a036fb2d2a05537dd8d780b675b9574751afab2f9449630de714586a39c2451d0ed22149299b9cb86e15e362f05839ba2736bff650e770db1e4fb4d7d3c702
7
- data.tar.gz: 95ba8579b3addb4a791a8e6d00eb91a0d98d2f36cf5f133a2349a7b4b2579c391dfe024b7f279f138ddcc68cefa21c5ade556c81e85a85035f362014a7a5630d
6
+ metadata.gz: 356e6b501c171868581103a98614f4ac5ffc1975712833d06ad818c67155e093b9468bc1c8f8810d261b70a3c1dc2191a0d65554c15887cef99f08bd2a25e206
7
+ data.tar.gz: 9bc56bc6ce9444aa13e63b0c4d4471d2f66ffbbc22a1d82c3d475c7c3d6dc38fd02df746ac3d789d64e72b3450ee01769f9c9c8f13f6528ba300c312212890a8
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PrawndownExt
4
4
  module Ext
5
- VERSION = "0.1.9"
5
+ VERSION = "0.1.10"
6
6
  end
7
7
  end
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
- file = args["path"]
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 = "." + 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")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawndown-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - PunishedFelix