asciidoctor-pdf 1.5.0.alpha.14 → 1.5.0.alpha.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  class Object
2
2
  # Convert the object to a serialized PDF object.
3
3
  def to_pdf
4
- ::PDF::Core::PdfObject self
4
+ ::PDF::Core.pdf_object self
5
5
  end
6
6
  end
@@ -21,6 +21,6 @@ class String
21
21
  # Convert the string to a serialized PDF object. If the string can be encoded as ASCII-8BIT, first convert it to a PDF
22
22
  # LiteralString object.
23
23
  def to_pdf
24
- ::PDF::Core::PdfObject as_pdf
24
+ ::PDF::Core.pdf_object as_pdf
25
25
  end
26
26
  end
@@ -11,7 +11,7 @@ module InlineDestinationMarker
11
11
  end
12
12
  # get precise position of the reference (x, y)
13
13
  dest_rect = fragment.absolute_bounding_box
14
- pdf.add_dest name, (pdf.dest_xyz dest_rect.first, dest_rect.last)
14
+ pdf.add_dest name, (pdf.dest_xyz dest_rect[0], dest_rect[-1])
15
15
  # prevent any text from being written
16
16
  fragment.conceal
17
17
  end
@@ -199,10 +199,19 @@ class Transform
199
199
  pname, pvalue = style.split(':', 2)
200
200
  case pname
201
201
  when 'color'
202
+ # QUESTION should we check whether the value is a valid hex color?
202
203
  unless fragment[:color]
203
- pvalue = pvalue[1..-1] if pvalue.start_with?('#')
204
- #pvalue = pvalue.each_char.map {|c| c * 2 }.join if pvalue.size == 3
205
- fragment[:color] = pvalue
204
+ case pvalue.length
205
+ when 6
206
+ fragment[:color] = pvalue
207
+ when 7
208
+ fragment[:color] = pvalue.slice(1, 6) if pvalue.start_with?('#')
209
+ # QUESTION should we support the 3 character form?
210
+ #when 3
211
+ # fragment[:color] = pvalue.each_char.map {|c| c * 2 }.join
212
+ #when 4
213
+ # fragment[:color] = pvalue.slice(1, 3).each_char.map {|c| c * 2 }.join if pvalue.start_with?('#')
214
+ end
206
215
  end
207
216
  when 'font-weight'
208
217
  if pvalue == 'bold'
@@ -1 +1,2 @@
1
+ require_relative 'pdf-core_ext/pdf_object'
1
2
  require_relative 'pdf-core_ext/page'
@@ -13,6 +13,13 @@ class PDF::Core::Page
13
13
  end
14
14
  @content = document.ref Hash.new
15
15
  dictionary.data[:Contents] << document.state.store[@content]
16
- document.renderer.open_graphics_state
16
+ document.open_graphics_state
17
17
  end unless method_defined? :new_content_stream
18
+
19
+ # Restore the imported_page? method from PDF::Core::Page
20
+ #
21
+ # see https://github.com/prawnpdf/pdf-core/commit/0e326a838e142061be8e062168190fae6b3b1dcf
22
+ def imported_page?
23
+ @imported_page
24
+ end unless method_defined? :imported_page?
18
25
  end
@@ -0,0 +1,6 @@
1
+ unless (defined? PDF::Core.pdf_object) == 'method'
2
+ module PDF::Core
3
+ alias :pdf_object :PdfObject
4
+ module_function :pdf_object
5
+ end
6
+ end
@@ -1,5 +1,6 @@
1
1
  class Prawn::Table::Cell::Text
2
2
  # Override draw_content method to drop cursor advancement
3
+ remove_method :draw_content
3
4
  def draw_content
4
5
  with_font do
5
6
  with_text_color do
@@ -0,0 +1,5 @@
1
+ class Prawn::Document
2
+ # NOTE allows prawn-templates 0.0.4 to be used with prawn >= 2.2.0
3
+ const_set :VALID_OPTIONS, (send :remove_const, :VALID_OPTIONS).dup if VALID_OPTIONS.frozen?
4
+ end
5
+ require 'prawn/templates'
@@ -97,7 +97,7 @@ class CodeRayEncoder < ::CodeRay::Encoders::Encoder
97
97
  @out << { text: text }
98
98
  else
99
99
  # QUESTION should we default to no color?
100
- @out << { text: text, color: (COLORS[kind] || COLORS[@open.last] || COLORS[:default]) }
100
+ @out << { text: text, color: (COLORS[kind] || COLORS[@open[-1]] || COLORS[:default]) }
101
101
  end
102
102
  @start_of_line = text.end_with? LF
103
103
  end
@@ -736,13 +736,12 @@ module Extensions
736
736
  end
737
737
  end
738
738
 
739
- #def advance_or_start_new_page options = {}
740
- # if last_page?
741
- # start_new_page options
742
- # else
743
- # go_to_page page_number + 1
744
- # end
745
- #end
739
+ # This method is a smarter version of start_new_page. It calls start_new_page
740
+ # if the current page is the last page of the document. Otherwise, it simply
741
+ # advances to the next existing page.
742
+ def advance_page
743
+ last_page? ? start_new_page : (go_to_page page_number + 1)
744
+ end
746
745
 
747
746
  # Start a new page without triggering the on_page_create callback
748
747
  #
@@ -42,8 +42,11 @@ class Prawn < Formatter
42
42
 
43
43
  def stream tokens, opts = {}
44
44
  if opts[:line_numbers]
45
- # TODO implement line number start (offset)
46
- linenum = 0
45
+ if (linenum = opts[:start_line]) > 0
46
+ linenum -= 1
47
+ else
48
+ linenum = 0
49
+ end
47
50
  fragments = []
48
51
  fragments << (create_linenum_fragment linenum += 1)
49
52
  tokens.each do |tok, val|
@@ -66,7 +69,7 @@ class Prawn < Formatter
66
69
  # NOTE drop orphaned linenum fragment (due to trailing endline in source)
67
70
  fragments.pop if (last_fragment = fragments[-1]) && last_fragment[:linenum]
68
71
  # NOTE pad numbers that have less digits than the largest line number
69
- if (linenum_w = linenum.to_s.size) > 1
72
+ if (linenum_w = linenum.to_s.length) > 1
70
73
  # NOTE extra column is the trailing space after the line number
71
74
  linenum_w += 1
72
75
  fragments.each do |fragment|
@@ -116,7 +119,7 @@ class Prawn < Formatter
116
119
  end
117
120
  if style_rules[:underline]
118
121
  if fragment.key? :styles
119
- fragment[:styles] << UnderlineStyle.first
122
+ fragment[:styles] << UnderlineStyle[0]
120
123
  else
121
124
  fragment[:styles] = UnderlineStyle.dup
122
125
  end
@@ -135,7 +138,7 @@ class Prawn < Formatter
135
138
  normalized
136
139
  else
137
140
  normalized = (raw.start_with? '#') ? raw[1..-1] : raw
138
- normalized = normalized.each_char.map {|c| c * 2 }.join if normalized.size == 3
141
+ normalized = normalized.each_char.map {|c| c * 2 }.join if normalized.length == 3
139
142
  @normalized_colors[raw] = normalized
140
143
  end
141
144
  end
@@ -17,7 +17,6 @@ class ThemeLoader
17
17
  VariableRx = /\$([a-z0-9_]+)/
18
18
  LoneVariableRx = /^\$([a-z0-9_]+)$/
19
19
  HexColorEntryRx = /^(?<k>[[:blank:]]*[[:graph:]]+): +(?!null$)(?<q>["']?)#?(?<v>\w{3,6})\k<q> *(?:#.*)?$/
20
- MeasurementValueRx = /(?<=^| |\()(-?\d+(?:\.\d+)?)(in|mm|cm|p[txc])(?=$| |\))/
21
20
  MultiplyDivideOpRx = /(-?\d+(?:\.\d+)?) +([*\/]) +(-?\d+(?:\.\d+)?)/
22
21
  AddSubtractOpRx = /(-?\d+(?:\.\d+)?) +([+\-]) +(-?\d+(?:\.\d+)?)/
23
22
  PrecisionFuncRx = /^(round|floor|ceil)\(/
@@ -184,11 +183,11 @@ class ThemeLoader
184
183
  if value == 'transparent'
185
184
  # FIXME should we have a TransparentColorValue class?
186
185
  return HexColorValue.new value
187
- elsif value.size == 6
186
+ elsif value.length == 6
188
187
  return HexColorValue.new value.upcase
189
188
  end
190
189
  when ::Array
191
- case value.size
190
+ case value.length
192
191
  # CMYK value
193
192
  when 4
194
193
  value = value.map do |e|
@@ -219,7 +218,7 @@ class ThemeLoader
219
218
  # Unknown type; coerce to a string
220
219
  value = value.to_s
221
220
  end
222
- value = case value.size
221
+ value = case value.length
223
222
  when 6
224
223
  value
225
224
  when 3
@@ -0,0 +1,8 @@
1
+ # patch ttfunk 1.5.0; see https://github.com/prawnpdf/ttfunk/issues/39
2
+ class TTFunk::Subset::Base
3
+ alias __checksum checksum
4
+ def checksum data
5
+ return 0 if data.length == 0
6
+ __checksum data
7
+ end
8
+ end
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Pdf
3
- VERSION = '1.5.0.alpha.14'
3
+ VERSION = '1.5.0.alpha.15'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.alpha.14
4
+ version: 1.5.0.alpha.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Allen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-06 00:00:00.000000000 Z
12
+ date: 2017-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -48,7 +48,7 @@ dependencies:
48
48
  version: 1.3.0
49
49
  - - "<"
50
50
  - !ruby/object:Gem::Version
51
- version: 3.0.0
51
+ version: 2.3.0
52
52
  type: :runtime
53
53
  prerelease: false
54
54
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  version: 1.3.0
59
59
  - - "<"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.0.0
61
+ version: 2.3.0
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: prawn-table
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -77,16 +77,22 @@ dependencies:
77
77
  name: prawn-templates
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.0.3
83
+ - - "<="
84
+ - !ruby/object:Gem::Version
85
+ version: 0.0.5
83
86
  type: :runtime
84
87
  prerelease: false
85
88
  version_requirements: !ruby/object:Gem::Requirement
86
89
  requirements:
87
- - - '='
90
+ - - ">="
88
91
  - !ruby/object:Gem::Version
89
92
  version: 0.0.3
93
+ - - "<="
94
+ - !ruby/object:Gem::Version
95
+ version: 0.0.5
90
96
  - !ruby/object:Gem::Dependency
91
97
  name: prawn-svg
92
98
  requirement: !ruby/object:Gem::Requirement
@@ -141,14 +147,14 @@ dependencies:
141
147
  requirements:
142
148
  - - "~>"
143
149
  - !ruby/object:Gem::Version
144
- version: 0.3.5
150
+ version: 0.3.6
145
151
  type: :runtime
146
152
  prerelease: false
147
153
  version_requirements: !ruby/object:Gem::Requirement
148
154
  requirements:
149
155
  - - "~>"
150
156
  - !ruby/object:Gem::Version
151
- version: 0.3.5
157
+ version: 0.3.6
152
158
  - !ruby/object:Gem::Dependency
153
159
  name: treetop
154
160
  requirement: !ruby/object:Gem::Requirement
@@ -226,12 +232,14 @@ files:
226
232
  - lib/asciidoctor-pdf/measurements.rb
227
233
  - lib/asciidoctor-pdf/pdf-core_ext.rb
228
234
  - lib/asciidoctor-pdf/pdf-core_ext/page.rb
235
+ - lib/asciidoctor-pdf/pdf-core_ext/pdf_object.rb
229
236
  - lib/asciidoctor-pdf/pdfmark.rb
230
237
  - lib/asciidoctor-pdf/prawn-svg_ext.rb
231
238
  - lib/asciidoctor-pdf/prawn-svg_ext/interface.rb
232
239
  - lib/asciidoctor-pdf/prawn-table_ext.rb
233
240
  - lib/asciidoctor-pdf/prawn-table_ext/cell/asciidoc.rb
234
241
  - lib/asciidoctor-pdf/prawn-table_ext/cell/text.rb
242
+ - lib/asciidoctor-pdf/prawn-templates_ext.rb
235
243
  - lib/asciidoctor-pdf/prawn_ext.rb
236
244
  - lib/asciidoctor-pdf/prawn_ext/coderay_encoder.rb
237
245
  - lib/asciidoctor-pdf/prawn_ext/extensions.rb
@@ -246,6 +254,7 @@ files:
246
254
  - lib/asciidoctor-pdf/sanitizer.rb
247
255
  - lib/asciidoctor-pdf/temporary_path.rb
248
256
  - lib/asciidoctor-pdf/theme_loader.rb
257
+ - lib/asciidoctor-pdf/ttfunk_ext.rb
249
258
  - lib/asciidoctor-pdf/version.rb
250
259
  homepage: https://github.com/asciidoctor/asciidoctor-pdf
251
260
  licenses: