asciidoctor-pdf 1.6.2 → 2.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/CHANGELOG.adoc +224 -30
  4. data/NOTICE.adoc +16 -4
  5. data/README.adoc +207 -67
  6. data/asciidoctor-pdf.gemspec +3 -7
  7. data/data/fonts/ABOUT-mplus1mn-subset +1 -1
  8. data/data/fonts/ABOUT-mplus1p-subset +2 -2
  9. data/data/fonts/ABOUT-notosans-subset +26 -0
  10. data/data/fonts/ABOUT-notoserif-subset +1 -1
  11. data/data/fonts/{LICENSE-notoserif → LICENSE-noto} +0 -0
  12. data/data/fonts/mplus1mn-bold-subset.ttf +0 -0
  13. data/data/fonts/mplus1mn-bold_italic-subset.ttf +0 -0
  14. data/data/fonts/mplus1mn-italic-subset.ttf +0 -0
  15. data/data/fonts/mplus1mn-regular-subset.ttf +0 -0
  16. data/data/fonts/mplus1p-regular-fallback.ttf +0 -0
  17. data/data/fonts/notoemoji-subset.ttf +0 -0
  18. data/data/fonts/notosans-bold-subset.ttf +0 -0
  19. data/data/fonts/notosans-bold_italic-subset.ttf +0 -0
  20. data/data/fonts/notosans-italic-subset.ttf +0 -0
  21. data/data/fonts/notosans-regular-subset.ttf +0 -0
  22. data/data/fonts/notoserif-bold-subset.ttf +0 -0
  23. data/data/fonts/notoserif-bold_italic-subset.ttf +0 -0
  24. data/data/fonts/notoserif-italic-subset.ttf +0 -0
  25. data/data/fonts/notoserif-regular-subset.ttf +0 -0
  26. data/data/themes/base-theme.yml +18 -22
  27. data/data/themes/default-for-print-theme.yml +24 -0
  28. data/data/themes/default-for-print-with-fallback-font-theme.yml +3 -0
  29. data/data/themes/default-theme.yml +49 -54
  30. data/data/themes/default-with-fallback-font-theme.yml +2 -2
  31. data/data/themes/sans-with-fallback-font-theme.yml +10 -0
  32. data/docs/theming-guide.adoc +967 -344
  33. data/lib/asciidoctor/pdf/converter.rb +1691 -1478
  34. data/lib/asciidoctor/pdf/ext/asciidoctor/document.rb +18 -1
  35. data/lib/asciidoctor/pdf/ext/asciidoctor/image.rb +9 -15
  36. data/lib/asciidoctor/pdf/ext/asciidoctor/list.rb +6 -13
  37. data/lib/asciidoctor/pdf/ext/asciidoctor/section.rb +3 -16
  38. data/lib/asciidoctor/pdf/ext/asciidoctor.rb +1 -5
  39. data/lib/asciidoctor/pdf/ext/core/file.rb +1 -1
  40. data/lib/asciidoctor/pdf/ext/core/quantifiable_stdout.rb +1 -4
  41. data/lib/asciidoctor/pdf/ext/core/string.rb +2 -2
  42. data/lib/asciidoctor/pdf/ext/core.rb +1 -4
  43. data/lib/asciidoctor/pdf/ext/pdf-core/page.rb +8 -33
  44. data/lib/asciidoctor/pdf/ext/pdf-core.rb +0 -18
  45. data/lib/asciidoctor/pdf/ext/prawn/coderay_encoder.rb +5 -7
  46. data/lib/asciidoctor/pdf/ext/prawn/extensions.rb +433 -329
  47. data/lib/asciidoctor/pdf/ext/prawn/font/afm.rb +0 -4
  48. data/lib/asciidoctor/pdf/ext/prawn/font_metric_cache.rb +1 -1
  49. data/lib/asciidoctor/pdf/ext/prawn/formatted_text/arranger.rb +33 -3
  50. data/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb +20 -14
  51. data/lib/asciidoctor/pdf/ext/prawn/formatted_text/fragment.rb +9 -3
  52. data/lib/asciidoctor/pdf/ext/prawn/images.rb +14 -16
  53. data/lib/asciidoctor/pdf/ext/prawn-svg/loaders/data.rb +6 -0
  54. data/lib/asciidoctor/pdf/ext/prawn-svg/loaders/web.rb +22 -0
  55. data/lib/asciidoctor/pdf/ext/prawn-svg/url_loader.rb +13 -0
  56. data/lib/asciidoctor/pdf/ext/prawn-svg.rb +5 -2
  57. data/lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb +76 -20
  58. data/lib/asciidoctor/pdf/ext/prawn-table/cell/text.rb +39 -1
  59. data/lib/asciidoctor/pdf/ext/prawn-table/cell.rb +21 -15
  60. data/lib/asciidoctor/pdf/ext/prawn-table.rb +1 -1
  61. data/lib/asciidoctor/pdf/ext/pygments.rb +2 -2
  62. data/lib/asciidoctor/pdf/ext/rouge/formatters/prawn.rb +17 -20
  63. data/lib/asciidoctor/pdf/ext/rouge/themes/asciidoctor_pdf_default.rb +1 -0
  64. data/lib/asciidoctor/pdf/ext/rouge.rb +0 -1
  65. data/lib/asciidoctor/pdf/formatted_text/formatter.rb +2 -2
  66. data/lib/asciidoctor/pdf/formatted_text/inline_destination_marker.rb +8 -10
  67. data/lib/asciidoctor/pdf/formatted_text/inline_image_arranger.rb +69 -78
  68. data/lib/asciidoctor/pdf/formatted_text/inline_image_renderer.rb +7 -10
  69. data/lib/asciidoctor/pdf/formatted_text/inline_text_aligner.rb +2 -4
  70. data/lib/asciidoctor/pdf/formatted_text/parser.rb +53 -47
  71. data/lib/asciidoctor/pdf/formatted_text/parser.treetop +5 -7
  72. data/lib/asciidoctor/pdf/formatted_text/source_wrap.rb +14 -14
  73. data/lib/asciidoctor/pdf/formatted_text/text_background_and_border_renderer.rb +4 -7
  74. data/lib/asciidoctor/pdf/formatted_text/transform.rb +116 -109
  75. data/lib/asciidoctor/pdf/formatted_text.rb +0 -1
  76. data/lib/asciidoctor/pdf/index_catalog.rb +7 -11
  77. data/lib/asciidoctor/pdf/optimizer.rb +3 -5
  78. data/lib/asciidoctor/pdf/pdfmark.rb +16 -8
  79. data/lib/asciidoctor/pdf/roman_numeral.rb +4 -22
  80. data/lib/asciidoctor/pdf/sanitizer.rb +18 -13
  81. data/lib/asciidoctor/pdf/section_info_by_page.rb +24 -0
  82. data/lib/asciidoctor/pdf/theme_loader.rb +89 -79
  83. data/lib/asciidoctor/pdf/version.rb +1 -2
  84. data/lib/asciidoctor/pdf.rb +5 -2
  85. metadata +34 -64
  86. data/data/fonts/mplus1mn-bold-ascii.ttf +0 -0
  87. data/data/fonts/mplus1mn-bold_italic-ascii.ttf +0 -0
  88. data/data/fonts/mplus1mn-italic-ascii.ttf +0 -0
  89. data/data/fonts/mplus1mn-regular-ascii-conums.ttf +0 -0
  90. data/lib/asciidoctor/pdf/ext/asciidoctor/abstract_block.rb +0 -7
  91. data/lib/asciidoctor/pdf/ext/asciidoctor/abstract_node.rb +0 -7
  92. data/lib/asciidoctor/pdf/ext/asciidoctor/list_item.rb +0 -18
  93. data/lib/asciidoctor/pdf/ext/asciidoctor/logging_shim.rb +0 -33
  94. data/lib/asciidoctor/pdf/ext/core/array.rb +0 -11
  95. data/lib/asciidoctor/pdf/ext/core/hash.rb +0 -7
  96. data/lib/asciidoctor/pdf/ext/core/regexp.rb +0 -5
  97. data/lib/asciidoctor/pdf/ext/pdf-core/pdf_object.rb +0 -8
  98. data/lib/asciidoctor-pdf/converter.rb +0 -3
  99. data/lib/asciidoctor-pdf/version.rb +0 -3
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Asciidoctor
4
+ module PDF
5
+ class SectionInfoByPage
6
+ def initialize title_method
7
+ @table = {}
8
+ @title_method = title_method
9
+ end
10
+
11
+ def []= pgnum, val
12
+ if ::Asciidoctor::Section === val
13
+ @table[pgnum] = { title: val.send(*@title_method), numeral: val.numeral }
14
+ else
15
+ @table[pgnum] = { title: val }
16
+ end
17
+ end
18
+
19
+ def [] pgnum
20
+ @table[pgnum]
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'safe_yaml/load'
4
3
  require 'ostruct'
5
4
  require_relative 'measurements'
6
5
 
@@ -14,21 +13,18 @@ module Asciidoctor
14
13
  ThemesDir = ::File.join DataDir, 'themes'
15
14
  FontsDir = ::File.join DataDir, 'fonts'
16
15
  BaseThemePath = ::File.join ThemesDir, 'base-theme.yml'
16
+ BundledThemeNames = (::Dir.children ThemesDir).map {|it| it.slice 0, it.length - 10 }
17
+ DeprecatedCategoryKeys = { 'blockquote' => 'quote', 'key' => 'kbd', 'literal' => 'codespan', 'outline_list' => 'list' }
17
18
 
18
19
  VariableRx = /\$([a-z0-9_-]+)/
19
20
  LoneVariableRx = /^\$([a-z0-9_-]+)$/
20
- HexColorEntryRx = /^(?<k> *\p{Graph}+): +(?!null$)(?<q>["']?)(?<h>#)?(?<v>[a-fA-F0-9]{3,6})\k<q> *(?:#.*)?$/
21
- MultiplyDivideOpRx = /(-?\d+(?:\.\d+)?) +([*\/]) +(-?\d+(?:\.\d+)?)/
21
+ HexColorEntryRx = /^(?<k> *\p{Graph}+): +(?!null$)(?<q>["']?)(?<h>#)?(?<v>\h\h\h\h{0,3})\k<q> *(?:#.*)?$/
22
+ MultiplyDivideOpRx = %r((-?\d+(?:\.\d+)?) +([*/^]) +(-?\d+(?:\.\d+)?))
22
23
  AddSubtractOpRx = /(-?\d+(?:\.\d+)?) +([+\-]) +(-?\d+(?:\.\d+)?)/
23
24
  PrecisionFuncRx = /^(round|floor|ceil)\(/
24
25
 
25
- # TODO: implement white? & black? methods
26
26
  module ColorValue; end
27
27
 
28
- class HexColorValue < String
29
- include ColorValue
30
- end
31
-
32
28
  # A marker module for a normalized CMYK array
33
29
  # Prevents normalizing CMYK value more than once
34
30
  module CMYKColorValue
@@ -38,9 +34,17 @@ module Asciidoctor
38
34
  end
39
35
  end
40
36
 
37
+ class HexColorValue < String
38
+ include ColorValue
39
+ end
40
+
41
+ class TransparentColorValue < String
42
+ include ColorValue
43
+ end
44
+
41
45
  def self.resolve_theme_file theme_name = nil, theme_dir = nil
42
- # NOTE if .yml extension is given, assume it's a path (don't append -theme.yml)
43
- if theme_name && (theme_name.end_with? '.yml')
46
+ # NOTE: if .yml extension is given, assume it's a path (don't append -theme.yml)
47
+ if theme_name&.end_with? '.yml'
44
48
  # FIXME: restrict to jail!
45
49
  if theme_dir
46
50
  theme_path = ::File.absolute_path theme_name, (theme_dir = ::File.expand_path theme_dir)
@@ -59,9 +63,11 @@ module Asciidoctor
59
63
  ::File.absolute_path asset_path, (theme_dir || ThemesDir)
60
64
  end
61
65
 
62
- # NOTE base theme is loaded "as is" (no post-processing)
66
+ # NOTE: base theme is loaded "as is" (no post-processing)
63
67
  def self.load_base_theme
64
- (::OpenStruct.new ::SafeYAML.load_file BaseThemePath).tap {|theme| theme.__dir__ = ThemesDir }
68
+ ::File.open BaseThemePath, mode: 'r:UTF-8' do |io|
69
+ (::OpenStruct.new ::YAML.safe_load io, aliases: true, filename: BaseThemePath).tap {|theme| theme.__dir__ = ThemesDir }
70
+ end
65
71
  end
66
72
 
67
73
  def self.load_theme theme_name = nil, theme_dir = nil
@@ -74,13 +80,14 @@ module Asciidoctor
74
80
  theme_data.base_align ||= 'left'
75
81
  theme_data.base_line_height ||= 1
76
82
  theme_data.base_font_color ||= '000000'
77
- theme_data.code_font_family ||= (theme_data.literal_font_family || 'Courier')
78
- theme_data.conum_font_family ||= (theme_data.literal_font_family || 'Courier')
83
+ theme_data.code_font_family ||= (theme_data.codespan_font_family || 'Courier')
84
+ theme_data.conum_font_family ||= (theme_data.codespan_font_family || 'Courier')
79
85
  if (heading_font_family = theme_data.heading_font_family)
80
86
  theme_data.abstract_title_font_family ||= heading_font_family
81
87
  theme_data.sidebar_title_font_family ||= heading_font_family
82
88
  end
83
89
  end
90
+ theme_data.delete_field :__loaded__
84
91
  theme_data.__dir__ = theme_dir
85
92
  theme_data
86
93
  end
@@ -88,28 +95,26 @@ module Asciidoctor
88
95
 
89
96
  def self.load_file filename, theme_data = nil, theme_dir = nil
90
97
  data = ::File.read filename, mode: 'r:UTF-8', newline: :universal
91
- data = data.each_line.map {|line|
98
+ data = data.each_line.map do |line|
92
99
  line.sub(HexColorEntryRx) { %(#{(m = $~)[:k]}: #{m[:h] || (m[:k].end_with? 'color') ? "'#{m[:v]}'" : m[:v]}) }
93
- }.join unless (::File.dirname filename) == ThemesDir
94
- yaml_data = ::SafeYAML.load data, filename
95
- if ::Hash === yaml_data && (yaml_data.key? 'extends')
96
- if (extends = yaml_data.delete 'extends')
97
- (Array extends).each do |extend_path|
98
- if extend_path == 'base'
99
- theme_data = theme_data ? (::OpenStruct.new theme_data.to_h.merge load_base_theme.to_h) : load_base_theme
100
- next
101
- elsif extend_path == 'default' || extend_path == 'default-with-fallback-font'
102
- extend_path, extend_theme_dir = resolve_theme_file extend_path, ThemesDir
103
- elsif extend_path.start_with? './'
104
- extend_path, extend_theme_dir = resolve_theme_file extend_path, (::File.dirname filename)
105
- else
106
- extend_path, extend_theme_dir = resolve_theme_file extend_path, theme_dir
107
- end
108
- theme_data = load_file extend_path, theme_data, extend_theme_dir
100
+ end.join unless (::File.dirname filename) == ThemesDir
101
+ yaml_data = ::YAML.safe_load data, aliases: true, filename: filename
102
+ (loaded = (theme_data ||= ::OpenStruct.new).__loaded__ ||= ::Set.new).add filename
103
+ if ::Hash === yaml_data && (extends = yaml_data.delete 'extends')
104
+ (Array extends).each do |extend_path|
105
+ extend_path = extend_path.slice 0, extend_path.length - 11 if (force = extend_path.end_with? ' !important')
106
+ if extend_path == 'base'
107
+ theme_data = ::OpenStruct.new theme_data.to_h.merge load_base_theme.to_h if (loaded.add? 'base') || force
108
+ next
109
+ elsif BundledThemeNames.include? extend_path
110
+ extend_path, extend_theme_dir = resolve_theme_file extend_path, ThemesDir
111
+ elsif extend_path.start_with? './'
112
+ extend_path, extend_theme_dir = resolve_theme_file extend_path, (::File.dirname filename)
113
+ else
114
+ extend_path, extend_theme_dir = resolve_theme_file extend_path, theme_dir
109
115
  end
116
+ theme_data = load_file extend_path, theme_data, extend_theme_dir if (loaded.add? extend_path) || force
110
117
  end
111
- else
112
- theme_data ||= ((::File.dirname filename) == ThemesDir ? nil : load_base_theme)
113
118
  end
114
119
  new.load yaml_data, theme_data
115
120
  end
@@ -128,30 +133,46 @@ module Asciidoctor
128
133
  end if ::Hash === val
129
134
  elsif key == 'font_catalog'
130
135
  data[key] = ::Hash === val ? (val.reduce (val.delete 'merge') ? data[key] || {} : {} do |accum, (name, styles)| # rubocop:disable Style/EachWithObject
131
- styles = %w(normal bold italic bold_italic).map {|style| [style, styles] }.to_h if ::String === styles
136
+ styles = { '*' => styles } if ::String === styles
132
137
  accum[name] = styles.reduce({}) do |subaccum, (style, path)| # rubocop:disable Style/EachWithObject
133
138
  if (path.start_with? 'GEM_FONTS_DIR') && (sep = path[13])
134
139
  path = %(#{FontsDir}#{sep}#{path.slice 14, path.length})
135
140
  end
136
- subaccum[style == 'regular' ? 'normal' : style] = expand_vars path, data
141
+ expanded_path = expand_vars path, data
142
+ case style
143
+ when '*'
144
+ %w(normal bold italic bold_italic).map {|it| subaccum[it] = expanded_path }
145
+ when 'regular'
146
+ subaccum['normal'] = expanded_path
147
+ else
148
+ subaccum[style] = expanded_path
149
+ end
137
150
  subaccum
138
151
  end if ::Hash === styles
139
152
  accum
140
- end) : {}
153
+ end) : nil
141
154
  elsif key == 'font_fallbacks'
142
155
  data[key] = ::Array === val ? val.map {|name| expand_vars name.to_s, data } : []
143
156
  elsif key.start_with? 'admonition_icon_'
144
- data[key] = val ? val.map {|(key2, val2)|
157
+ data[key] = val.map do |(key2, val2)|
145
158
  key2 = key2.tr '-', '_' if key2.include? '-'
146
159
  [key2.to_sym, (key2.end_with? '_color') ? (to_color evaluate val2, data) : (evaluate val2, data)]
147
- }.to_h : {}
160
+ end.to_h if val
148
161
  elsif ::Hash === val
162
+ if (rekey = DeprecatedCategoryKeys[key])
163
+ logger.warn %(the #{key.tr '_', '-'} theme category is deprecated; use the #{rekey.tr '_', '-'} category instead)
164
+ key = rekey
165
+ end
149
166
  val.each do |subkey, subval|
150
167
  process_entry %(#{key}_#{key == 'role' || !(subkey.include? '-') ? subkey : (subkey.tr '-', '_')}), subval, data
151
168
  end
169
+ # QUESTION: do we really need to evaluate_math in this case?
152
170
  elsif key.end_with? '_color'
153
- # QUESTION do we really need to evaluate_math in this case?
154
- data[key] = to_color evaluate val, data
171
+ if key == 'table_grid_color' && (Array val).size == 2
172
+ data[key] = val.map {|it| to_color evaluate it, data }
173
+ else
174
+ data[key] = to_color evaluate val, data
175
+ end
155
176
  elsif key.end_with? '_content'
156
177
  data[key] = (expand_vars val.to_s, data).to_s
157
178
  else
@@ -171,46 +192,37 @@ module Asciidoctor
171
192
  end
172
193
  end
173
194
 
174
- # NOTE we assume expr is a String
195
+ # NOTE: we assume expr is a String
175
196
  def expand_vars expr, vars
176
- if (idx = (expr.index '$'))
177
- if idx == 0 && expr =~ LoneVariableRx
178
- if (key = $1).include? '-'
179
- key = key.tr '-', '_'
180
- end
181
- if vars.respond_to? key
182
- vars[key]
183
- else
184
- logger.warn %(unknown variable reference in PDF theme: $#{$1})
185
- expr
186
- end
187
- else
188
- expr.gsub VariableRx do
189
- if (key = $1).include? '-'
190
- key = key.tr '-', '_'
191
- end
192
- if vars.respond_to? key
193
- vars[key]
194
- else
195
- logger.warn %(unknown variable reference in PDF theme: $#{$1})
196
- $&
197
- end
198
- end
199
- end
197
+ return expr unless (idx = expr.index '$')
198
+ if idx == 0
199
+ return resolve_var vars, expr, $1 if expr =~ LoneVariableRx
200
+ elsif idx == 1 && expr.chr == '-' && (negated_expr = expr.slice 1, expr.length) =~ LoneVariableRx
201
+ return Numeric === (val = resolve_var vars, negated_expr, $1) ? -val : '-' + val
202
+ end
203
+ expr.gsub(VariableRx) { resolve_var vars, $&, $1 }
204
+ end
205
+
206
+ def resolve_var vars, ref, var
207
+ var = var.tr '-', '_' if var.include? '-'
208
+ if (vars.respond_to? var) ||
209
+ DeprecatedCategoryKeys.any? {|old, new| (var.start_with? old + '_') && (vars.respond_to? (replace = new + (var.slice old.length, var.length))) && (var = replace) }
210
+ vars[var]
200
211
  else
201
- expr
212
+ logger.warn %(unknown variable reference in PDF theme: #{ref})
213
+ ref
202
214
  end
203
215
  end
204
216
 
205
217
  def evaluate_math expr
206
218
  return expr if !(::String === expr) || ColorValue === expr
207
219
  # resolve measurement values (e.g., 0.5in => 36)
208
- # QUESTION should we round the value? perhaps leave that to the precision functions
209
- # NOTE leave % as a string; handled by converter for now
220
+ # QUESTION: should we round the value? perhaps leave that to the precision functions
221
+ # NOTE: leave % as a string; handled by converter for now
210
222
  original, expr = expr, (resolve_measurement_values expr)
211
- loop do
212
- if (expr.count '*/') > 0
213
- result = expr.gsub(MultiplyDivideOpRx) { $1.to_f.send $2.to_sym, $3.to_f }
223
+ while true
224
+ if (expr.count '*/^') > 0
225
+ result = expr.gsub(MultiplyDivideOpRx) { $1.to_f.send ($2 == '^' ? '**' : $2).to_sym, $3.to_f }
214
226
  unchanged = (result == expr)
215
227
  expr = result
216
228
  break if unchanged
@@ -218,7 +230,7 @@ module Asciidoctor
218
230
  break
219
231
  end
220
232
  end
221
- loop do
233
+ while true
222
234
  if (expr.count '+-') > 0
223
235
  result = expr.gsub(AddSubtractOpRx) { $1.to_f.send $2.to_sym, $3.to_f }
224
236
  unchanged = (result == expr)
@@ -253,7 +265,7 @@ module Asciidoctor
253
265
  if ::Numeric === e
254
266
  e *= 100.0 unless e > 1
255
267
  else
256
- e = e.to_s.chomp('%').to_f
268
+ e = (e.to_s.chomp '%').to_f
257
269
  end
258
270
  e == (int_e = e.to_i) ? int_e : e
259
271
  end
@@ -263,25 +275,23 @@ module Asciidoctor
263
275
  when [100, 100, 100, 100]
264
276
  return HexColorValue.new '000000'
265
277
  else
266
- value.extend CMYKColorValue
267
- return value
278
+ return value.extend CMYKColorValue
268
279
  end
269
280
  # RGB value
270
281
  when 3
271
- return HexColorValue.new value.map {|e| '%02X' % e }.join
282
+ return HexColorValue.new value.map {|e| sprintf '%02X', e }.join
272
283
  # Nonsense array value; flatten to string
273
284
  else
274
285
  value = value.join
275
286
  end
276
287
  when ::String
277
288
  if value == 'transparent'
278
- # FIXME: should we have a TransparentColorValue class?
279
- return HexColorValue.new value
289
+ return TransparentColorValue.new value
280
290
  elsif value.length == 6
281
291
  return HexColorValue.new value.upcase
282
292
  end
283
293
  when ::NilClass
284
- return nil
294
+ return
285
295
  else
286
296
  # Unknown type (usually Integer); coerce to String
287
297
  if (value = value.to_s).length == 6
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module PDF
5
- VERSION = '1.6.2'
5
+ VERSION = '2.0.0.alpha.1'
6
6
  end
7
- Pdf = PDF unless const_defined? :Pdf, false
8
7
  end
@@ -1,15 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'pdf/version'
4
- require 'asciidoctor' unless defined? Asciidoctor.load
4
+ require 'asciidoctor'
5
5
  require 'prawn'
6
+ # NOTE: patch float precision constant so prawn-table does not fail to arrange cells that span columns (see #1835)
6
7
  Prawn.send :remove_const, :FLOAT_PRECISION
7
8
  Prawn::FLOAT_PRECISION = 1e-3
8
9
  require 'prawn/templates'
9
10
  begin
10
11
  require 'prawn/gmagick'
11
- rescue LoadError
12
+ rescue LoadError # rubocop:disable Lint/SuppressedException
12
13
  end unless defined? GMagick::Image
14
+ autoload :Set, 'set'
15
+ require 'time' unless defined? Time.parse
13
16
  require_relative 'pdf/measurements'
14
17
  require_relative 'pdf/sanitizer'
15
18
  require_relative 'pdf/text_transformer'
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.6.2
4
+ version: 2.0.0.alpha.1
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: 2021-12-31 00:00:00.000000000 Z
12
+ date: 2022-04-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asciidoctor
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: 2.4.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: matrix
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '0.4'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '0.4'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: prawn-table
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -95,20 +109,6 @@ dependencies:
95
109
  - - "~>"
96
110
  - !ruby/object:Gem::Version
97
111
  version: 3.0.0
98
- - !ruby/object:Gem::Dependency
99
- name: safe_yaml
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
103
- - !ruby/object:Gem::Version
104
- version: 1.0.0
105
- type: :runtime
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: 1.0.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: concurrent-ruby
114
114
  requirement: !ruby/object:Gem::Requirement
@@ -157,14 +157,14 @@ dependencies:
157
157
  requirements:
158
158
  - - "~>"
159
159
  - !ruby/object:Gem::Version
160
- version: 3.10.0
160
+ version: 3.11.0
161
161
  type: :development
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
165
  - - "~>"
166
166
  - !ruby/object:Gem::Version
167
- version: 3.10.0
167
+ version: 3.11.0
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: pdf-inspector
170
170
  requirement: !ruby/object:Gem::Requirement
@@ -179,34 +179,6 @@ dependencies:
179
179
  - - "~>"
180
180
  - !ruby/object:Gem::Version
181
181
  version: 1.3.0
182
- - !ruby/object:Gem::Dependency
183
- name: rouge
184
- requirement: !ruby/object:Gem::Requirement
185
- requirements:
186
- - - "~>"
187
- - !ruby/object:Gem::Version
188
- version: '3.0'
189
- type: :development
190
- prerelease: false
191
- version_requirements: !ruby/object:Gem::Requirement
192
- requirements:
193
- - - "~>"
194
- - !ruby/object:Gem::Version
195
- version: '3.0'
196
- - !ruby/object:Gem::Dependency
197
- name: coderay
198
- requirement: !ruby/object:Gem::Requirement
199
- requirements:
200
- - - "~>"
201
- - !ruby/object:Gem::Version
202
- version: 1.1.0
203
- type: :development
204
- prerelease: false
205
- version_requirements: !ruby/object:Gem::Requirement
206
- requirements:
207
- - - "~>"
208
- - !ruby/object:Gem::Version
209
- version: 1.1.0
210
182
  - !ruby/object:Gem::Dependency
211
183
  name: chunky_png
212
184
  requirement: !ruby/object:Gem::Requirement
@@ -241,54 +213,51 @@ files:
241
213
  - data/fonts/ABOUT-mplus1mn-subset
242
214
  - data/fonts/ABOUT-mplus1p-subset
243
215
  - data/fonts/ABOUT-notoemoji-subset
216
+ - data/fonts/ABOUT-notosans-subset
244
217
  - data/fonts/ABOUT-notoserif-subset
245
218
  - data/fonts/LICENSE-mplus
246
- - data/fonts/LICENSE-notoserif
247
- - data/fonts/mplus1mn-bold-ascii.ttf
219
+ - data/fonts/LICENSE-noto
248
220
  - data/fonts/mplus1mn-bold-subset.ttf
249
- - data/fonts/mplus1mn-bold_italic-ascii.ttf
250
221
  - data/fonts/mplus1mn-bold_italic-subset.ttf
251
- - data/fonts/mplus1mn-italic-ascii.ttf
252
222
  - data/fonts/mplus1mn-italic-subset.ttf
253
- - data/fonts/mplus1mn-regular-ascii-conums.ttf
254
223
  - data/fonts/mplus1mn-regular-subset.ttf
255
224
  - data/fonts/mplus1p-regular-fallback.ttf
256
225
  - data/fonts/notoemoji-subset.ttf
226
+ - data/fonts/notosans-bold-subset.ttf
227
+ - data/fonts/notosans-bold_italic-subset.ttf
228
+ - data/fonts/notosans-italic-subset.ttf
229
+ - data/fonts/notosans-regular-subset.ttf
257
230
  - data/fonts/notoserif-bold-subset.ttf
258
231
  - data/fonts/notoserif-bold_italic-subset.ttf
259
232
  - data/fonts/notoserif-italic-subset.ttf
260
233
  - data/fonts/notoserif-regular-subset.ttf
261
234
  - data/themes/base-theme.yml
235
+ - data/themes/default-for-print-theme.yml
236
+ - data/themes/default-for-print-with-fallback-font-theme.yml
262
237
  - data/themes/default-theme.yml
263
238
  - data/themes/default-with-fallback-font-theme.yml
239
+ - data/themes/sans-with-fallback-font-theme.yml
264
240
  - docs/theming-guide.adoc
265
241
  - lib/asciidoctor-pdf.rb
266
- - lib/asciidoctor-pdf/converter.rb
267
- - lib/asciidoctor-pdf/version.rb
268
242
  - lib/asciidoctor/pdf.rb
269
243
  - lib/asciidoctor/pdf/converter.rb
270
244
  - lib/asciidoctor/pdf/ext.rb
271
245
  - lib/asciidoctor/pdf/ext/asciidoctor.rb
272
- - lib/asciidoctor/pdf/ext/asciidoctor/abstract_block.rb
273
- - lib/asciidoctor/pdf/ext/asciidoctor/abstract_node.rb
274
246
  - lib/asciidoctor/pdf/ext/asciidoctor/document.rb
275
247
  - lib/asciidoctor/pdf/ext/asciidoctor/image.rb
276
248
  - lib/asciidoctor/pdf/ext/asciidoctor/list.rb
277
- - lib/asciidoctor/pdf/ext/asciidoctor/list_item.rb
278
- - lib/asciidoctor/pdf/ext/asciidoctor/logging_shim.rb
279
249
  - lib/asciidoctor/pdf/ext/asciidoctor/section.rb
280
250
  - lib/asciidoctor/pdf/ext/core.rb
281
- - lib/asciidoctor/pdf/ext/core/array.rb
282
251
  - lib/asciidoctor/pdf/ext/core/file.rb
283
- - lib/asciidoctor/pdf/ext/core/hash.rb
284
252
  - lib/asciidoctor/pdf/ext/core/object.rb
285
253
  - lib/asciidoctor/pdf/ext/core/quantifiable_stdout.rb
286
- - lib/asciidoctor/pdf/ext/core/regexp.rb
287
254
  - lib/asciidoctor/pdf/ext/core/string.rb
288
255
  - lib/asciidoctor/pdf/ext/pdf-core.rb
289
256
  - lib/asciidoctor/pdf/ext/pdf-core/page.rb
290
- - lib/asciidoctor/pdf/ext/pdf-core/pdf_object.rb
291
257
  - lib/asciidoctor/pdf/ext/prawn-svg.rb
258
+ - lib/asciidoctor/pdf/ext/prawn-svg/loaders/data.rb
259
+ - lib/asciidoctor/pdf/ext/prawn-svg/loaders/web.rb
260
+ - lib/asciidoctor/pdf/ext/prawn-svg/url_loader.rb
292
261
  - lib/asciidoctor/pdf/ext/prawn-table.rb
293
262
  - lib/asciidoctor/pdf/ext/prawn-table/cell.rb
294
263
  - lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb
@@ -324,6 +293,7 @@ files:
324
293
  - lib/asciidoctor/pdf/pdfmark.rb
325
294
  - lib/asciidoctor/pdf/roman_numeral.rb
326
295
  - lib/asciidoctor/pdf/sanitizer.rb
296
+ - lib/asciidoctor/pdf/section_info_by_page.rb
327
297
  - lib/asciidoctor/pdf/text_transformer.rb
328
298
  - lib/asciidoctor/pdf/theme_loader.rb
329
299
  - lib/asciidoctor/pdf/version.rb
@@ -346,11 +316,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
346
316
  version: '0'
347
317
  required_rubygems_version: !ruby/object:Gem::Requirement
348
318
  requirements:
349
- - - ">="
319
+ - - ">"
350
320
  - !ruby/object:Gem::Version
351
- version: '0'
321
+ version: 1.3.1
352
322
  requirements: []
353
- rubygems_version: 3.2.32
323
+ rubygems_version: 3.3.7
354
324
  signing_key:
355
325
  specification_version: 4
356
326
  summary: Converts AsciiDoc documents to PDF using Asciidoctor and Prawn
Binary file
Binary file
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Asciidoctor::AbstractBlock
4
- def sections?
5
- !sections.empty?
6
- end unless method_defined? :sections?
7
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Asciidoctor::AbstractNode
4
- def remove_attr name
5
- @attributes.delete name
6
- end unless method_defined? :remove_attr
7
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # TODO: add these methods to Asciidoctor core
4
- class Asciidoctor::ListItem
5
- # Check whether this list item has complex content (i.e., nested blocks other than an outline list).
6
- #
7
- # Return false if the list item contains no blocks or it contains a nested outline list. Otherwise, return true.
8
- def complex?
9
- !simple?
10
- end unless method_defined? :complex?
11
-
12
- # Check whether this list item has simple content (i.e., no nested blocks aside from an outline list).
13
- #
14
- # Return true if the list item contains no blocks or it contains a nested outline list. Otherwise, return false.
15
- def simple?
16
- @blocks.empty? || (@blocks.size == 1 && Asciidoctor::List === (blk = @blocks[0]) && blk.outline?)
17
- end unless method_defined? :simple?
18
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Asciidoctor
4
- class StubLogger
5
- class << self
6
- def info message = nil
7
- # ignore since this isn't a real logger
8
- end
9
-
10
- def info?
11
- false
12
- end
13
-
14
- def warn message = nil
15
- ::Kernel.warn %(asciidoctor: WARNING: #{message || (block_given? ? yield : '???')})
16
- end
17
-
18
- def error message = nil
19
- ::Kernel.warn %(asciidoctor: ERROR: #{message || (block_given? ? yield : '???')})
20
- end
21
- end
22
- end
23
-
24
- module Logging
25
- def logger
26
- StubLogger
27
- end
28
-
29
- def message_with_context text, _context = {}
30
- text
31
- end
32
- end
33
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Array
4
- def delete_all *entries
5
- entries.map {|entry| delete entry }.compact
6
- end unless method_defined? :delete_all
7
-
8
- def sum
9
- reduce(&:+)
10
- end unless method_defined? :sum
11
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Hash
4
- def compact
5
- select {|_, val| val }
6
- end unless method_defined? :compact
7
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Regexp
4
- alias match? === unless Regexp.method_defined? :match?
5
- end