asciidoctor-pdf 1.5.0.beta.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +277 -2
  3. data/LICENSE.adoc +1 -1
  4. data/NOTICE.adoc +1 -1
  5. data/README.adoc +486 -292
  6. data/asciidoctor-pdf.gemspec +12 -11
  7. data/bin/asciidoctor-pdf +2 -6
  8. data/bin/asciidoctor-pdf-optimize +20 -0
  9. data/data/fonts/ABOUT-mplus1mn-subset +26 -0
  10. data/data/fonts/ABOUT-mplus1p-subset +26 -0
  11. data/data/fonts/ABOUT-notoemoji-subset +3 -0
  12. data/data/fonts/ABOUT-notoserif-subset +26 -0
  13. data/data/fonts/{LICENSE-mplus-testflight-58 → LICENSE-mplus} +2 -2
  14. data/data/fonts/{LICENSE-noto-2015-06-05 → LICENSE-notoserif} +0 -0
  15. data/data/fonts/mplus1mn-bold-ascii.ttf +0 -0
  16. data/data/fonts/mplus1mn-bold-subset.ttf +0 -0
  17. data/data/fonts/mplus1mn-bold_italic-ascii.ttf +0 -0
  18. data/data/fonts/mplus1mn-bold_italic-subset.ttf +0 -0
  19. data/data/fonts/mplus1mn-italic-ascii.ttf +0 -0
  20. data/data/fonts/mplus1mn-italic-subset.ttf +0 -0
  21. data/data/fonts/mplus1mn-regular-ascii-conums.ttf +0 -0
  22. data/data/fonts/mplus1mn-regular-subset.ttf +0 -0
  23. data/data/fonts/mplus1p-regular-fallback.ttf +0 -0
  24. data/data/fonts/notoemoji-subset.ttf +0 -0
  25. data/data/fonts/notoserif-bold-subset.ttf +0 -0
  26. data/data/fonts/notoserif-bold_italic-subset.ttf +0 -0
  27. data/data/fonts/notoserif-italic-subset.ttf +0 -0
  28. data/data/fonts/notoserif-regular-subset.ttf +0 -0
  29. data/data/themes/base-theme.yml +22 -4
  30. data/data/themes/default-theme.yml +59 -29
  31. data/data/themes/default-with-fallback-font-theme.yml +4 -17
  32. data/docs/theming-guide.adoc +1647 -167
  33. data/lib/asciidoctor/pdf/converter.rb +4489 -0
  34. data/lib/{asciidoctor-pdf/asciidoctor_ext → asciidoctor/pdf/ext/asciidoctor}/abstract_block.rb +2 -0
  35. data/lib/asciidoctor/pdf/ext/asciidoctor/abstract_node.rb +7 -0
  36. data/lib/{asciidoctor-pdf/asciidoctor_ext → asciidoctor/pdf/ext/asciidoctor}/document.rb +2 -0
  37. data/lib/asciidoctor/pdf/ext/asciidoctor/image.rb +35 -0
  38. data/lib/{asciidoctor-pdf/asciidoctor_ext → asciidoctor/pdf/ext/asciidoctor}/list.rb +4 -2
  39. data/lib/{asciidoctor-pdf/asciidoctor_ext → asciidoctor/pdf/ext/asciidoctor}/list_item.rb +3 -1
  40. data/lib/asciidoctor/pdf/ext/asciidoctor/logging_shim.rb +33 -0
  41. data/lib/{asciidoctor-pdf/asciidoctor_ext → asciidoctor/pdf/ext/asciidoctor}/section.rb +9 -6
  42. data/lib/asciidoctor/pdf/ext/asciidoctor.rb +11 -0
  43. data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/array.rb +6 -0
  44. data/lib/asciidoctor/pdf/ext/core/file.rb +9 -0
  45. data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/hash.rb +2 -0
  46. data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/numeric.rb +5 -3
  47. data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/object.rb +3 -1
  48. data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/quantifiable_stdout.rb +9 -1
  49. data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/regexp.rb +2 -0
  50. data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/string.rb +9 -13
  51. data/lib/asciidoctor/pdf/ext/core.rb +10 -0
  52. data/lib/asciidoctor/pdf/ext/pdf-core/page.rb +54 -0
  53. data/lib/asciidoctor/pdf/ext/pdf-core/pdf_object.rb +8 -0
  54. data/lib/asciidoctor/pdf/ext/pdf-core.rb +4 -0
  55. data/lib/asciidoctor/pdf/ext/prawn/coderay_encoder.rb +117 -0
  56. data/lib/asciidoctor/pdf/ext/prawn/extensions.rb +922 -0
  57. data/lib/{asciidoctor-pdf/prawn_ext → asciidoctor/pdf/ext/prawn}/font/afm.rb +14 -10
  58. data/lib/asciidoctor/pdf/ext/prawn/font_metric_cache.rb +9 -0
  59. data/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb +66 -0
  60. data/lib/{asciidoctor-pdf/prawn_ext → asciidoctor/pdf/ext/prawn}/formatted_text/fragment.rb +16 -12
  61. data/lib/asciidoctor/pdf/ext/prawn/images.rb +54 -0
  62. data/lib/asciidoctor/pdf/ext/prawn-svg/interface.rb +14 -0
  63. data/lib/{asciidoctor-pdf/prawn-svg_ext.rb → asciidoctor/pdf/ext/prawn-svg.rb} +3 -1
  64. data/lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb +76 -0
  65. data/lib/{asciidoctor-pdf/prawn-table_ext → asciidoctor/pdf/ext/prawn-table}/cell/text.rb +6 -3
  66. data/lib/{asciidoctor-pdf/prawn-table_ext → asciidoctor/pdf/ext/prawn-table}/cell.rb +10 -10
  67. data/lib/asciidoctor/pdf/ext/prawn-table.rb +6 -0
  68. data/lib/{asciidoctor-pdf/prawn-templates_ext.rb → asciidoctor/pdf/ext/prawn-templates.rb} +2 -0
  69. data/lib/asciidoctor/pdf/ext/prawn.rb +9 -0
  70. data/lib/asciidoctor/pdf/ext/pygments.rb +34 -0
  71. data/lib/asciidoctor/pdf/ext/rouge/formatters/prawn.rb +208 -0
  72. data/lib/{asciidoctor-pdf/rouge_ext → asciidoctor/pdf/ext/rouge}/themes/asciidoctor_pdf_default.rb +2 -0
  73. data/lib/asciidoctor/pdf/ext/rouge.rb +5 -0
  74. data/lib/asciidoctor/pdf/ext.rb +9 -0
  75. data/lib/asciidoctor/pdf/formatted_text/formatter.rb +43 -0
  76. data/lib/asciidoctor/pdf/formatted_text/fragment_position_renderer.rb +14 -0
  77. data/lib/asciidoctor/pdf/formatted_text/inline_destination_marker.rb +21 -0
  78. data/lib/asciidoctor/pdf/formatted_text/inline_image_arranger.rb +134 -0
  79. data/lib/asciidoctor/pdf/formatted_text/inline_image_renderer.rb +51 -0
  80. data/lib/asciidoctor/pdf/formatted_text/inline_text_aligner.rb +22 -0
  81. data/lib/{asciidoctor-pdf → asciidoctor/pdf}/formatted_text/parser.rb +31 -7
  82. data/lib/{asciidoctor-pdf → asciidoctor/pdf}/formatted_text/parser.treetop +3 -4
  83. data/lib/asciidoctor/pdf/formatted_text/source_wrap.rb +43 -0
  84. data/lib/asciidoctor/pdf/formatted_text/text_background_and_border_renderer.rb +55 -0
  85. data/lib/asciidoctor/pdf/formatted_text/transform.rb +394 -0
  86. data/lib/{asciidoctor-pdf → asciidoctor/pdf}/formatted_text.rb +4 -0
  87. data/lib/asciidoctor/pdf/index_catalog.rb +133 -0
  88. data/lib/asciidoctor/pdf/measurements.rb +62 -0
  89. data/lib/asciidoctor/pdf/optimizer.rb +44 -0
  90. data/lib/asciidoctor/pdf/pdfmark.rb +41 -0
  91. data/lib/asciidoctor/pdf/roman_numeral.rb +128 -0
  92. data/lib/asciidoctor/pdf/sanitizer.rb +45 -0
  93. data/lib/asciidoctor/pdf/text_transformer.rb +116 -0
  94. data/lib/asciidoctor/pdf/theme_loader.rb +305 -0
  95. data/lib/asciidoctor/pdf/version.rb +8 -1
  96. data/lib/asciidoctor/pdf.rb +15 -1
  97. data/lib/asciidoctor-pdf/converter.rb +2 -3824
  98. data/lib/asciidoctor-pdf/version.rb +3 -6
  99. data/lib/asciidoctor-pdf.rb +3 -4
  100. metadata +130 -85
  101. data/lib/asciidoctor-pdf/asciidoctor_ext/image.rb +0 -24
  102. data/lib/asciidoctor-pdf/asciidoctor_ext/logging_shim.rb +0 -25
  103. data/lib/asciidoctor-pdf/asciidoctor_ext.rb +0 -8
  104. data/lib/asciidoctor-pdf/core_ext/ostruct.rb +0 -8
  105. data/lib/asciidoctor-pdf/core_ext.rb +0 -6
  106. data/lib/asciidoctor-pdf/formatted_text/formatter.rb +0 -40
  107. data/lib/asciidoctor-pdf/formatted_text/inline_destination_marker.rb +0 -21
  108. data/lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb +0 -160
  109. data/lib/asciidoctor-pdf/formatted_text/inline_image_renderer.rb +0 -46
  110. data/lib/asciidoctor-pdf/formatted_text/inline_text_aligner.rb +0 -20
  111. data/lib/asciidoctor-pdf/formatted_text/text_background_and_border_renderer.rb +0 -45
  112. data/lib/asciidoctor-pdf/formatted_text/transform.rb +0 -294
  113. data/lib/asciidoctor-pdf/implicit_header_processor.rb +0 -63
  114. data/lib/asciidoctor-pdf/index_catalog.rb +0 -127
  115. data/lib/asciidoctor-pdf/measurements.rb +0 -58
  116. data/lib/asciidoctor-pdf/pdf-core_ext/page.rb +0 -25
  117. data/lib/asciidoctor-pdf/pdf-core_ext/pdf_object.rb +0 -6
  118. data/lib/asciidoctor-pdf/pdf-core_ext.rb +0 -2
  119. data/lib/asciidoctor-pdf/pdfmark.rb +0 -33
  120. data/lib/asciidoctor-pdf/prawn-svg_ext/interface.rb +0 -10
  121. data/lib/asciidoctor-pdf/prawn-table_ext/cell/asciidoc.rb +0 -69
  122. data/lib/asciidoctor-pdf/prawn-table_ext.rb +0 -4
  123. data/lib/asciidoctor-pdf/prawn_ext/coderay_encoder.rb +0 -115
  124. data/lib/asciidoctor-pdf/prawn_ext/extensions.rb +0 -904
  125. data/lib/asciidoctor-pdf/prawn_ext/images.rb +0 -51
  126. data/lib/asciidoctor-pdf/prawn_ext.rb +0 -5
  127. data/lib/asciidoctor-pdf/roman_numeral.rb +0 -126
  128. data/lib/asciidoctor-pdf/rouge_ext/formatters/prawn.rb +0 -175
  129. data/lib/asciidoctor-pdf/rouge_ext/themes/bw.rb +0 -38
  130. data/lib/asciidoctor-pdf/rouge_ext.rb +0 -4
  131. data/lib/asciidoctor-pdf/sanitizer.rb +0 -101
  132. data/lib/asciidoctor-pdf/temporary_path.rb +0 -13
  133. data/lib/asciidoctor-pdf/theme_loader.rb +0 -280
  134. data/lib/asciidoctor-pdf/ttfunk_ext.rb +0 -8
@@ -1,6 +1,3 @@
1
- module Asciidoctor
2
- module PDF
3
- VERSION = '1.5.0.beta.1'
4
- end
5
- Pdf = PDF unless const_defined? :Pdf, false
6
- end
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../asciidoctor/pdf/version'
@@ -1,4 +1,3 @@
1
- require 'asciidoctor' unless defined? Asciidoctor.load
2
- require_relative 'asciidoctor-pdf/asciidoctor_ext'
3
- require_relative 'asciidoctor-pdf/version'
4
- require_relative 'asciidoctor-pdf/converter'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'asciidoctor/pdf'
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
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: 2020-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asciidoctor
@@ -45,6 +45,26 @@ dependencies:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.2.0
48
+ - !ruby/object:Gem::Dependency
49
+ name: ttfunk
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.5.0
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 1.5.1
58
+ type: :runtime
59
+ prerelease: false
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - "~>"
63
+ - !ruby/object:Gem::Version
64
+ version: 1.5.0
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 1.5.1
48
68
  - !ruby/object:Gem::Dependency
49
69
  name: prawn-table
50
70
  requirement: !ruby/object:Gem::Requirement
@@ -79,28 +99,28 @@ dependencies:
79
99
  requirements:
80
100
  - - "~>"
81
101
  - !ruby/object:Gem::Version
82
- version: 0.29.0
102
+ version: 0.30.0
83
103
  type: :runtime
84
104
  prerelease: false
85
105
  version_requirements: !ruby/object:Gem::Requirement
86
106
  requirements:
87
107
  - - "~>"
88
108
  - !ruby/object:Gem::Version
89
- version: 0.29.0
109
+ version: 0.30.0
90
110
  - !ruby/object:Gem::Dependency
91
111
  name: prawn-icon
92
112
  requirement: !ruby/object:Gem::Requirement
93
113
  requirements:
94
114
  - - "~>"
95
115
  - !ruby/object:Gem::Version
96
- version: 2.3.0
116
+ version: 2.5.0
97
117
  type: :runtime
98
118
  prerelease: false
99
119
  version_requirements: !ruby/object:Gem::Requirement
100
120
  requirements:
101
121
  - - "~>"
102
122
  - !ruby/object:Gem::Version
103
- version: 2.3.0
123
+ version: 2.5.0
104
124
  - !ruby/object:Gem::Dependency
105
125
  name: safe_yaml
106
126
  requirement: !ruby/object:Gem::Requirement
@@ -149,76 +169,84 @@ dependencies:
149
169
  requirements:
150
170
  - - "~>"
151
171
  - !ruby/object:Gem::Version
152
- version: 1.5.0
172
+ version: 1.6.0
153
173
  type: :runtime
154
174
  prerelease: false
155
175
  version_requirements: !ruby/object:Gem::Requirement
156
176
  requirements:
157
177
  - - "~>"
158
178
  - !ruby/object:Gem::Version
159
- version: 1.5.0
179
+ version: 1.6.0
160
180
  - !ruby/object:Gem::Dependency
161
181
  name: rake
162
182
  requirement: !ruby/object:Gem::Requirement
163
183
  requirements:
164
184
  - - "~>"
165
185
  - !ruby/object:Gem::Version
166
- version: 12.3.0
186
+ version: 13.0.0
167
187
  type: :development
168
188
  prerelease: false
169
189
  version_requirements: !ruby/object:Gem::Requirement
170
190
  requirements:
171
191
  - - "~>"
172
192
  - !ruby/object:Gem::Version
173
- version: 12.3.0
193
+ version: 13.0.0
174
194
  - !ruby/object:Gem::Dependency
175
- name: rouge
195
+ name: rspec
176
196
  requirement: !ruby/object:Gem::Requirement
177
197
  requirements:
178
198
  - - "~>"
179
199
  - !ruby/object:Gem::Version
180
- version: 3.4.0
181
- - - "!="
182
- - !ruby/object:Gem::Version
183
- version: 3.4.1
200
+ version: 3.9.0
184
201
  type: :development
185
202
  prerelease: false
186
203
  version_requirements: !ruby/object:Gem::Requirement
187
204
  requirements:
188
205
  - - "~>"
189
206
  - !ruby/object:Gem::Version
190
- version: 3.4.0
191
- - - "!="
207
+ version: 3.9.0
208
+ - !ruby/object:Gem::Dependency
209
+ name: pdf-inspector
210
+ requirement: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - "~>"
213
+ - !ruby/object:Gem::Version
214
+ version: 1.3.0
215
+ type: :development
216
+ prerelease: false
217
+ version_requirements: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - "~>"
192
220
  - !ruby/object:Gem::Version
193
- version: 3.4.1
221
+ version: 1.3.0
194
222
  - !ruby/object:Gem::Dependency
195
- name: rspec
223
+ name: rouge
196
224
  requirement: !ruby/object:Gem::Requirement
197
225
  requirements:
198
226
  - - "~>"
199
227
  - !ruby/object:Gem::Version
200
- version: 3.8.0
228
+ version: '3.0'
201
229
  type: :development
202
230
  prerelease: false
203
231
  version_requirements: !ruby/object:Gem::Requirement
204
232
  requirements:
205
233
  - - "~>"
206
234
  - !ruby/object:Gem::Version
207
- version: 3.8.0
235
+ version: '3.0'
208
236
  - !ruby/object:Gem::Dependency
209
- name: pdf-inspector
237
+ name: coderay
210
238
  requirement: !ruby/object:Gem::Requirement
211
239
  requirements:
212
240
  - - "~>"
213
241
  - !ruby/object:Gem::Version
214
- version: 1.3.0
242
+ version: 1.1.0
215
243
  type: :development
216
244
  prerelease: false
217
245
  version_requirements: !ruby/object:Gem::Requirement
218
246
  requirements:
219
247
  - - "~>"
220
248
  - !ruby/object:Gem::Version
221
- version: 1.3.0
249
+ version: 1.1.0
222
250
  - !ruby/object:Gem::Dependency
223
251
  name: chunky_png
224
252
  requirement: !ruby/object:Gem::Requirement
@@ -238,6 +266,7 @@ description: An extension for Asciidoctor that converts AsciiDoc documents to PD
238
266
  email: dan@opendevise.com
239
267
  executables:
240
268
  - asciidoctor-pdf
269
+ - asciidoctor-pdf-optimize
241
270
  extensions: []
242
271
  extra_rdoc_files: []
243
272
  files:
@@ -248,13 +277,23 @@ files:
248
277
  - README.adoc
249
278
  - asciidoctor-pdf.gemspec
250
279
  - bin/asciidoctor-pdf
251
- - data/fonts/LICENSE-mplus-testflight-58
252
- - data/fonts/LICENSE-noto-2015-06-05
280
+ - bin/asciidoctor-pdf-optimize
281
+ - data/fonts/ABOUT-mplus1mn-subset
282
+ - data/fonts/ABOUT-mplus1p-subset
283
+ - data/fonts/ABOUT-notoemoji-subset
284
+ - data/fonts/ABOUT-notoserif-subset
285
+ - data/fonts/LICENSE-mplus
286
+ - data/fonts/LICENSE-notoserif
253
287
  - data/fonts/mplus1mn-bold-ascii.ttf
288
+ - data/fonts/mplus1mn-bold-subset.ttf
254
289
  - data/fonts/mplus1mn-bold_italic-ascii.ttf
290
+ - data/fonts/mplus1mn-bold_italic-subset.ttf
255
291
  - data/fonts/mplus1mn-italic-ascii.ttf
292
+ - data/fonts/mplus1mn-italic-subset.ttf
256
293
  - data/fonts/mplus1mn-regular-ascii-conums.ttf
294
+ - data/fonts/mplus1mn-regular-subset.ttf
257
295
  - data/fonts/mplus1p-regular-fallback.ttf
296
+ - data/fonts/notoemoji-subset.ttf
258
297
  - data/fonts/notoserif-bold-subset.ttf
259
298
  - data/fonts/notoserif-bold_italic-subset.ttf
260
299
  - data/fonts/notoserif-italic-subset.ttf
@@ -264,65 +303,71 @@ files:
264
303
  - data/themes/default-with-fallback-font-theme.yml
265
304
  - docs/theming-guide.adoc
266
305
  - lib/asciidoctor-pdf.rb
267
- - lib/asciidoctor-pdf/asciidoctor_ext.rb
268
- - lib/asciidoctor-pdf/asciidoctor_ext/abstract_block.rb
269
- - lib/asciidoctor-pdf/asciidoctor_ext/document.rb
270
- - lib/asciidoctor-pdf/asciidoctor_ext/image.rb
271
- - lib/asciidoctor-pdf/asciidoctor_ext/list.rb
272
- - lib/asciidoctor-pdf/asciidoctor_ext/list_item.rb
273
- - lib/asciidoctor-pdf/asciidoctor_ext/logging_shim.rb
274
- - lib/asciidoctor-pdf/asciidoctor_ext/section.rb
275
306
  - lib/asciidoctor-pdf/converter.rb
276
- - lib/asciidoctor-pdf/core_ext.rb
277
- - lib/asciidoctor-pdf/core_ext/array.rb
278
- - lib/asciidoctor-pdf/core_ext/hash.rb
279
- - lib/asciidoctor-pdf/core_ext/numeric.rb
280
- - lib/asciidoctor-pdf/core_ext/object.rb
281
- - lib/asciidoctor-pdf/core_ext/ostruct.rb
282
- - lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
283
- - lib/asciidoctor-pdf/core_ext/regexp.rb
284
- - lib/asciidoctor-pdf/core_ext/string.rb
285
- - lib/asciidoctor-pdf/formatted_text.rb
286
- - lib/asciidoctor-pdf/formatted_text/formatter.rb
287
- - lib/asciidoctor-pdf/formatted_text/inline_destination_marker.rb
288
- - lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb
289
- - lib/asciidoctor-pdf/formatted_text/inline_image_renderer.rb
290
- - lib/asciidoctor-pdf/formatted_text/inline_text_aligner.rb
291
- - lib/asciidoctor-pdf/formatted_text/parser.rb
292
- - lib/asciidoctor-pdf/formatted_text/parser.treetop
293
- - lib/asciidoctor-pdf/formatted_text/text_background_and_border_renderer.rb
294
- - lib/asciidoctor-pdf/formatted_text/transform.rb
295
- - lib/asciidoctor-pdf/implicit_header_processor.rb
296
- - lib/asciidoctor-pdf/index_catalog.rb
297
- - lib/asciidoctor-pdf/measurements.rb
298
- - lib/asciidoctor-pdf/pdf-core_ext.rb
299
- - lib/asciidoctor-pdf/pdf-core_ext/page.rb
300
- - lib/asciidoctor-pdf/pdf-core_ext/pdf_object.rb
301
- - lib/asciidoctor-pdf/pdfmark.rb
302
- - lib/asciidoctor-pdf/prawn-svg_ext.rb
303
- - lib/asciidoctor-pdf/prawn-svg_ext/interface.rb
304
- - lib/asciidoctor-pdf/prawn-table_ext.rb
305
- - lib/asciidoctor-pdf/prawn-table_ext/cell.rb
306
- - lib/asciidoctor-pdf/prawn-table_ext/cell/asciidoc.rb
307
- - lib/asciidoctor-pdf/prawn-table_ext/cell/text.rb
308
- - lib/asciidoctor-pdf/prawn-templates_ext.rb
309
- - lib/asciidoctor-pdf/prawn_ext.rb
310
- - lib/asciidoctor-pdf/prawn_ext/coderay_encoder.rb
311
- - lib/asciidoctor-pdf/prawn_ext/extensions.rb
312
- - lib/asciidoctor-pdf/prawn_ext/font/afm.rb
313
- - lib/asciidoctor-pdf/prawn_ext/formatted_text/fragment.rb
314
- - lib/asciidoctor-pdf/prawn_ext/images.rb
315
- - lib/asciidoctor-pdf/roman_numeral.rb
316
- - lib/asciidoctor-pdf/rouge_ext.rb
317
- - lib/asciidoctor-pdf/rouge_ext/formatters/prawn.rb
318
- - lib/asciidoctor-pdf/rouge_ext/themes/asciidoctor_pdf_default.rb
319
- - lib/asciidoctor-pdf/rouge_ext/themes/bw.rb
320
- - lib/asciidoctor-pdf/sanitizer.rb
321
- - lib/asciidoctor-pdf/temporary_path.rb
322
- - lib/asciidoctor-pdf/theme_loader.rb
323
- - lib/asciidoctor-pdf/ttfunk_ext.rb
324
307
  - lib/asciidoctor-pdf/version.rb
325
308
  - lib/asciidoctor/pdf.rb
309
+ - lib/asciidoctor/pdf/converter.rb
310
+ - lib/asciidoctor/pdf/ext.rb
311
+ - lib/asciidoctor/pdf/ext/asciidoctor.rb
312
+ - lib/asciidoctor/pdf/ext/asciidoctor/abstract_block.rb
313
+ - lib/asciidoctor/pdf/ext/asciidoctor/abstract_node.rb
314
+ - lib/asciidoctor/pdf/ext/asciidoctor/document.rb
315
+ - lib/asciidoctor/pdf/ext/asciidoctor/image.rb
316
+ - lib/asciidoctor/pdf/ext/asciidoctor/list.rb
317
+ - lib/asciidoctor/pdf/ext/asciidoctor/list_item.rb
318
+ - lib/asciidoctor/pdf/ext/asciidoctor/logging_shim.rb
319
+ - lib/asciidoctor/pdf/ext/asciidoctor/section.rb
320
+ - lib/asciidoctor/pdf/ext/core.rb
321
+ - lib/asciidoctor/pdf/ext/core/array.rb
322
+ - lib/asciidoctor/pdf/ext/core/file.rb
323
+ - lib/asciidoctor/pdf/ext/core/hash.rb
324
+ - lib/asciidoctor/pdf/ext/core/numeric.rb
325
+ - lib/asciidoctor/pdf/ext/core/object.rb
326
+ - lib/asciidoctor/pdf/ext/core/quantifiable_stdout.rb
327
+ - lib/asciidoctor/pdf/ext/core/regexp.rb
328
+ - lib/asciidoctor/pdf/ext/core/string.rb
329
+ - lib/asciidoctor/pdf/ext/pdf-core.rb
330
+ - lib/asciidoctor/pdf/ext/pdf-core/page.rb
331
+ - lib/asciidoctor/pdf/ext/pdf-core/pdf_object.rb
332
+ - lib/asciidoctor/pdf/ext/prawn-svg.rb
333
+ - lib/asciidoctor/pdf/ext/prawn-svg/interface.rb
334
+ - lib/asciidoctor/pdf/ext/prawn-table.rb
335
+ - lib/asciidoctor/pdf/ext/prawn-table/cell.rb
336
+ - lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb
337
+ - lib/asciidoctor/pdf/ext/prawn-table/cell/text.rb
338
+ - lib/asciidoctor/pdf/ext/prawn-templates.rb
339
+ - lib/asciidoctor/pdf/ext/prawn.rb
340
+ - lib/asciidoctor/pdf/ext/prawn/coderay_encoder.rb
341
+ - lib/asciidoctor/pdf/ext/prawn/extensions.rb
342
+ - lib/asciidoctor/pdf/ext/prawn/font/afm.rb
343
+ - lib/asciidoctor/pdf/ext/prawn/font_metric_cache.rb
344
+ - lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb
345
+ - lib/asciidoctor/pdf/ext/prawn/formatted_text/fragment.rb
346
+ - lib/asciidoctor/pdf/ext/prawn/images.rb
347
+ - lib/asciidoctor/pdf/ext/pygments.rb
348
+ - lib/asciidoctor/pdf/ext/rouge.rb
349
+ - lib/asciidoctor/pdf/ext/rouge/formatters/prawn.rb
350
+ - lib/asciidoctor/pdf/ext/rouge/themes/asciidoctor_pdf_default.rb
351
+ - lib/asciidoctor/pdf/formatted_text.rb
352
+ - lib/asciidoctor/pdf/formatted_text/formatter.rb
353
+ - lib/asciidoctor/pdf/formatted_text/fragment_position_renderer.rb
354
+ - lib/asciidoctor/pdf/formatted_text/inline_destination_marker.rb
355
+ - lib/asciidoctor/pdf/formatted_text/inline_image_arranger.rb
356
+ - lib/asciidoctor/pdf/formatted_text/inline_image_renderer.rb
357
+ - lib/asciidoctor/pdf/formatted_text/inline_text_aligner.rb
358
+ - lib/asciidoctor/pdf/formatted_text/parser.rb
359
+ - lib/asciidoctor/pdf/formatted_text/parser.treetop
360
+ - lib/asciidoctor/pdf/formatted_text/source_wrap.rb
361
+ - lib/asciidoctor/pdf/formatted_text/text_background_and_border_renderer.rb
362
+ - lib/asciidoctor/pdf/formatted_text/transform.rb
363
+ - lib/asciidoctor/pdf/index_catalog.rb
364
+ - lib/asciidoctor/pdf/measurements.rb
365
+ - lib/asciidoctor/pdf/optimizer.rb
366
+ - lib/asciidoctor/pdf/pdfmark.rb
367
+ - lib/asciidoctor/pdf/roman_numeral.rb
368
+ - lib/asciidoctor/pdf/sanitizer.rb
369
+ - lib/asciidoctor/pdf/text_transformer.rb
370
+ - lib/asciidoctor/pdf/theme_loader.rb
326
371
  - lib/asciidoctor/pdf/version.rb
327
372
  homepage: https://asciidoctor.org/docs/asciidoctor-pdf
328
373
  licenses:
@@ -343,11 +388,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
343
388
  version: '0'
344
389
  required_rubygems_version: !ruby/object:Gem::Requirement
345
390
  requirements:
346
- - - ">"
391
+ - - ">="
347
392
  - !ruby/object:Gem::Version
348
- version: 1.3.1
393
+ version: '0'
349
394
  requirements: []
350
- rubygems_version: 3.0.4
395
+ rubygems_version: 3.0.6
351
396
  signing_key:
352
397
  specification_version: 4
353
398
  summary: Converts AsciiDoc documents to PDF using Asciidoctor and Prawn
@@ -1,24 +0,0 @@
1
- module Asciidoctor
2
- module Image
3
- DataUriRx = /^data:image\/(?<fmt>png|jpe?g|gif|pdf|bmp|tiff);base64,(?<data>.*)$/
4
-
5
- class << self
6
- def format path, attributes = nil
7
- (attributes && attributes['format']) || ((ext = ::File.extname path).downcase.slice 1, ext.length)
8
- end
9
- end
10
-
11
- def format
12
- (attr 'format', nil, false) || ((ext = ::File.extname(inline? ? target : (attr 'target'))).downcase.slice 1, ext.length)
13
- end
14
-
15
- def target_and_format
16
- image_path = inline? ? target : (attr 'target')
17
- if (image_path.start_with? 'data:') && (m = DataUriRx.match image_path)
18
- [(m[:data].extend ::Base64), m[:fmt]]
19
- else
20
- [image_path, (attr 'format', nil, false) || ((ext = ::File.extname image_path).downcase.slice 1, ext.length)]
21
- end
22
- end
23
- end
24
- end
@@ -1,25 +0,0 @@
1
- module Asciidoctor
2
- class StubLogger
3
- class << self
4
- def info message = nil
5
- # ignore since this isn't a real logger
6
- end
7
-
8
- def warn message = nil
9
- message = block_given? ? yield : message unless message
10
- ::Kernel.warn %(asciidoctor: WARNING: #{message})
11
- end
12
-
13
- def error message = nil
14
- message = block_given? ? yield : message unless message
15
- ::Kernel.warn %(asciidoctor: ERROR: #{message})
16
- end
17
- end
18
- end
19
-
20
- module LoggingShim
21
- def logger
22
- StubLogger
23
- end
24
- end
25
- end
@@ -1,8 +0,0 @@
1
- # NOTE these are either candidates for inclusion in Asciidoctor core or backports
2
- require_relative 'asciidoctor_ext/abstract_block'
3
- require_relative 'asciidoctor_ext/document'
4
- require_relative 'asciidoctor_ext/section'
5
- require_relative 'asciidoctor_ext/list'
6
- require_relative 'asciidoctor_ext/list_item'
7
- require_relative 'asciidoctor_ext/logging_shim' unless defined? Asciidoctor::Logging
8
- require_relative 'asciidoctor_ext/image'
@@ -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
@@ -1,6 +0,0 @@
1
- require_relative 'core_ext/object'
2
- require_relative 'core_ext/array'
3
- require_relative 'core_ext/hash'
4
- require_relative 'core_ext/numeric'
5
- require_relative 'core_ext/string'
6
- require_relative 'core_ext/regexp'
@@ -1,40 +0,0 @@
1
- module Asciidoctor
2
- module PDF
3
- module FormattedText
4
- class Formatter
5
- if defined? ::Asciidoctor::Logging
6
- include ::Asciidoctor::Logging
7
- else
8
- include ::Asciidoctor::LoggingShim
9
- end
10
-
11
- FormattingSnifferPattern = /[<&]/
12
- WHITESPACE = " \t\n"
13
-
14
- def initialize options = {}
15
- @parser = MarkupParser.new
16
- @transform = Transform.new merge_adjacent_text_nodes: true, theme: options[:theme]
17
- end
18
-
19
- def format string, *args
20
- options = args[0] || {}
21
- string = string.tr_s(WHITESPACE, ' ') if options[:normalize]
22
- return [text: string] unless FormattingSnifferPattern.match? string
23
- if (parsed = @parser.parse(string))
24
- @transform.apply(parsed.content)
25
- else
26
- logger.error %(failed to parse formatted text: #{string})
27
- [text: string]
28
- end
29
- end
30
-
31
- # The original purpose of this method is to split paragraphs, but our formatter only works on paragraphs that have
32
- # been presplit. Therefore, we just need to wrap the fragments in a single-element array (representing a single
33
- # paragraph) and return them.
34
- def array_paragraphs fragments
35
- [fragments]
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,21 +0,0 @@
1
- module Asciidoctor::PDF::FormattedText
2
- module InlineDestinationMarker
3
- module_function
4
-
5
- # render_behind is called before the text is printed
6
- def render_behind fragment
7
- unless (pdf = fragment.document).scratch?
8
- if (name = fragment.format_state[:name])
9
- if fragment.format_state[:type] == :indexterm
10
- (pdf.instance_variable_get :@index).link_dest_to_page name, pdf.page_number
11
- end
12
- # get precise position of the reference (x, y)
13
- dest_rect = fragment.absolute_bounding_box
14
- pdf.add_dest name, (pdf.dest_xyz dest_rect[0], dest_rect[-1])
15
- # prevent any text from being written
16
- fragment.conceal
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,160 +0,0 @@
1
- module Asciidoctor::PDF::FormattedText
2
- module InlineImageArranger
3
- include ::Asciidoctor::PDF::Measurements
4
- if defined? ::Asciidoctor::Logging
5
- include ::Asciidoctor::Logging
6
- else
7
- include ::Asciidoctor::LoggingShim
8
- end
9
-
10
- ImagePlaceholderChar = '.'
11
- begin
12
- require 'concurrent/map' unless defined? ::Concurrent::Map
13
- PlaceholderWidthCache = ::Concurrent::Map.new
14
- rescue
15
- PlaceholderWidthCache = {}
16
- end
17
- TemporaryPath = ::Asciidoctor::PDF::TemporaryPath
18
-
19
- def wrap fragments
20
- arrange_images fragments
21
- super
22
- end
23
-
24
- # Iterates over the fragments that represent inline images and prepares the
25
- # image data to be embedded into the document.
26
- #
27
- # This method populates the image_width, image_height, image_obj and
28
- # image_info (PNG only) keys on the fragment. The text is replaced with
29
- # placeholder text that will be used to reserve enough room in the line to
30
- # fit the image.
31
- #
32
- # The image height is scaled down to 75% of the specified width (px to pt
33
- # conversion). If the image height is more than 1.5x the height of the
34
- # surrounding line of text, the font size and line metrics of the fragment
35
- # are modified to fit the image in the line.
36
- #
37
- # If this is the scratch document, the image renderer callback is removed so
38
- # that the image is not embedded.
39
- #
40
- # When this method is called, the cursor is positioned at start of where this
41
- # group of fragments will be written (offset by the leading padding).
42
- #
43
- # This method is called each time the set of fragments overflow to another
44
- # page, so it's necessary to short-circuit if that case is detected.
45
- def arrange_images fragments
46
- doc = @document
47
- return if (raw_image_fragments = fragments.select {|f| (f.key? :image_path) && !(f.key? :image_obj) }).empty?
48
- scratch = doc.scratch?
49
- available_w = doc.bounds.width
50
- #available_h = doc.bounds.height
51
- # NOTE try to fit image within bounds if cursor is within 1% of top of page
52
- # QUESTION are we considering the right boundaries here?
53
- available_h ||= (doc.cursor / (available_h = doc.bounds.height) >= 0.99 ? doc.cursor : available_h)
54
- raw_image_fragments.each do |fragment|
55
- drop = scratch
56
- begin
57
- image_path = fragment[:image_path]
58
-
59
- # NOTE only attempt to convert an unresolved (i.e., String) value
60
- if ::String === (image_w = fragment[:image_width])
61
- image_w = [available_w, (image_w.end_with? '%') ? (image_w.to_f / 100 * available_w) : image_w.to_f].min
62
- end
63
-
64
- # TODO make helper method to calculate width and height of image
65
- if fragment[:image_format] == 'svg'
66
- svg_obj = ::Prawn::SVG::Interface.new ::File.read(image_path), doc,
67
- at: doc.bounds.top_left,
68
- width: image_w,
69
- fallback_font_name: doc.default_svg_font,
70
- enable_web_requests: doc.allow_uri_read,
71
- enable_file_requests_with_root: (::File.dirname image_path)
72
- svg_size = image_w ? svg_obj.document.sizing :
73
- # NOTE convert intrinsic dimensions to points; constrain to content width
74
- (svg_obj.resize width: [(to_pt svg_obj.document.sizing.output_width, :px), available_w].min)
75
- # NOTE the best we can do is make the image fit within full height of bounds
76
- if (image_h = svg_size.output_height) > available_h
77
- image_w = (svg_size = svg_obj.resize height: (image_h = available_h)).output_width
78
- else
79
- image_w = svg_size.output_width
80
- end
81
- fragment[:image_obj] = svg_obj
82
- else
83
- # TODO cache image info based on path (Prawn caches based on SHA1 of content)
84
- # NOTE image_obj is constrained to image_width by renderer
85
- image_obj, image_info = ::File.open(image_path, 'rb') {|fd| doc.build_image_object fd }
86
- if image_w
87
- if image_w == image_info.width
88
- image_h = image_info.height.to_f
89
- else
90
- image_h = image_w * (image_info.height.fdiv image_info.width)
91
- end
92
- else
93
- # NOTE convert intrinsic dimensions to points; constrain to content width
94
- if (image_w = to_pt image_info.width, :px) > available_w
95
- image_h = (image_w = available_w) * (image_info.height.fdiv image_info.width)
96
- else
97
- image_h = to_pt image_info.height, :px
98
- end
99
- end
100
- # NOTE the best we can do is make the image fit within full height of bounds
101
- image_w = (image_h = available_h) * (image_info.width.fdiv image_info.height) if image_h > available_h
102
- fragment[:image_obj] = image_obj
103
- fragment[:image_info] = image_info
104
- end
105
-
106
- spacer_w = nil
107
- doc.fragment_font fragment do
108
- # NOTE if image height exceeds line height by more than 1.5x, increase the line height
109
- # FIXME we could really use a nicer API from Prawn here; this is an ugly hack
110
- if (f_height = image_h) > (line_font = doc.font).height * 1.5
111
- # align with descender (equivalent to vertical-align: bottom in CSS)
112
- fragment[:ascender] = f_height - (fragment[:descender] = line_font.descender)
113
- doc.font_size(fragment[:size] = f_height * (doc.font_size / line_font.height))
114
- # align with baseline (roughly equivalent to vertical-align: baseline in CSS)
115
- #fragment[:ascender] = f_height
116
- #fragment[:descender] = 0
117
- #doc.font_size(fragment[:size] = (f_height + line_font.descender) * (doc.font_size / line_font.height))
118
- fragment[:line_height_increased] = true
119
- end
120
-
121
- unless (spacer_w = PlaceholderWidthCache[f_info = doc.font_info])
122
- spacer_w = PlaceholderWidthCache[f_info] = doc.width_of ImagePlaceholderChar
123
- end
124
- end
125
-
126
- # NOTE make room for image by repeating image placeholder character, using character spacing to fine-tune
127
- # NOTE image_width is constrained to available_w, so we don't have to check for overflow
128
- spacer_cnt, remainder = image_w.divmod spacer_w
129
- if spacer_cnt > 0
130
- fragment[:text] = ImagePlaceholderChar * spacer_cnt
131
- fragment[:character_spacing] = remainder.fdiv spacer_cnt if remainder > 0
132
- else
133
- fragment[:text] = ImagePlaceholderChar
134
- fragment[:character_spacing] = -(spacer_w - remainder)
135
- end
136
-
137
- # FIXME we could use a nicer API from Prawn here that lets us reserve a fragment width without text
138
- #fragment[:image_width] = fragment[:width] = image_w
139
- fragment[:image_width] = image_w
140
- fragment[:image_height] = image_h
141
- rescue
142
- logger.warn %(could not embed image: #{image_path}; #{$!.message})
143
- drop = true # delegate to cleanup logic in ensure block
144
- ensure
145
- # NOTE skip rendering image in scratch document or if image can't be loaded
146
- if drop
147
- fragment.delete :callback
148
- fragment.delete :image_info
149
- # NOTE retain key to indicate we've visited fragment already
150
- fragment[:image_obj] = nil
151
- # NOTE in main document, temporary image path is unlinked by renderer
152
- image_path.unlink if TemporaryPath === image_path && image_path.exist?
153
- end
154
- end
155
- end
156
- end
157
- end
158
-
159
- ::Prawn::Text::Formatted::Box.prepend InlineImageArranger
160
- end