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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cde96e249677d9a8796584e537c0466f30cf98764c16eafe3fd08b82fcecebee
4
- data.tar.gz: 664c9251c77bfe9a783d2ac26ecaf4a506c0f87e604a097ba49c6ae4c613015a
3
+ metadata.gz: cde2a748cc80534bf28bcb5540cd5788eb3d2690b64fec3c0357f72edfaa25bf
4
+ data.tar.gz: dfcc6a5c1d475d660e3c8502e5351c91907bb5872a637f0a229e9f828c530945
5
5
  SHA512:
6
- metadata.gz: a2a036fb2d2a05537dd8d780b675b9574751afab2f9449630de714586a39c2451d0ed22149299b9cb86e15e362f05839ba2736bff650e770db1e4fb4d7d3c702
7
- data.tar.gz: 95ba8579b3addb4a791a8e6d00eb91a0d98d2f36cf5f133a2349a7b4b2579c391dfe024b7f279f138ddcc68cefa21c5ade556c81e85a85035f362014a7a5630d
6
+ metadata.gz: 756968bf80dfc61824d0a6825aaf966132b0a25fc4c62879cc32dfdba3454ab2e0f900b55f8c7658e4588d8631f9bcfa13cf065f1d117157f5bb41c0d6ed25ae
7
+ data.tar.gz: 443c379f6e4d49bcbaea754a6775d5099a74c1d0ccdba2a5e762c7923252f7716e4a1bb722e4f688ee3a16b41fb22e402664cbfec1ed95fde5ebc8e9e5c1dd3f
@@ -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
- if @options.key?(replacer)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PrawndownExt
4
4
  module Ext
5
- VERSION = "0.1.9"
5
+ VERSION = "0.1.11"
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.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - PunishedFelix