asciidoctor-pdf 1.5.0.rc.1 → 1.5.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +10 -0
- data/README.adoc +88 -17
- data/data/themes/default-theme.yml +18 -22
- data/docs/theming-guide.adoc +12 -2
- data/lib/asciidoctor/pdf/converter.rb +36 -34
- data/lib/asciidoctor/pdf/ext/pdf-core/page.rb +3 -0
- data/lib/asciidoctor/pdf/ext/prawn.rb +1 -0
- data/lib/asciidoctor/pdf/ext/prawn/extensions.rb +1 -1
- data/lib/asciidoctor/pdf/ext/prawn/font_metric_cache.rb +9 -0
- data/lib/asciidoctor/pdf/formatted_text/inline_image_renderer.rb +6 -1
- data/lib/asciidoctor/pdf/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7290367ccc4d34f5fe1c5668c08de5a84e49af2d605b2ff30586620ab0eb6b58
|
4
|
+
data.tar.gz: '0920410efe9b0f47ad3dd5ae10626e251898782e190d2e73cb232d4a46bf15f5'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 411e2a27ea226772b264c9686a163dc2f5b932f160182df11df9bef3b3eac2424e50c96287539a21d3a646ad8cc9ad29964e3c11d7305d045a74671cc33024b8
|
7
|
+
data.tar.gz: 227a016304d3fa406e4e1ae5a23ee5be0152d7bfacb94435a96d6735256bb4a100b853f1bae26489c74c9fb4648ff1ba191273594c657124a7188ae773c3618e
|
data/CHANGELOG.adoc
CHANGED
@@ -5,6 +5,16 @@
|
|
5
5
|
This document provides a high-level view of the changes to the {project-name} by release.
|
6
6
|
For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.
|
7
7
|
|
8
|
+
== 1.5.0.rc.2 (2020-01-09) - @mojavelinux
|
9
|
+
|
10
|
+
* patch Prawn to fix incompatibilty with Ruby 2.7 (to fix text wrapping)
|
11
|
+
* fix crash when assigning font style to header cell in table body (#1468)
|
12
|
+
* fix parsing of array value of pdf-page-margin attribute (#1475)
|
13
|
+
* fix warning when reading data from a remote URL when running with Ruby 2.7 (#1477)
|
14
|
+
* pass SVG warnings to logger (#1479)
|
15
|
+
* compress streams if the compress attribute is set on the document (#1471)
|
16
|
+
* don't set heading-font-family in default theme so it inherits from base
|
17
|
+
|
8
18
|
== 1.5.0.rc.1 (2020-01-06) - @mojavelinux
|
9
19
|
|
10
20
|
* support data URI for SVG image (#1423)
|
data/README.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Asciidoctor PDF: A native PDF converter for AsciiDoc
|
2
2
|
Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>
|
3
|
-
v1.5.0.rc.
|
3
|
+
v1.5.0.rc.2, 2020-01-09
|
4
4
|
// Settings:
|
5
5
|
:experimental:
|
6
6
|
:idprefix:
|
@@ -23,7 +23,7 @@ endif::[]
|
|
23
23
|
:project-name: Asciidoctor PDF
|
24
24
|
:project-handle: asciidoctor-pdf
|
25
25
|
// Variables:
|
26
|
-
:release-version: 1.5.0.rc.
|
26
|
+
:release-version: 1.5.0.rc.2
|
27
27
|
// URIs:
|
28
28
|
:url-asciidoctor: http://asciidoctor.org
|
29
29
|
:url-gem: http://rubygems.org/gems/asciidoctor-pdf
|
@@ -295,27 +295,89 @@ For example, to configure Rouge to use the built-in monokai theme, run Asciidoct
|
|
295
295
|
It's possible to develop your own theme for Rouge.
|
296
296
|
Refer to the <<docs/theming-guide.adoc#,Asciidoctor PDF Theme Guide>> for details.
|
297
297
|
|
298
|
-
|
298
|
+
== Support for Non-Latin Languages
|
299
299
|
|
300
300
|
Asciidoctor can process the full range of characters in the UTF-8 character set.
|
301
|
-
That means you can write your document in any language, save the file with UTF-8 encoding, and expect Asciidoctor to convert the text properly.
|
302
|
-
|
303
|
-
|
301
|
+
That means you can write your document in any language, save the file with UTF-8 encoding (_that's important!_), and expect Asciidoctor to convert the text properly.
|
302
|
+
But you still need a font that provides the glyphs for those characters.
|
303
|
+
|
304
|
+
When converting a document with Asciidoctor PDF, you may notice that some of the glyphs for certain languages, such as Chinese, are missing from the PDF.
|
305
|
+
PDF is a "`bring your own font`" kind of system.
|
306
|
+
In other words, the font you provide must provide glyphs for all the characters used.
|
307
|
+
There's no one font that supports all the world's languages (though some, like Noto Serif, certainly come close).
|
308
|
+
Even if there were such a font, bundling that font with the main gem would make it enormous.
|
309
|
+
It would also severely limit the style choices in the default theme, which targets Latin-based languages.
|
310
|
+
Therefore, we're taking the strategy of creating separate dedicated theme gems that target each language family, such as CJK.
|
311
|
+
Read on to find out how to use these themes.
|
312
|
+
|
313
|
+
Asciidoctor PDF provides a built-in theme that provides a broad range of characters in the CJK charsets, so you can start with that theme:
|
304
314
|
|
305
|
-
|
306
|
-
|
315
|
+
$ asciidoctor-pdf -a scripts=cjk -a pdf-theme=default-with-fallback-font document.adoc
|
316
|
+
|
317
|
+
Notice the `-a scripts=cjk` option.
|
318
|
+
That's important.
|
319
|
+
It tells the converter to insert break opportunities between CJK characters so that the line wraps properly when mixing English and a CJK language like Japanese.
|
320
|
+
|
321
|
+
If the built-in theme with the fallback font doesn't go far enough, you'll need to use a theme that is optimized for CJK text.
|
307
322
|
You can get such a theme by installing the `asciidoctor-pdf-cjk-kai_gen_gothic` gem.
|
308
|
-
|
323
|
+
The https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic[asciidoctor-pdf-cjk-kai_gen_gothic] project provides themes optimized for CJK languages based on the kai_gen_gothic font.
|
324
|
+
See the https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic[asciidoctor-pdf-cjk-kai_gen_gothic] project README for detailed setup instructions.
|
309
325
|
|
310
|
-
|
311
|
-
|
312
|
-
There's no one font that supports all the worlds languages (though some, like Noto Serif, certainly come close).
|
313
|
-
Even if there were such a font, bundling that font with the main gem would make the package enormous.
|
314
|
-
It would also severely limit the style choices in the default theme, which targets Latin-based languages.
|
326
|
+
Once you have that gem installed (and the fonts), you need to tell Asciidoctor PDF to use one of the themes.
|
327
|
+
If you're converting a document that is primarily written in Japanese, you'd run Asciidoctor PDF as follows:
|
315
328
|
|
316
|
-
|
317
|
-
|
318
|
-
|
329
|
+
asciidoctor-pdf -r asciidoctor-pdf-cjk-kai_gen_gothic -a pdf-theme=KaiGenGothicJP document.adoc
|
330
|
+
|
331
|
+
You also have to option of creating your own theme gem that uses fonts of your choice.
|
332
|
+
For example, if you want to use the `asciidoctor-pdf-cjk-kai_gen_gothic` gem to fetch fonts, but then use them in your own theme, here's how you'd do it.
|
333
|
+
|
334
|
+
. Install the `asciidoctor-pdf-cjk-kai_gen_gothic` gem:
|
335
|
+
|
336
|
+
$ gem install asciidoctor-pdf-cjk-kai_gen_gothic
|
337
|
+
|
338
|
+
. Download / install the fonts:
|
339
|
+
|
340
|
+
$ asciidoctor-pdf-cjk-kai_gen_gothic-install
|
341
|
+
|
342
|
+
. Create a theme that extends the default theme:
|
343
|
+
+
|
344
|
+
[source,yml]
|
345
|
+
----
|
346
|
+
extends: default
|
347
|
+
font:
|
348
|
+
catalog:
|
349
|
+
KaiGen Gothic JP:
|
350
|
+
normal: KaiGenGothicJP-Regular.ttf
|
351
|
+
bold: KaiGenGothicJP-Bold.ttf
|
352
|
+
italic: KaiGenGothicJP-Regular-Italic.ttf
|
353
|
+
bold_italic: KaiGenGothicJP-Bold-Italic.ttf
|
354
|
+
M+ 1mn:
|
355
|
+
normal: GEM_FONTS_DIR/mplus1mn-regular-subset.ttf
|
356
|
+
bold: GEM_FONTS_DIR/mplus1mn-bold-subset.ttf
|
357
|
+
italic: GEM_FONTS_DIR/mplus1mn-italic-subset.ttf
|
358
|
+
bold_italic: GEM_FONTS_DIR/mplus1mn-bold_italic-subset.ttf
|
359
|
+
fallbacks:
|
360
|
+
- KaiGen Gothic JP
|
361
|
+
base:
|
362
|
+
font-family: KaiGen Gothic JP
|
363
|
+
heading:
|
364
|
+
font-family: $base-font-family
|
365
|
+
abstract:
|
366
|
+
title:
|
367
|
+
font-family: $heading-font-family
|
368
|
+
sidebar:
|
369
|
+
title:
|
370
|
+
font-family: $heading-font-family
|
371
|
+
----
|
372
|
+
|
373
|
+
. Load your theme when running Asciidoctor PDF:
|
374
|
+
|
375
|
+
$ asciidoctor-pdf -a scripts=cjk -a pdf-theme=./jp-theme.yml -a pdf-fontsdir=`ruby -r asciidoctor-pdf-cjk-kai_gen_gothic -e "print File.expand_path '../fonts', (Gem.datadir 'asciidoctor-pdf-cjk-kai_gen_gothic')"` document.adoc
|
376
|
+
|
377
|
+
The `-a pdf-fontsdir` option is important to tell Asciidoctor PDF where to find your custom fonts.
|
378
|
+
|
379
|
+
Rather than using the installer from the `asciidoctor-pdf-cjk-kai_gen_gothic` gem, you can download fonts whatever way you choose.
|
380
|
+
When using your own fonts, be sure to consult the <<docs/theming-guide.adoc#preparing-a-custom-font,Preparing a Custom Font>> section of the theming guide to find recommended modifications.
|
319
381
|
|
320
382
|
== Font-Based Icons
|
321
383
|
|
@@ -937,6 +999,15 @@ However, you could use an extension, such as a TreeProcessor, to automatically m
|
|
937
999
|
|
938
1000
|
== Optimizing the Generated PDF
|
939
1001
|
|
1002
|
+
By default, Asciidoctor PDF does not optimize the output document or even compress the streams.
|
1003
|
+
The simplest way to reduce the size of the file is to enable stream compression (using the FlateDecode method).
|
1004
|
+
You can enable this feature by setting the `compress` attribute on the document:
|
1005
|
+
|
1006
|
+
$ asciidoctor-pdf -a compress document.adoc
|
1007
|
+
|
1008
|
+
For more thorough optimzation, you can use either the built-in `asciidoctor-pdf-optimize` script or hexapdf.
|
1009
|
+
Read on to learn how.
|
1010
|
+
|
940
1011
|
=== asciidoctor-pdf-optimize
|
941
1012
|
|
942
1013
|
{project-name} also provides a bin script that uses GhostScript to optimize and compress the generated PDF (with minimal impact on quality).
|
@@ -13,7 +13,7 @@ font:
|
|
13
13
|
italic: mplus1mn-italic-subset.ttf
|
14
14
|
bold_italic: mplus1mn-bold_italic-subset.ttf
|
15
15
|
page:
|
16
|
-
background_color:
|
16
|
+
background_color: FFFFFF
|
17
17
|
layout: portrait
|
18
18
|
initial_zoom: FitH
|
19
19
|
margin: [0.5in, 0.67in, 0.67in, 0.67in]
|
@@ -49,7 +49,7 @@ base:
|
|
49
49
|
font_size_small: round($base_font_size * 0.85)
|
50
50
|
font_size_min: $base_font_size * 0.75
|
51
51
|
font_style: normal
|
52
|
-
border_color:
|
52
|
+
border_color: EEEEEE
|
53
53
|
border_radius: 4
|
54
54
|
border_width: 0.5
|
55
55
|
role:
|
@@ -72,32 +72,30 @@ horizontal_rhythm: $base_line_height_length
|
|
72
72
|
# QUESTION should vertical_spacing be block_spacing instead?
|
73
73
|
vertical_spacing: $vertical_rhythm
|
74
74
|
link:
|
75
|
-
font_color:
|
75
|
+
font_color: 428BCA
|
76
76
|
# literal is currently used for inline monospaced in prose and table cells
|
77
77
|
literal:
|
78
|
-
font_color:
|
78
|
+
font_color: B12146
|
79
79
|
font_family: M+ 1mn
|
80
80
|
button:
|
81
81
|
content: "[\u2009%s\u2009]"
|
82
82
|
font_style: bold
|
83
83
|
key:
|
84
|
-
background_color:
|
85
|
-
border_color:
|
84
|
+
background_color: F5F5F5
|
85
|
+
border_color: CCCCCC
|
86
86
|
border_offset: 2
|
87
87
|
border_radius: 2
|
88
88
|
border_width: 0.5
|
89
89
|
font_family: $literal_font_family
|
90
90
|
separator: "\u202f+\u202f"
|
91
91
|
mark:
|
92
|
-
background_color:
|
92
|
+
background_color: FFFF00
|
93
93
|
border_offset: 1
|
94
94
|
menu:
|
95
95
|
caret_content: " <font size=\"1.15em\"><color rgb=\"b12146\">\u203a</color></font> "
|
96
96
|
heading:
|
97
97
|
align: left
|
98
|
-
#font_color: 181818
|
99
98
|
font_color: $base_font_color
|
100
|
-
font_family: $base_font_family
|
101
99
|
font_style: bold
|
102
100
|
# h1 is used for part titles (book doctype) or the doctitle (article doctype)
|
103
101
|
h1_font_size: floor($base_font_size * 2.6)
|
@@ -147,7 +145,7 @@ lead:
|
|
147
145
|
font_size: $base_font_size_large
|
148
146
|
line_height: 1.4
|
149
147
|
abstract:
|
150
|
-
font_color:
|
148
|
+
font_color: 5C6266
|
151
149
|
font_size: $lead_font_size
|
152
150
|
line_height: $lead_line_height
|
153
151
|
font_style: italic
|
@@ -155,7 +153,6 @@ abstract:
|
|
155
153
|
title:
|
156
154
|
align: center
|
157
155
|
font_color: $heading_font_color
|
158
|
-
font_family: $heading_font_family
|
159
156
|
font_size: $heading_h4_font_size
|
160
157
|
font_style: $heading_font_style
|
161
158
|
admonition:
|
@@ -196,8 +193,8 @@ code:
|
|
196
193
|
line_height: 1.25
|
197
194
|
# line_gap is an experimental property to control how a background color is applied to an inline block element
|
198
195
|
line_gap: 3.8
|
199
|
-
background_color:
|
200
|
-
border_color:
|
196
|
+
background_color: F5F5F5
|
197
|
+
border_color: CCCCCC
|
201
198
|
border_radius: $base_border_radius
|
202
199
|
border_width: 0.75
|
203
200
|
conum:
|
@@ -210,7 +207,7 @@ example:
|
|
210
207
|
border_color: $base_border_color
|
211
208
|
border_radius: $base_border_radius
|
212
209
|
border_width: 0.75
|
213
|
-
background_color:
|
210
|
+
background_color: FFFFFF
|
214
211
|
# FIXME reenable padding bottom once margin collapsing is implemented
|
215
212
|
padding: [$vertical_rhythm, $horizontal_rhythm, 0, $horizontal_rhythm]
|
216
213
|
image:
|
@@ -219,8 +216,8 @@ prose:
|
|
219
216
|
margin_top: $block_margin_top
|
220
217
|
margin_bottom: $block_margin_bottom
|
221
218
|
sidebar:
|
222
|
-
background_color:
|
223
|
-
border_color:
|
219
|
+
background_color: EEEEEE
|
220
|
+
border_color: E1E1E1
|
224
221
|
border_radius: $base_border_radius
|
225
222
|
border_width: $base_border_width
|
226
223
|
# FIXME reenable padding bottom once margin collapsing is implemented
|
@@ -228,7 +225,6 @@ sidebar:
|
|
228
225
|
title:
|
229
226
|
align: center
|
230
227
|
font_color: $heading_font_color
|
231
|
-
font_family: $heading_font_family
|
232
228
|
font_size: $heading_h4_font_size
|
233
229
|
font_style: $heading_font_style
|
234
230
|
thematic_break:
|
@@ -248,22 +244,22 @@ outline_list:
|
|
248
244
|
item_spacing: $vertical_rhythm / 2
|
249
245
|
table:
|
250
246
|
background_color: $page_background_color
|
251
|
-
border_color:
|
247
|
+
border_color: DDDDDD
|
252
248
|
border_width: $base_border_width
|
253
249
|
cell_padding: 3
|
254
250
|
head:
|
255
251
|
font_style: bold
|
256
252
|
border_bottom_width: $base_border_width * 2.5
|
257
253
|
body:
|
258
|
-
stripe_background_color:
|
254
|
+
stripe_background_color: F9F9F9
|
259
255
|
foot:
|
260
|
-
background_color:
|
256
|
+
background_color: F0F0F0
|
261
257
|
toc:
|
262
258
|
indent: $horizontal_rhythm
|
263
259
|
line_height: 1.4
|
264
260
|
dot_leader:
|
265
261
|
#content: ". "
|
266
|
-
font_color:
|
262
|
+
font_color: A9A9A9
|
267
263
|
#levels: 2 3
|
268
264
|
footnotes:
|
269
265
|
font_size: round($base_font_size * 0.75)
|
@@ -275,7 +271,7 @@ header:
|
|
275
271
|
footer:
|
276
272
|
font_size: $base_font_size_small
|
277
273
|
# NOTE if background_color is set, background and border will span width of page
|
278
|
-
border_color:
|
274
|
+
border_color: DDDDDD
|
279
275
|
border_width: 0.25
|
280
276
|
height: $base_line_height_length * 2.5
|
281
277
|
line_height: 1
|
data/docs/theming-guide.adoc
CHANGED
@@ -795,7 +795,7 @@ CAUTION: You must declare all four variants.
|
|
795
795
|
If you're missing the font file for one of the variants, configure it to use the same font file as the normal variant.
|
796
796
|
|
797
797
|
You can use the key that you assign to the font in the font catalog anywhere the `font-family` property is accepted in the theme file.
|
798
|
-
For example, to use the Roboto font for all headings, use:
|
798
|
+
For example, to use the Roboto font for all headings (section titles and discrete headings), use:
|
799
799
|
|
800
800
|
[source,yaml]
|
801
801
|
----
|
@@ -1522,7 +1522,7 @@ The keys in this category control the style of most headings, including part tit
|
|
1522
1522
|
|
1523
1523
|
|font-family
|
1524
1524
|
|<<fonts,Font family name>> +
|
1525
|
-
(default:
|
1525
|
+
(default: _inherit_)
|
1526
1526
|
|heading:
|
1527
1527
|
font-family: Noto Serif
|
1528
1528
|
|
@@ -3826,6 +3826,12 @@ The keys in this category control the arrangement and style of tables and table
|
|
3826
3826
|
|table:
|
3827
3827
|
border-width: 0.5
|
3828
3828
|
|
3829
|
+
|caption-align
|
3830
|
+
|<<text-alignments,Text alignment>> {vbar} inherit +
|
3831
|
+
(default: $caption-align)
|
3832
|
+
|table:
|
3833
|
+
caption-align: inherit
|
3834
|
+
|
3829
3835
|
|caption-side
|
3830
3836
|
|top {vbar} bottom +
|
3831
3837
|
(default: top)
|
@@ -4896,6 +4902,10 @@ These settings override equivalent keys defined in the theme file, where applica
|
|
4896
4902
|
|screen {vbar} print {vbar} prepress
|
4897
4903
|
|:media: prepress
|
4898
4904
|
|
4905
|
+
|compress
|
4906
|
+
|flag (default: _not set_)
|
4907
|
+
|:compress:
|
4908
|
+
|
4899
4909
|
|optimize
|
4900
4910
|
|screen {vbar} ebook {vbar} printer {vbar} prepress {vbar} default (default: default)
|
4901
4911
|
|:optimize: prepress
|
@@ -406,7 +406,7 @@ module Asciidoctor
|
|
406
406
|
if page_margin.empty?
|
407
407
|
page_margin = nil
|
408
408
|
elsif (page_margin.start_with? '[') && (page_margin.end_with? ']')
|
409
|
-
if (page_margin = (page_margin.slice 1, page_margin.
|
409
|
+
if (page_margin = (page_margin.slice 1, page_margin.length - 2).rstrip).empty?
|
410
410
|
page_margin = [0]
|
411
411
|
else
|
412
412
|
if (page_margin = page_margin.split ',', -1).length > 4
|
@@ -468,6 +468,7 @@ module Asciidoctor
|
|
468
468
|
page_size: (page_size || 'A4'),
|
469
469
|
page_layout: (page_layout || :portrait),
|
470
470
|
info: (build_pdf_info doc),
|
471
|
+
compress: (doc.attr? 'compress'),
|
471
472
|
skip_page_creation: true,
|
472
473
|
text_formatter: (FormattedText::Formatter.new theme: theme),
|
473
474
|
}
|
@@ -815,6 +816,9 @@ module Asciidoctor
|
|
815
816
|
icon_width = svg_size.output_width
|
816
817
|
end
|
817
818
|
svg_obj.draw
|
819
|
+
svg_obj.document.warnings.each do |icon_warning|
|
820
|
+
logger.warn %(problem encountered in image: #{icon_path}; #{icon_warning})
|
821
|
+
end
|
818
822
|
rescue
|
819
823
|
logger.warn %(could not embed admonition icon: #{icon_path}; #{$!.message})
|
820
824
|
end
|
@@ -1419,13 +1423,8 @@ module Asciidoctor
|
|
1419
1423
|
# TODO: add `to_pt page_width` method to ViewportWidth type
|
1420
1424
|
width = (width.to_f / 100) * page_width if ViewportWidth === width
|
1421
1425
|
|
1422
|
-
if
|
1423
|
-
|
1424
|
-
caption_max_w = width && @theme.image_caption_max_width == 'fit-content' ? width : nil
|
1425
|
-
caption_h = layout_caption node, category: :image, side: :bottom, block_align: alignment, max_width: caption_max_w, dry_run: true
|
1426
|
-
else
|
1427
|
-
caption_h = 0
|
1428
|
-
end
|
1426
|
+
# NOTE: if width is not set explicitly and max-width is fit-content, caption height may not be accurate
|
1427
|
+
caption_h = node.title? ? (layout_caption node, category: :image, side: :bottom, block_align: alignment, block_width: width, max_width: @theme.image_caption_max_width, dry_run: true) : 0
|
1429
1428
|
|
1430
1429
|
align_to_page = node.option? 'align-to-page'
|
1431
1430
|
|
@@ -1472,6 +1471,9 @@ module Asciidoctor
|
|
1472
1471
|
# NOTE: prawn-svg 0.24.0, 0.25.0, & 0.25.1 didn't restore font after call to draw (see mogest/prawn-svg#80)
|
1473
1472
|
# NOTE: cursor advances automatically
|
1474
1473
|
svg_obj.draw
|
1474
|
+
svg_obj.document.warnings.each do |img_warning|
|
1475
|
+
logger.warn %(problem encountered in image: #{image_path}; #{img_warning})
|
1476
|
+
end
|
1475
1477
|
draw_image_border image_cursor, rendered_w, rendered_h, alignment unless node.role? && (node.has_role? 'noborder')
|
1476
1478
|
if (link = node.attr 'link', nil, false)
|
1477
1479
|
add_link_to_image link, { width: rendered_w, height: rendered_h }, position: alignment, y: image_y
|
@@ -1509,10 +1511,7 @@ module Asciidoctor
|
|
1509
1511
|
move_down rendered_h if y == image_y
|
1510
1512
|
end
|
1511
1513
|
end
|
1512
|
-
if node.title?
|
1513
|
-
caption_max_w = @theme.image_caption_max_width == 'fit-content' ? rendered_w : nil
|
1514
|
-
layout_caption node, category: :image, side: :bottom, block_align: alignment, max_width: caption_max_w
|
1515
|
-
end
|
1514
|
+
layout_caption node, category: :image, side: :bottom, block_align: alignment, block_width: rendered_w, max_width: @theme.image_caption_max_width if node.title?
|
1516
1515
|
theme_margin :block, :bottom unless pinned
|
1517
1516
|
rescue
|
1518
1517
|
on_image_error :exception, node, target, (opts.merge message: %(could not embed image: #{image_path}; #{$!.message}#{::Prawn::Errors::UnsupportedImageType === $! ? '; install prawn-gmagick gem to add support' : ''}))
|
@@ -1586,7 +1585,7 @@ module Asciidoctor
|
|
1586
1585
|
else
|
1587
1586
|
::OpenURI
|
1588
1587
|
end
|
1589
|
-
poster =
|
1588
|
+
poster = ::OpenURI.open_uri %(http://vimeo.com/api/v2/video/#{video_id}.xml), 'r' do |f|
|
1590
1589
|
/<thumbnail_large>(.*?)<\/thumbnail_large>/ =~ f.read && $1
|
1591
1590
|
end
|
1592
1591
|
end
|
@@ -1954,7 +1953,7 @@ module Asciidoctor
|
|
1954
1953
|
text_color: @font_color,
|
1955
1954
|
font: header_cell_font_info[:family],
|
1956
1955
|
size: header_cell_font_info[:size],
|
1957
|
-
|
1956
|
+
font_style: header_cell_font_info[:style],
|
1958
1957
|
text_transform: @text_transform,
|
1959
1958
|
}
|
1960
1959
|
header_cell_line_metrics = calc_line_metrics theme.base_line_height
|
@@ -2099,7 +2098,7 @@ module Asciidoctor
|
|
2099
2098
|
end
|
2100
2099
|
|
2101
2100
|
caption_side = (theme.table_caption_side || :top).to_sym
|
2102
|
-
caption_max_width =
|
2101
|
+
caption_max_width = theme.table_caption_max_width || 'fit-content'
|
2103
2102
|
|
2104
2103
|
table_settings = {
|
2105
2104
|
header: table_header,
|
@@ -2134,8 +2133,7 @@ module Asciidoctor
|
|
2134
2133
|
table table_data, table_settings do
|
2135
2134
|
# NOTE: call width to capture resolved table width
|
2136
2135
|
table_width = width
|
2137
|
-
|
2138
|
-
@pdf.layout_table_caption node, alignment, caption_max_width if node.title? && caption_side == :top
|
2136
|
+
@pdf.layout_table_caption node, alignment, table_width, caption_max_width if node.title? && caption_side == :top
|
2139
2137
|
# NOTE align using padding instead of bounding_box as prawn-table does
|
2140
2138
|
# using a bounding_box across pages mangles the margin box of subsequent pages
|
2141
2139
|
if alignment != :left && table_width != (this_bounds = @pdf.bounds).width
|
@@ -2210,7 +2208,7 @@ module Asciidoctor
|
|
2210
2208
|
bounds.subtract_left_padding left_padding
|
2211
2209
|
bounds.subtract_right_padding right_padding if right_padding
|
2212
2210
|
end
|
2213
|
-
layout_table_caption node, alignment, caption_max_width, caption_side if node.title? && caption_side == :bottom
|
2211
|
+
layout_table_caption node, alignment, table_width, caption_max_width, caption_side if node.title? && caption_side == :bottom
|
2214
2212
|
theme_margin :block, :bottom
|
2215
2213
|
end
|
2216
2214
|
|
@@ -2294,9 +2292,10 @@ module Asciidoctor
|
|
2294
2292
|
end
|
2295
2293
|
text = %(#{text}, #{pagenums.join ', '})
|
2296
2294
|
end
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2295
|
+
subterm_indent = @theme.description_list_description_indent
|
2296
|
+
layout_prose text, align: :left, margin: 0, normalize_line_height: true, hanging_indent: subterm_indent * 2
|
2297
|
+
indent subterm_indent do
|
2298
|
+
term.subterms.each do |subterm|
|
2300
2299
|
convert_index_list_item subterm
|
2301
2300
|
end
|
2302
2301
|
end unless term.leaf?
|
@@ -2873,17 +2872,20 @@ module Asciidoctor
|
|
2873
2872
|
else
|
2874
2873
|
align = @base_align.to_sym
|
2875
2874
|
end
|
2876
|
-
|
2877
|
-
|
2878
|
-
|
2879
|
-
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
2883
|
-
|
2875
|
+
indent_by = [0, 0]
|
2876
|
+
if block_align
|
2877
|
+
block_width = opts.delete :block_width
|
2878
|
+
if (max_width = opts.delete :max_width) && max_width != 'none' &&
|
2879
|
+
(max_width != 'fit-content' || (max_width = block_width)) && (remainder = bounds.width - max_width) > 0
|
2880
|
+
case block_align
|
2881
|
+
when :right
|
2882
|
+
indent_by = [remainder, 0]
|
2883
|
+
when :center
|
2884
|
+
indent_by = [(side_margin = remainder * 0.5), side_margin]
|
2885
|
+
else # :left
|
2886
|
+
indent_by = [0, remainder]
|
2887
|
+
end
|
2884
2888
|
end
|
2885
|
-
else
|
2886
|
-
indent_by = [0, 0]
|
2887
2889
|
end
|
2888
2890
|
theme_font :caption do
|
2889
2891
|
theme_font category_caption do
|
@@ -2920,8 +2922,8 @@ module Asciidoctor
|
|
2920
2922
|
end
|
2921
2923
|
|
2922
2924
|
# Render the caption for a table and return the height of the rendered content
|
2923
|
-
def layout_table_caption node, table_alignment = :left, max_width = nil, side = :top
|
2924
|
-
layout_caption node, category: :table, side: side, block_align: table_alignment, max_width: max_width
|
2925
|
+
def layout_table_caption node, table_alignment = :left, table_width = nil, max_width = nil, side = :top
|
2926
|
+
layout_caption node, category: :table, side: side, block_align: table_alignment, block_width: table_width, max_width: max_width
|
2925
2927
|
end
|
2926
2928
|
|
2927
2929
|
def allocate_toc doc, toc_num_levels, toc_start_y, use_title_page
|
@@ -4031,7 +4033,7 @@ module Asciidoctor
|
|
4031
4033
|
tmp_image = ::Tempfile.create ['image-', image_format && %(.#{image_format})]
|
4032
4034
|
tmp_image.binmode if (binary = image_format != 'svg')
|
4033
4035
|
begin
|
4034
|
-
|
4036
|
+
::OpenURI.open_uri(image_path, (binary ? 'rb' : 'r')) {|fd| tmp_image.write fd.read }
|
4035
4037
|
tmp_image.path.extend TemporaryPath
|
4036
4038
|
rescue
|
4037
4039
|
logger.warn %(could not retrieve remote image: #{image_path}; #{$!.message}) unless scratch?
|
@@ -18,6 +18,9 @@ class PDF::Core::Page
|
|
18
18
|
document.open_graphics_state
|
19
19
|
end unless method_defined? :new_content_stream
|
20
20
|
|
21
|
+
# NOTE alias method to avoid warning if another gem replaces this method
|
22
|
+
alias __new_content_stream new_content_stream
|
23
|
+
|
21
24
|
# Restore the imported_page? method from PDF::Core::Page
|
22
25
|
#
|
23
26
|
# see https://github.com/prawnpdf/pdf-core/commit/0e326a838e142061be8e062168190fae6b3b1dcf
|
@@ -33,7 +33,12 @@ module Asciidoctor::PDF::FormattedText
|
|
33
33
|
(image_obj = data[:image_obj]).options[:at] = [image_left, image_top]
|
34
34
|
# NOTE prawn-svg messes with the cursor; use float to workaround
|
35
35
|
# NOTE prawn-svg 0.24.0, 0.25.0, & 0.25.1 didn't restore font after call to draw (see mogest/prawn-svg#80)
|
36
|
-
pdf.float
|
36
|
+
pdf.float do
|
37
|
+
image_obj.draw
|
38
|
+
image_obj.document.warnings.each do |img_warning|
|
39
|
+
pdf.logger.warn %(problem encountered in image: #{data[:image_path]}; #{img_warning})
|
40
|
+
end
|
41
|
+
end
|
37
42
|
else
|
38
43
|
pdf.embed_image data[:image_obj], data[:image_info], at: [image_left, image_top], width: data[:image_width], height: data[:image_height]
|
39
44
|
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.rc.
|
4
|
+
version: 1.5.0.rc.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: 2020-01-
|
12
|
+
date: 2020-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: asciidoctor
|
@@ -393,6 +393,7 @@ files:
|
|
393
393
|
- lib/asciidoctor/pdf/ext/prawn/coderay_encoder.rb
|
394
394
|
- lib/asciidoctor/pdf/ext/prawn/extensions.rb
|
395
395
|
- lib/asciidoctor/pdf/ext/prawn/font/afm.rb
|
396
|
+
- lib/asciidoctor/pdf/ext/prawn/font_metric_cache.rb
|
396
397
|
- lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb
|
397
398
|
- lib/asciidoctor/pdf/ext/prawn/formatted_text/fragment.rb
|
398
399
|
- lib/asciidoctor/pdf/ext/prawn/images.rb
|
@@ -445,7 +446,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
445
446
|
- !ruby/object:Gem::Version
|
446
447
|
version: 1.3.1
|
447
448
|
requirements: []
|
448
|
-
rubygems_version: 3.
|
449
|
+
rubygems_version: 3.1.2
|
449
450
|
signing_key:
|
450
451
|
specification_version: 4
|
451
452
|
summary: Converts AsciiDoc documents to PDF using Asciidoctor and Prawn
|