asciidoctor-pdf 1.5.0.beta.1 → 1.5.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +26 -0
  3. data/README.adoc +2 -2
  4. data/asciidoctor-pdf.gemspec +3 -3
  5. data/bin/asciidoctor-pdf +1 -0
  6. data/data/fonts/ABOUT-mplus1mn-subset +24 -0
  7. data/data/fonts/ABOUT-mplus1p-subset +25 -0
  8. data/data/fonts/ABOUT-notoserif-subset +25 -0
  9. data/data/fonts/{LICENSE-mplus-testflight-58 → LICENSE-mplus} +2 -2
  10. data/data/fonts/{LICENSE-noto-2015-06-05 → LICENSE-notoserif} +0 -0
  11. data/data/fonts/mplus1mn-bold-ascii.ttf +0 -0
  12. data/data/fonts/mplus1mn-bold-subset.ttf +0 -0
  13. data/data/fonts/mplus1mn-bold_italic-ascii.ttf +0 -0
  14. data/data/fonts/mplus1mn-bold_italic-subset.ttf +0 -0
  15. data/data/fonts/mplus1mn-italic-ascii.ttf +0 -0
  16. data/data/fonts/mplus1mn-italic-subset.ttf +0 -0
  17. data/data/fonts/mplus1mn-regular-ascii-conums.ttf +0 -0
  18. data/data/fonts/mplus1mn-regular-subset.ttf +0 -0
  19. data/data/fonts/mplus1p-regular-fallback.ttf +0 -0
  20. data/data/fonts/notoserif-bold-subset.ttf +0 -0
  21. data/data/fonts/notoserif-bold_italic-subset.ttf +0 -0
  22. data/data/fonts/notoserif-italic-subset.ttf +0 -0
  23. data/data/fonts/notoserif-regular-subset.ttf +0 -0
  24. data/data/themes/base-theme.yml +8 -1
  25. data/data/themes/default-theme.yml +22 -7
  26. data/data/themes/default-with-fallback-font-theme.yml +4 -4
  27. data/docs/theming-guide.adoc +459 -44
  28. data/lib/asciidoctor-pdf.rb +1 -0
  29. data/lib/asciidoctor-pdf/asciidoctor_ext.rb +1 -0
  30. data/lib/asciidoctor-pdf/asciidoctor_ext/abstract_block.rb +1 -0
  31. data/lib/asciidoctor-pdf/asciidoctor_ext/document.rb +1 -0
  32. data/lib/asciidoctor-pdf/asciidoctor_ext/image.rb +1 -0
  33. data/lib/asciidoctor-pdf/asciidoctor_ext/list.rb +1 -0
  34. data/lib/asciidoctor-pdf/asciidoctor_ext/list_item.rb +1 -0
  35. data/lib/asciidoctor-pdf/asciidoctor_ext/logging_shim.rb +1 -0
  36. data/lib/asciidoctor-pdf/asciidoctor_ext/section.rb +1 -0
  37. data/lib/asciidoctor-pdf/converter.rb +227 -137
  38. data/lib/asciidoctor-pdf/core_ext.rb +1 -0
  39. data/lib/asciidoctor-pdf/core_ext/array.rb +1 -0
  40. data/lib/asciidoctor-pdf/core_ext/hash.rb +1 -0
  41. data/lib/asciidoctor-pdf/core_ext/numeric.rb +1 -0
  42. data/lib/asciidoctor-pdf/core_ext/object.rb +1 -0
  43. data/lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb +1 -0
  44. data/lib/asciidoctor-pdf/core_ext/regexp.rb +1 -0
  45. data/lib/asciidoctor-pdf/core_ext/string.rb +1 -0
  46. data/lib/asciidoctor-pdf/formatted_text.rb +1 -0
  47. data/lib/asciidoctor-pdf/formatted_text/formatter.rb +1 -0
  48. data/lib/asciidoctor-pdf/formatted_text/inline_destination_marker.rb +1 -0
  49. data/lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb +2 -1
  50. data/lib/asciidoctor-pdf/formatted_text/inline_image_renderer.rb +1 -0
  51. data/lib/asciidoctor-pdf/formatted_text/inline_text_aligner.rb +1 -0
  52. data/lib/asciidoctor-pdf/formatted_text/parser.rb +19 -6
  53. data/lib/asciidoctor-pdf/formatted_text/parser.treetop +2 -3
  54. data/lib/asciidoctor-pdf/formatted_text/text_background_and_border_renderer.rb +1 -0
  55. data/lib/asciidoctor-pdf/formatted_text/transform.rb +51 -3
  56. data/lib/asciidoctor-pdf/implicit_header_processor.rb +1 -0
  57. data/lib/asciidoctor-pdf/index_catalog.rb +1 -0
  58. data/lib/asciidoctor-pdf/measurements.rb +1 -0
  59. data/lib/asciidoctor-pdf/pdf-core_ext.rb +1 -0
  60. data/lib/asciidoctor-pdf/pdf-core_ext/page.rb +26 -0
  61. data/lib/asciidoctor-pdf/pdf-core_ext/pdf_object.rb +1 -0
  62. data/lib/asciidoctor-pdf/pdfmark.rb +1 -0
  63. data/lib/asciidoctor-pdf/prawn-svg_ext.rb +1 -0
  64. data/lib/asciidoctor-pdf/prawn-svg_ext/interface.rb +1 -0
  65. data/lib/asciidoctor-pdf/prawn-table_ext.rb +1 -0
  66. data/lib/asciidoctor-pdf/prawn-table_ext/cell.rb +1 -0
  67. data/lib/asciidoctor-pdf/prawn-table_ext/cell/asciidoc.rb +1 -0
  68. data/lib/asciidoctor-pdf/prawn-table_ext/cell/text.rb +1 -0
  69. data/lib/asciidoctor-pdf/prawn-templates_ext.rb +1 -0
  70. data/lib/asciidoctor-pdf/prawn_ext.rb +1 -0
  71. data/lib/asciidoctor-pdf/prawn_ext/coderay_encoder.rb +6 -5
  72. data/lib/asciidoctor-pdf/prawn_ext/extensions.rb +11 -17
  73. data/lib/asciidoctor-pdf/prawn_ext/font/afm.rb +15 -8
  74. data/lib/asciidoctor-pdf/prawn_ext/formatted_text/fragment.rb +1 -0
  75. data/lib/asciidoctor-pdf/prawn_ext/images.rb +2 -1
  76. data/lib/asciidoctor-pdf/roman_numeral.rb +1 -0
  77. data/lib/asciidoctor-pdf/rouge_ext.rb +1 -0
  78. data/lib/asciidoctor-pdf/rouge_ext/formatters/prawn.rb +1 -0
  79. data/lib/asciidoctor-pdf/rouge_ext/themes/asciidoctor_pdf_default.rb +1 -0
  80. data/lib/asciidoctor-pdf/rouge_ext/themes/bw.rb +1 -0
  81. data/lib/asciidoctor-pdf/sanitizer.rb +1 -0
  82. data/lib/asciidoctor-pdf/temporary_path.rb +1 -0
  83. data/lib/asciidoctor-pdf/theme_loader.rb +13 -13
  84. data/lib/asciidoctor-pdf/ttfunk_ext.rb +1 -0
  85. data/lib/asciidoctor-pdf/version.rb +2 -1
  86. data/lib/asciidoctor/pdf.rb +1 -0
  87. data/lib/asciidoctor/pdf/version.rb +1 -0
  88. metadata +15 -15
  89. data/lib/asciidoctor-pdf/core_ext/ostruct.rb +0 -8
@@ -1,10 +1,17 @@
1
+ # frozen_string_literal: true
1
2
  class Prawn::Font::AFM
3
+ if defined? ::Asciidoctor::Logging
4
+ include ::Asciidoctor::Logging
5
+ else
6
+ include ::Asciidoctor::LoggingShim
7
+ end
8
+
2
9
  FALLBACK_CHARS = {
3
- %(\u200b) => '',
4
- %(\u202f) => %(\u00a0),
5
- %(\u2009) => ' ',
6
- %(\u25e6) => '-',
7
- %(\u25aa) => %(\u00b7)
10
+ ?\u200b => '',
11
+ ?\u202f => ?\u00a0,
12
+ ?\u2009 => ' ',
13
+ ?\u25e6 => '-',
14
+ ?\u25aa => ?\u00b7
8
15
  }
9
16
 
10
17
  remove_method :normalize_encoding
@@ -17,9 +24,9 @@ class Prawn::Font::AFM
17
24
  def normalize_encoding text
18
25
  text.encode 'windows-1252', fallback: FALLBACK_CHARS
19
26
  rescue ::Encoding::UndefinedConversionError
20
- warn 'The following text could not be fully converted to the Windows-1252 character set:'
21
- warn %(#{text.gsub(/^/, '| ').rstrip})
22
- text.encode 'windows-1252', undef: :replace, replace: %(\u00ac)
27
+ logger.warn %(The following text could not be fully converted to the Windows-1252 character set:
28
+ #{text.gsub(/^/, '| ').rstrip})
29
+ text.encode 'windows-1252', undef: :replace, replace: ?\u00ac
23
30
  rescue ::Encoding::InvalidByteSequenceError
24
31
  raise Prawn::Errors::IncompatibleStringEncoding,
25
32
  %(Your document includes text which is not compatible with the Windows-1252 character set.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Asciidoctor
2
3
  module Prawn
3
4
  module FormattedText
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Asciidoctor
2
3
  module Prawn
3
4
  module Images
@@ -13,7 +14,7 @@ module Images
13
14
  if ::String === file && (((opts = opts.dup).delete :format) == 'svg' || (file.downcase.end_with? '.svg'))
14
15
  #opts[:enable_file_requests_with_root] = (::File.dirname file) unless opts.key? :enable_file_requests_with_root
15
16
  #opts[:enable_web_requests] = allow_uri_read if !(opts.key? :enable_web_requests) && (respond_to? :allow_uri_read)
16
- #opts[:fallback_font_name] = default_svg_font if !(opts.key? :fallback_font_name) && (respond_to? :default_svg_font)
17
+ #opts[:fallback_font_name] = fallback_svg_font_name if !(opts.key? :fallback_font_name) && (respond_to? :fallback_svg_font_name)
17
18
  if (opts.key? :fit) && (fit = opts.delete :fit) && !opts[:width] && !opts[:height]
18
19
  svg (::File.read file), opts do |svg_doc|
19
20
  max_width, max_height = fit
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ########################################################################
2
3
  #
3
4
  # This file was copied from roman-numerals and modified for use with
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rouge'
2
3
  require_relative 'rouge_ext/formatters/prawn'
3
4
  require_relative 'rouge_ext/themes/asciidoctor_pdf_default'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rouge
2
3
  module Formatters
3
4
  # Transforms a token stream into an array of
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rouge
2
3
  module Themes
3
4
  # A variation on the pastie style from Pygments, customized for Asciidoctor PDF
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rouge
2
3
  module Themes
3
4
  # A port of the bw style from Pygments.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  unless RUBY_VERSION >= '2.4'
2
3
  begin
3
4
  require 'unicode' unless defined? Unicode::VERSION
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Asciidoctor
2
3
  module PDF
3
4
  module TemporaryPath
@@ -1,6 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  require 'safe_yaml/load'
2
3
  require 'ostruct'
3
- require_relative 'core_ext/ostruct'
4
4
  require_relative 'measurements'
5
5
 
6
6
  module Asciidoctor
@@ -16,12 +16,11 @@ class ThemeLoader
16
16
  DataDir = ::File.expand_path(::File.join(::File.dirname(__FILE__), '..', '..', 'data'))
17
17
  ThemesDir = ::File.join DataDir, 'themes'
18
18
  FontsDir = ::File.join DataDir, 'fonts'
19
- DefaultThemePath = ::File.expand_path 'default-theme.yml', ThemesDir
20
19
  BaseThemePath = ::File.expand_path 'base-theme.yml', ThemesDir
21
20
 
22
21
  VariableRx = /\$([a-z0-9_-]+)/
23
22
  LoneVariableRx = /^\$([a-z0-9_-]+)$/
24
- HexColorEntryRx = /^(?<k> *\p{Graph}+): +(?!null$)(?<q>["']?)(?<h>#)?(?<v>[a-f0-9]{3,6})\k<q> *(?:#.*)?$/
23
+ HexColorEntryRx = /^(?<k> *\p{Graph}+): +(?!null$)(?<q>["']?)(?<h>#)?(?<v>[a-fA-F0-9]{3,6})\k<q> *(?:#.*)?$/
25
24
  MultiplyDivideOpRx = /(-?\d+(?:\.\d+)?) +([*\/]) +(-?\d+(?:\.\d+)?)/
26
25
  AddSubtractOpRx = /(-?\d+(?:\.\d+)?) +([+\-]) +(-?\d+(?:\.\d+)?)/
27
26
  PrecisionFuncRx = /^(round|floor|ceil)\(/
@@ -44,12 +43,12 @@ class ThemeLoader
44
43
 
45
44
  def self.resolve_theme_file theme_name = nil, theme_path = nil
46
45
  # if .yml extension is given, assume it's a path (don't append -theme.yml)
47
- if ((theme_name ||= 'default').end_with? '.yml')
46
+ if theme_name && (theme_name.end_with? '.yml')
48
47
  # FIXME restrict to jail!
49
48
  theme_file = ::File.expand_path theme_name, theme_path
50
49
  theme_path ||= ::File.dirname theme_file
51
50
  else
52
- theme_file = ::File.expand_path %(#{theme_name}-theme.yml), (theme_path || (theme_path = ThemesDir))
51
+ theme_file = ::File.expand_path %(#{theme_name || 'default'}-theme.yml), (theme_path ||= ThemesDir)
53
52
  end
54
53
  [theme_file, theme_path]
55
54
  end
@@ -69,9 +68,10 @@ class ThemeLoader
69
68
  load_base_theme
70
69
  else
71
70
  theme_data = load_file theme_file, nil, theme_path
72
- unless theme_file == DefaultThemePath
73
- # QUESTION should we enforce any other fallback values?
71
+ unless (::File.dirname theme_file) == ThemesDir
74
72
  theme_data.base_align ||= 'left'
73
+ theme_data.base_line_height ||= 1
74
+ theme_data.base_font_color ||= '000000'
75
75
  theme_data.code_font_family ||= (theme_data.literal_font_family || 'Courier')
76
76
  theme_data.conum_font_family ||= (theme_data.literal_font_family || 'Courier')
77
77
  end
@@ -82,9 +82,9 @@ class ThemeLoader
82
82
 
83
83
  def self.load_file filename, theme_data = nil, theme_path = nil
84
84
  data = ::File.read filename, encoding: ::Encoding::UTF_8
85
- data = data.each_line.map {|l|
86
- l.sub(HexColorEntryRx) { %(#{(m = $~)[:k]}: #{m[:h] || (m[:k].end_with? 'color') ? "'#{m[:v]}'" : m[:v]}) }
87
- }.join unless filename == DefaultThemePath
85
+ data = data.each_line.map {|line|
86
+ line.sub(HexColorEntryRx) { %(#{(m = $~)[:k]}: #{m[:h] || (m[:k].end_with? 'color') ? "'#{m[:v]}'" : m[:v]}) }
87
+ }.join unless (::File.dirname filename) == ThemesDir
88
88
  yaml_data = ::SafeYAML.load data
89
89
  if ::Hash === yaml_data && (yaml_data.key? 'extends')
90
90
  if (extends = yaml_data.delete 'extends')
@@ -93,7 +93,7 @@ class ThemeLoader
93
93
  theme_data = theme_data ? (::OpenStruct.new theme_data.to_h.merge load_base_theme.to_h) : load_base_theme
94
94
  next
95
95
  elsif extend_file == 'default' || extend_file == 'default-with-fallback-font'
96
- extend_file, extend_theme_path = resolve_theme_file extend_file
96
+ extend_file, extend_theme_path = resolve_theme_file extend_file, ThemesDir
97
97
  elsif extend_file.start_with? './'
98
98
  extend_file, extend_theme_path = resolve_theme_file extend_file, (::File.dirname filename)
99
99
  else
@@ -103,7 +103,7 @@ class ThemeLoader
103
103
  end
104
104
  end
105
105
  else
106
- theme_data ||= (filename == DefaultThemePath ? nil : load_base_theme)
106
+ theme_data ||= ((::File.dirname filename) == ThemesDir ? nil : load_base_theme)
107
107
  end
108
108
  self.new.load yaml_data, theme_data, theme_path
109
109
  end
@@ -116,7 +116,7 @@ class ThemeLoader
116
116
 
117
117
  def process_entry key, val, data
118
118
  key = key.tr '-', '_' if key.include? '-'
119
- if key == 'font_catalog' || key == 'font_fallbacks'
119
+ if key.start_with? 'font_'
120
120
  data[key] = val
121
121
  elsif key.start_with? 'admonition_icon_'
122
122
  data[key] = (val || {}).map do |(key2, val2)|
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # patch ttfunk 1.5.0; see https://github.com/prawnpdf/ttfunk/issues/39
2
3
  class TTFunk::Subset::Base
3
4
  alias __checksum checksum
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  module Asciidoctor
2
3
  module PDF
3
- VERSION = '1.5.0.beta.1'
4
+ VERSION = '1.5.0.beta.2'
4
5
  end
5
6
  Pdf = PDF unless const_defined? :Pdf, false
6
7
  end
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../asciidoctor-pdf'
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../../asciidoctor-pdf/version'
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.beta.1
4
+ version: 1.5.0.beta.2
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: 2019-07-08 00:00:00.000000000 Z
12
+ date: 2019-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asciidoctor
@@ -93,14 +93,14 @@ dependencies:
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 2.3.0
96
+ version: 2.4.0
97
97
  type: :runtime
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 2.3.0
103
+ version: 2.4.0
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: safe_yaml
106
106
  requirement: !ruby/object:Gem::Requirement
@@ -177,20 +177,14 @@ dependencies:
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: 3.4.0
181
- - - "!="
182
- - !ruby/object:Gem::Version
183
- version: 3.4.1
180
+ version: 3.6.0
184
181
  type: :development
185
182
  prerelease: false
186
183
  version_requirements: !ruby/object:Gem::Requirement
187
184
  requirements:
188
185
  - - "~>"
189
186
  - !ruby/object:Gem::Version
190
- version: 3.4.0
191
- - - "!="
192
- - !ruby/object:Gem::Version
193
- version: 3.4.1
187
+ version: 3.6.0
194
188
  - !ruby/object:Gem::Dependency
195
189
  name: rspec
196
190
  requirement: !ruby/object:Gem::Requirement
@@ -248,12 +242,19 @@ files:
248
242
  - README.adoc
249
243
  - asciidoctor-pdf.gemspec
250
244
  - bin/asciidoctor-pdf
251
- - data/fonts/LICENSE-mplus-testflight-58
252
- - data/fonts/LICENSE-noto-2015-06-05
245
+ - data/fonts/ABOUT-mplus1mn-subset
246
+ - data/fonts/ABOUT-mplus1p-subset
247
+ - data/fonts/ABOUT-notoserif-subset
248
+ - data/fonts/LICENSE-mplus
249
+ - data/fonts/LICENSE-notoserif
253
250
  - data/fonts/mplus1mn-bold-ascii.ttf
251
+ - data/fonts/mplus1mn-bold-subset.ttf
254
252
  - data/fonts/mplus1mn-bold_italic-ascii.ttf
253
+ - data/fonts/mplus1mn-bold_italic-subset.ttf
255
254
  - data/fonts/mplus1mn-italic-ascii.ttf
255
+ - data/fonts/mplus1mn-italic-subset.ttf
256
256
  - data/fonts/mplus1mn-regular-ascii-conums.ttf
257
+ - data/fonts/mplus1mn-regular-subset.ttf
257
258
  - data/fonts/mplus1p-regular-fallback.ttf
258
259
  - data/fonts/notoserif-bold-subset.ttf
259
260
  - data/fonts/notoserif-bold_italic-subset.ttf
@@ -278,7 +279,6 @@ files:
278
279
  - lib/asciidoctor-pdf/core_ext/hash.rb
279
280
  - lib/asciidoctor-pdf/core_ext/numeric.rb
280
281
  - lib/asciidoctor-pdf/core_ext/object.rb
281
- - lib/asciidoctor-pdf/core_ext/ostruct.rb
282
282
  - lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
283
283
  - lib/asciidoctor-pdf/core_ext/regexp.rb
284
284
  - lib/asciidoctor-pdf/core_ext/string.rb
@@ -1,8 +0,0 @@
1
- class OpenStruct
2
- def delete key
3
- begin
4
- delete_field key
5
- rescue ::NameError
6
- end
7
- end unless method_defined? :delete
8
- end