asciidoctor-pdf 1.5.0.alpha.13 → 1.5.0.alpha.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +131 -4
- data/Gemfile +8 -1
- data/README.adoc +199 -36
- data/Rakefile +1 -0
- data/asciidoctor-pdf.gemspec +4 -4
- data/data/themes/base-theme.yml +9 -2
- data/data/themes/default-theme.yml +34 -20
- data/docs/theming-guide.adoc +1147 -268
- data/lib/asciidoctor-pdf/asciidoctor_ext/image.rb +7 -1
- data/lib/asciidoctor-pdf/converter.rb +841 -409
- data/lib/asciidoctor-pdf/core_ext.rb +1 -0
- data/lib/asciidoctor-pdf/core_ext/numeric.rb +12 -8
- data/lib/asciidoctor-pdf/core_ext/object.rb +6 -0
- data/lib/asciidoctor-pdf/core_ext/string.rb +15 -0
- data/lib/asciidoctor-pdf/formatted_text/inline_destination_marker.rb +5 -0
- data/lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb +75 -28
- data/lib/asciidoctor-pdf/formatted_text/inline_image_renderer.rb +3 -2
- data/lib/asciidoctor-pdf/formatted_text/transform.rb +97 -89
- data/lib/asciidoctor-pdf/index_catalog.rb +119 -0
- data/lib/asciidoctor-pdf/measurements.rb +58 -0
- data/lib/asciidoctor-pdf/pdf-core_ext.rb +1 -0
- data/lib/asciidoctor-pdf/{pdf_core_ext → pdf-core_ext}/page.rb +3 -7
- data/lib/asciidoctor-pdf/pdfmark.rb +33 -0
- data/lib/asciidoctor-pdf/prawn-svg_ext.rb +4 -0
- data/lib/asciidoctor-pdf/prawn-svg_ext/interface.rb +10 -0
- data/lib/asciidoctor-pdf/prawn-table_ext.rb +3 -0
- data/lib/asciidoctor-pdf/prawn-table_ext/cell/asciidoc.rb +69 -0
- data/lib/asciidoctor-pdf/prawn-table_ext/cell/text.rb +12 -0
- data/lib/asciidoctor-pdf/prawn_ext/extensions.rb +89 -76
- data/lib/asciidoctor-pdf/prawn_ext/images.rb +0 -1
- data/lib/asciidoctor-pdf/roman_numeral.rb +1 -1
- data/lib/asciidoctor-pdf/rouge_ext/formatters/prawn.rb +51 -11
- data/lib/asciidoctor-pdf/rouge_ext/themes/pastie.rb +64 -59
- data/lib/asciidoctor-pdf/sanitizer.rb +53 -2
- data/lib/asciidoctor-pdf/theme_loader.rb +8 -21
- data/lib/asciidoctor-pdf/version.rb +1 -1
- metadata +19 -13
- data/docs/theme-schema.json +0 -114
- data/lib/asciidoctor-pdf/pdf_core_ext.rb +0 -2
- data/lib/asciidoctor-pdf/pdf_core_ext/pdf_object.rb +0 -25
- data/lib/asciidoctor-pdf/pdfmarks.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94832dc67ed7ce7dfc52ecd5245bcd47d1a13ad7
|
4
|
+
data.tar.gz: fe2c218069cc009756e83c8e8aacaa3d15b48a88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 881736c11065cddaf7cbef76d587016267605b6acb9c09a7f694f6a0c347e4aeec09e2ba151dd3528dbcd9198e8f4322c15956e7fa61c6e9c675756ec386aaa9
|
7
|
+
data.tar.gz: f37f79944645d1139fbd347761d028f80595f3f0a827b8cd9b65d8ef177929336882f93f1f2ea66a15a79a4ad3998117f9d9c0f8c4f8f3ecb5e5220e62cd03ff
|
data/CHANGELOG.adoc
CHANGED
@@ -5,12 +5,134 @@
|
|
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.alpha.14 (2017-02-05) - @mojavelinux
|
9
|
+
|
10
|
+
* add support for AsciiDoc table cells (including nested tables) (#6)
|
11
|
+
* patch text cell to remove cursor advancement
|
12
|
+
* make header cell in body inherit styles from table head (#239)
|
13
|
+
* don't crash if table is empty and cols are explicitly set (#610)
|
14
|
+
* fix vertical centering for cells in table head row
|
15
|
+
* implement converter for index (PR #386)
|
16
|
+
* record page number for index term when writing anchor (#639)
|
17
|
+
* support the underline and line-through roles on phrases (#339)
|
18
|
+
* allow printed URI to break at break opportunities (#563)
|
19
|
+
* don't drop subsequent images after inline image fails to load
|
20
|
+
* show alt text when image fails to embed (#693)
|
21
|
+
* don't crash if inline image is an unsupported format; issue warning instead (#587)
|
22
|
+
* always show image caption even if image fails to embed
|
23
|
+
* delegate to method to handle missing image
|
24
|
+
* permit use of gif image format if prawn-gmagick is available (#573)
|
25
|
+
* add support for image macros that have a data URI target (#318)
|
26
|
+
* don't crash if format of image in running content is unrecognized
|
27
|
+
* only fit image within bounds of running content if contain option is set
|
28
|
+
* document fit attribute for image in running content
|
29
|
+
* fix alignment for SVG image in running content
|
30
|
+
* keep block image with caption (#690)
|
31
|
+
* place destination for block image on same page as image
|
32
|
+
* set color space when block image occurs on page by itself (#688)
|
33
|
+
* resize SVG to fit page (#691)
|
34
|
+
* backport resize method from prawn-svg and use it
|
35
|
+
* disable system font scan in Prawn SVG
|
36
|
+
* use character spacing to fine-tune width of placeholder for inline image (#686)
|
37
|
+
* fix duplicate inline image rendering (@fap-) (#388)
|
38
|
+
* constrain inline image to width of bounds
|
39
|
+
* add support for pdfwidth to inline images (@fap-) (#620)
|
40
|
+
* honor pdfwidth attribute for image in running content (#625)
|
41
|
+
* add support for absolute measurement units to scaledwidth attribute (#674)
|
42
|
+
* resize inline SVG without an explicit width (#684)
|
43
|
+
* resize inline image to fit within content height (#700)
|
44
|
+
* calculate height of inline image correctly in table cell (#295)
|
45
|
+
* fix bug in calculation when image overflows page (#708)
|
46
|
+
* simplify calculation of rendered width and height of images
|
47
|
+
* add square brackets around alt text for inline image
|
48
|
+
* don't surround alt text of block image with non-breaking spaces
|
49
|
+
* specify width & height when embedding (inline) raster image to avoid recalc
|
50
|
+
* resize title logo image to keep on page (#714)
|
51
|
+
* don't leave blank page when importing PDF page (#614)
|
52
|
+
* fix running content dimensions (#616)
|
53
|
+
* introduce document attribute to control default text alignment (#396)
|
54
|
+
* allow setting a default columns spec for running content on both recto and verso pages; set if not defined
|
55
|
+
* show example of center column alignment in default theme
|
56
|
+
* map dynamic section-title attribute in running content to current section if page has no section (#709)
|
57
|
+
* assign dynamic part-title attribute for use in running content (#596)
|
58
|
+
* don't set dynamic chapter-title attribute in running content for preface unless doctype is book
|
59
|
+
* assign page number label to each page (#641)
|
60
|
+
* don't set dynamic page-number attribute in running content of pagenums is disabled
|
61
|
+
* allow toc title properties to be controlled by theme (#701)
|
62
|
+
* use correct number of dots when font style is applied to toc level (#621)
|
63
|
+
* allow theme to control which toc levels have dot leaders; default to 2-3 (#631)
|
64
|
+
* set font color of page number for parts in toc
|
65
|
+
* don't crash when toc dot leader is empty string
|
66
|
+
* list preface with title in table of contents (#732)
|
67
|
+
* allow theme to apply text decoration to link text (#567)
|
68
|
+
* allow page layout to be controlled from document (#565)
|
69
|
+
* don't crash if image in running content fails to embed (#728)
|
70
|
+
* treat abstract section as abstract block (#703)
|
71
|
+
* set example block background to white by default
|
72
|
+
* add support for background colors when highlighting code with Rouge
|
73
|
+
* add support underline style for token in Rouge theme (#665)
|
74
|
+
* drop background colors on strings in rouge pastie theme
|
75
|
+
* add support for image-based icons (#479) (@JBR69)
|
76
|
+
* preliminary support for vertical alignment of admonition icon/label
|
77
|
+
* allow side padding on admonition label to be controlled separately from admonition content
|
78
|
+
* add more control over vertical rule in admonition block (#601)
|
79
|
+
* allow theme to control font properties for admonition content (#592)
|
80
|
+
* only add lead role to first paragraph of preamble (#654)
|
81
|
+
* display poster image for video with link to video URI (#287)
|
82
|
+
* add link to audio file (#475)
|
83
|
+
* don't drop anchor within text that overruns page (#638)
|
84
|
+
* display title for abstract (#582)
|
85
|
+
* display title for open block (#577)
|
86
|
+
* display block title on quote and verse blocks (#416)
|
87
|
+
* don't draw border for quote/verse block on empty page or if border width is 0
|
88
|
+
* allow delimiter between author names on title page to be configured in theme
|
89
|
+
* coerce resolved value of content key in theme to String (#653)
|
90
|
+
* honor background color from Pygments theme
|
91
|
+
* set default inner/outer margins in base theme
|
92
|
+
* document missing glyph encoding warning in theming guide; minor rewording
|
93
|
+
* document how to configure fonts in SVG images (#739)
|
94
|
+
* document how to use Asciidoctor Mathematical to enable STEM support (#45)
|
95
|
+
* transform text containing multibyte characters (#363)
|
96
|
+
* document in theming guide how to transform unicode letters with Ruby < 2.4
|
97
|
+
* show unmodified text if text_transform is none (#584)
|
98
|
+
* make performance optimization to formatted text transform
|
99
|
+
* use reference_bounds instead of @margin_box to move past bottom
|
100
|
+
* handle negative bottom padding properly at page boundary
|
101
|
+
* use value of docdatetime & localdatetime attributes in PDF info (#590)
|
102
|
+
* use truncate_to_precision instead of round to truncate floats; map to native method in Ruby >= 2.4
|
103
|
+
* upgrade prawn-svg dependency to 0.26.x
|
104
|
+
* upgrade prawn-icon to 1.3.0
|
105
|
+
* document in the README how to use the autofit option on verbatim blocks
|
106
|
+
* clarify in README how inline image are sized
|
107
|
+
* clarify instructions in README about how to specify a page number range for printing
|
108
|
+
* document in theming guide how to define and apply a custom Rouge theme
|
109
|
+
* rename pdfmarks to pdfmarks; document pdfmark attribute in theming guide
|
110
|
+
* describe the quoted string value type in the theming guide
|
111
|
+
* add self-referencing anchor to each key prefix in theming guide
|
112
|
+
* document nonfacing option for sections (@jnerlich)
|
113
|
+
* fix documentation for toc_dot_leader_font_color in theming guide (@davidgamba)
|
114
|
+
* document that dot leader inherits font properties from toc category
|
115
|
+
* fill in missing defaults for keys in theming guide
|
116
|
+
* rewrite intro to Keys section in theming guide
|
117
|
+
* add keys for prose, menu, and conum categories to theming guide
|
118
|
+
* document outline_list_marker_font_color key in theming guide
|
119
|
+
* refactor measurement value helpers into module (#677)
|
120
|
+
* add reproducible flag to examples
|
121
|
+
* add inline ref and corresponding xref to chronicles example
|
122
|
+
* fix Ruby warnings
|
123
|
+
* update instructions and Gemfile config to use with Ruby 1.9.3
|
124
|
+
* configure build as the default rake task
|
125
|
+
|
126
|
+
{uri-repo}/issues?q=milestone%3Av1.5.0.alpha.14[issues resolved] |
|
127
|
+
{uri-repo}/releases/tag/v1.5.0.alpha.14[git tag]
|
128
|
+
|
8
129
|
== 1.5.0.alpha.13 (2016-09-19) - @mojavelinux
|
9
130
|
|
10
|
-
* Add support for
|
131
|
+
* Add support for mirror (recto/verso) margins and facing pages when media=prepress
|
11
132
|
* Add non-breaking hyphen glyph to built-in fonts so its intended behavior is honored (#462)
|
12
133
|
* Add page break before a book part (#329)
|
13
|
-
* Allow running (header/footer) content to be
|
134
|
+
* Allow running (header/footer) content to be arranged in columns (#449)
|
135
|
+
* Allow font properties to be set per element in running content (#454)
|
14
136
|
* Prevent the SVG from modifying the document font (#494)
|
15
137
|
* Implement decorative border for multipage quote and verse blocks (#270, #557, #558)
|
16
138
|
* Encode anchors in hex that contain characters outside of ASCII range (#481, #301)
|
@@ -22,7 +144,6 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
|
|
22
144
|
* Preserve indentation in literal and verse table cells
|
23
145
|
* Preserve paragraph breaks in normal table cells
|
24
146
|
* Honor value of width attribute even when autowidth option is set on table (#519)
|
25
|
-
* Allow font properties to be set per element in running content (#454)
|
26
147
|
* Align table title to left edge of table, regardless of table alignment (#469)
|
27
148
|
* Add support for reversed option on ordered list (#491)
|
28
149
|
* Don't drop whitespace in front of conum on final line of source block (#470)
|
@@ -47,7 +168,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
|
|
47
168
|
* Add support for px units to pdf-page-size attribute
|
48
169
|
* Fix parsing error when value of pdf-page-size attribute is unitless
|
49
170
|
* Don't crash if table is empty (#480)
|
50
|
-
* Don't crash when deleting last remaining page; don't delete last page if empty
|
171
|
+
* Don't crash when deleting last remaining page; don't delete last page if empty (#317)
|
51
172
|
* Don't orphan space between conums when extracting from verbatim block (#506)
|
52
173
|
* Properly scope attr and attr? lookups
|
53
174
|
* Rename internal page_start and page_end attributes to pdf-page-start and pdf-page-end, respectively
|
@@ -69,6 +190,9 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
|
|
69
190
|
* Configure README for better preview on GitHub
|
70
191
|
* Update chronicles example to modern AsciiDoc syntax; update content
|
71
192
|
|
193
|
+
{uri-repo}/issues?q=milestone%3Av1.5.0.alpha.13[issues resolved] |
|
194
|
+
{uri-repo}/releases/tag/v1.5.0.alpha.13[git tag]
|
195
|
+
|
72
196
|
== 1.5.0.alpha.12 (2016-08-05) - @mojavelinux
|
73
197
|
|
74
198
|
* Fix incompatibility with Rouge 2 source highlighter (#471)
|
@@ -103,6 +227,9 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
|
|
103
227
|
* Add hints to theming guide about how to apply styles when using Maven or Gradle (@fwilhe)
|
104
228
|
* Fix gemspec to collect files when project is not a git repository or git is not available
|
105
229
|
|
230
|
+
{uri-repo}/issues?q=milestone%3Av1.5.0.alpha.12[issues resolved] |
|
231
|
+
{uri-repo}/releases/tag/v1.5.0.alpha.12[git tag]
|
232
|
+
|
106
233
|
== 1.5.0.alpha.11 (2016-01-05) - @mojavelinux
|
107
234
|
|
108
235
|
* Allow font style for first line of abstract to be controlled by theme (@nawroth) (#378)
|
data/Gemfile
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
3
|
+
if (Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.0.0')
|
4
|
+
gem 'addressable', '2.4.0'
|
5
|
+
gem 'prawn', '1.3.0'
|
6
|
+
gem 'prawn-svg', '0.21.0'
|
7
|
+
end
|
4
8
|
|
5
9
|
# Look in asciidoctor-pdf.gemspec for runtime and development dependencies
|
6
10
|
gemspec
|
7
11
|
|
8
12
|
group :examples do
|
9
13
|
gem 'rouge', '2.0.6'
|
14
|
+
# Add unicode (preferred) or activesupport to transform case of text containing multibyte chars on Ruby < 2.4
|
15
|
+
#gem 'activesupport', '4.2.7.1' if (Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.4.0')
|
16
|
+
#gem 'unicode' if (Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.4.0')
|
10
17
|
end
|
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.alpha.
|
3
|
+
v1.5.0.alpha.14, 2017-02-05
|
4
4
|
// Settings:
|
5
5
|
:experimental:
|
6
6
|
:idprefix:
|
@@ -31,7 +31,11 @@ endif::[]
|
|
31
31
|
:uri-project-issues: {uri-project-repo}/issues
|
32
32
|
:uri-project-list: http://discuss.asciidoctor.org
|
33
33
|
:uri-prawn: http://prawn.majesticseacreature.com
|
34
|
+
:uri-prawn-gmagick: https://github.com/packetmonkey/prawn-gmagick
|
35
|
+
:uri-prawn-svg: https://github.com/mogest/prawn-svg
|
36
|
+
:uri-asciidoctor-mathematical: https://github.com/asciidoctor/asciidoctor-mathematical
|
34
37
|
:uri-rvm: http://rvm.io
|
38
|
+
:uri-graphicsmagick: http://www.graphicsmagick.org
|
35
39
|
|
36
40
|
ifdef::status[]
|
37
41
|
image:https://img.shields.io/gem/v/asciidoctor-pdf.svg[Latest Release, link={uri-gem}]
|
@@ -86,7 +90,7 @@ Picking up from there, {project-name} takes the pain out of creating PDF documen
|
|
86
90
|
=== Notable Features
|
87
91
|
|
88
92
|
* Direct AsciiDoc to PDF conversion
|
89
|
-
* <<docs/theming-guide
|
93
|
+
* <<docs/theming-guide#,Configuration-driven style and layout>>
|
90
94
|
* SVG support
|
91
95
|
* PDF document outline (i.e., bookmarks)
|
92
96
|
* Table of contents page(s)
|
@@ -105,7 +109,7 @@ Picking up from there, {project-name} takes the pain out of creating PDF documen
|
|
105
109
|
|
106
110
|
=== Missing Features
|
107
111
|
|
108
|
-
See <<WORKLOG
|
112
|
+
See <<WORKLOG#,WORKLOG>>.
|
109
113
|
|
110
114
|
== Prerequisites
|
111
115
|
|
@@ -122,6 +126,7 @@ Since version 2.0.0, Prawn requires Ruby >= 2.0.0 during installation (though it
|
|
122
126
|
Therefore, to use Asciidoctor PDF with Ruby 1.9.3, you must first explicitly install Prawn 1.3.0 and Prawn SVG 0.21.0 using the following commands:
|
123
127
|
|
124
128
|
$ gem install prawn --version 1.3.0
|
129
|
+
gem install addressable --version 2.4.0
|
125
130
|
gem install prawn-svg --version 0.21.0
|
126
131
|
|
127
132
|
You can then proceed with installation of Asciidoctor PDF on Ruby 1.9.3.
|
@@ -151,23 +156,23 @@ You can install the published gem using the following command:
|
|
151
156
|
|
152
157
|
$ gem install asciidoctor-pdf --pre
|
153
158
|
|
154
|
-
If you want to syntax highlight source listings, you'll also want to install
|
159
|
+
If you want to syntax highlight source listings, you'll also want to install Rouge, Pygments, or CodeRay.
|
155
160
|
Choose one (or more) of the following:
|
156
161
|
|
157
|
-
.
|
158
|
-
$ gem install coderay
|
159
|
-
|
160
|
-
.Rouge
|
162
|
+
.Rouge (preferred)
|
161
163
|
$ gem install rouge
|
162
164
|
|
163
165
|
.Pygments
|
164
166
|
$ gem install pygments.rb
|
165
|
-
|
166
|
-
|
167
|
+
|
168
|
+
.CodeRay
|
169
|
+
$ gem install coderay
|
170
|
+
|
171
|
+
You then activate syntax highlighting for a given document by adding the `source-highlighter` attribute to the document header (Rouge shown):
|
167
172
|
|
168
173
|
[source,asciidoc]
|
169
174
|
----
|
170
|
-
:source-highlighter:
|
175
|
+
:source-highlighter: rouge
|
171
176
|
----
|
172
177
|
|
173
178
|
Assuming all the required gems install properly, verify you can run the `asciidoctor-pdf` script:
|
@@ -183,7 +188,7 @@ Let's grab an AsciiDoc document to distill and start putting {project-name} to u
|
|
183
188
|
If you don't already have an AsciiDoc document, you can use the [file]_basic-example.adoc_ file found in the examples directory of this project.
|
184
189
|
|
185
190
|
ifeval::[{safe-mode-level} >= 20]
|
186
|
-
See <<examples/basic-example
|
191
|
+
See <<examples/basic-example#,basic-example.adoc>>.
|
187
192
|
endif::[]
|
188
193
|
ifeval::[{safe-mode-level} < 20]
|
189
194
|
.basic-example.adoc
|
@@ -223,7 +228,7 @@ The pain of the DocBook toolchain should be melting away about now.
|
|
223
228
|
== Themes
|
224
229
|
|
225
230
|
The layout and styling of the PDF is driven by a YAML configuration file.
|
226
|
-
To learn how the theming system works and how to create and apply custom themes, refer to the <<docs/theming-guide
|
231
|
+
To learn how the theming system works and how to create and apply custom themes, refer to the <<docs/theming-guide#,Asciidoctor PDF Theme Guide>>.
|
227
232
|
You can use the built-in theme files, which you can find in the [file]_data/themes_ directory, as examples.
|
228
233
|
|
229
234
|
== Font-Based Icons
|
@@ -284,7 +289,7 @@ Images are resolved relative to the value of the `imagesdir` attribute at the ti
|
|
284
289
|
This is effectively the same as how the built-in HTML converter works when the `data-uri` attribute is set.
|
285
290
|
The `imagesdir` is blank by default, which means images are resolved relative to the input document.
|
286
291
|
|
287
|
-
If the image is an SVG, and the SVG includes a nested raster image (
|
292
|
+
If the image is an SVG, and the SVG includes a nested raster image (PNG or JPG) with a relative path, that path is resolved relative to the directory that contains the SVG.
|
288
293
|
|
289
294
|
The converter will refuse to include an image if the target is a URI unless the `allow-uri-read` attribute is enabled via the CLI or API.
|
290
295
|
|
@@ -298,11 +303,14 @@ There are five ways to specify the width of an image, listed here in order of pr
|
|
298
303
|
|Attribute{nbsp}Name | Description
|
299
304
|
|
300
305
|
|pdfwidth
|
301
|
-
|The display width of the image as an absolute size (e.g., 2in), percentage of the content width (e.g., 75%), or percentage of the page width (e.g., 100vw).
|
306
|
+
|The display width of the image as an absolute size (e.g., 2in), percentage of the content area width (e.g., 75%), or percentage of the page width (e.g., 100vw).
|
307
|
+
If a unit of measurement is not specified (or not recognized), pt (points) is assumed.
|
302
308
|
_Intended to be used for the PDF converter only._
|
303
309
|
|
304
310
|
|scaledwidth
|
305
|
-
|The display width of the image as
|
311
|
+
|The display width of the image as an absolute size (e.g., 2in) or percentage of the content area width (e.g., 75%).
|
312
|
+
If a unit of measurement is not specified, % (percentage) is assumed.
|
313
|
+
If a unit of measurement is recognized, pt (points) is assumed.
|
306
314
|
_Intended to be used for print output such as PDF._
|
307
315
|
|
308
316
|
|image_width key from theme
|
@@ -311,16 +319,20 @@ _Only applies to block images._
|
|
311
319
|
|
312
320
|
|width
|
313
321
|
|The unitless display width of the image (assumed to be pixels), typically matching the intrinsic width of the image.
|
314
|
-
If the width exceeds the content width, the image is scaled down to the content width.
|
322
|
+
If the width exceeds the content area width, the image is scaled down to the content area width.
|
315
323
|
|
316
324
|
|_unspecified_
|
317
|
-
|If you don't specify one of the aforementioned width settings, the intrinsic width of the image is used (the px value is multiplied by 75% to convert to pt) unless the width exceeds the content width, in which case the image is scaled down to the content width.
|
325
|
+
|If you don't specify one of the aforementioned width settings, the intrinsic width of the image is used (the px value is multiplied by 75% to convert to pt, assuming canvas is 96 dpi) unless the width exceeds the content area width, in which case the image is scaled down to the content area width.
|
318
326
|
|===
|
319
327
|
|
320
|
-
The image is always sized according to the explicit or intrinsic width and its height is scaled
|
328
|
+
The image is always sized according to the explicit or intrinsic width and its height is scaled proportionally.
|
321
329
|
The height of the image is ignored by the PDF converter unless the height of the image exceeds the content height of the page.
|
322
330
|
In this case, the image is scaled down to fit on a single page.
|
323
331
|
|
332
|
+
Images in running content also support the `fit` attribute.
|
333
|
+
If the value of this attribute is `contain`, the image size is increased or decreased to fill the available space while preserving its aspect ratio.
|
334
|
+
If the value of this attribute is `scaled-down`, the image size is first resolved in the normal way, then scaled down further to fit within the available space, if necessary.
|
335
|
+
|
324
336
|
=== Using the pdfwidth Attribute
|
325
337
|
|
326
338
|
The pdfwidth attribute is the recommended way to set the image size for the PDF output.
|
@@ -332,17 +344,18 @@ The pdfwidth attribute supports the following units:
|
|
332
344
|
|
333
345
|
* pt (default)
|
334
346
|
* in
|
335
|
-
* mm
|
336
347
|
* cm
|
348
|
+
* mm
|
337
349
|
* px
|
338
|
-
*
|
350
|
+
* pc
|
339
351
|
* vw (percentage of page width)
|
352
|
+
* % (percentage of content area width)
|
340
353
|
|
341
354
|
In all cases, the width is converted to pt.
|
342
355
|
|
343
|
-
=== Specifying a default
|
356
|
+
=== Specifying a default width
|
344
357
|
|
345
|
-
If you want to scale all block images that don't have a pdfwidth
|
358
|
+
If you want to scale all block images that don't have a pdfwidth or scaledwidth attribute specified, assign a value to the image_width key in your theme.
|
346
359
|
|
347
360
|
[source,yaml]
|
348
361
|
----
|
@@ -352,18 +365,168 @@ image:
|
|
352
365
|
|
353
366
|
=== Inline Image Sizing
|
354
367
|
|
355
|
-
Inline images
|
356
|
-
|
368
|
+
Inline images can be sized in much the same way as block images (using the pdfwidth, scaledwidth or width attributes), with the following exceptions:
|
369
|
+
|
370
|
+
* The viewport width unit (i.e., vw) is not recognized in this context.
|
371
|
+
* The image will be scaled down, if necessary, to fit the width and height of the content area.
|
372
|
+
* Inline images do not currently support a default width controlled from the theme.
|
373
|
+
|
374
|
+
If the resolved height of the image is less than or equal to 1.5 times the line height, the image won't disrupt the line height and is centered vertically in the line.
|
375
|
+
This is done to maximize the use of available space.
|
376
|
+
Once the resolved height exceeds this amount, the height of the line is increased (by increasing the font size of the invisible placeholder text) to accommodate the image.
|
377
|
+
In this case, the surrounding text will be aligned to the bottom of the image.
|
378
|
+
If the image height exceeds the height of the page, the image will be scaled down to fit on a single page (this may cause the image to advance to the subsequent page).
|
379
|
+
|
380
|
+
== Fonts in SVG Images
|
381
|
+
|
382
|
+
Asciidoctor PDF uses {uri-prawn-svg}[prawn-svg] to embed SVGs in the PDF document, including SVGs generated by Asciidoctor Diagram.
|
383
|
+
|
384
|
+
Actually, it's not accurate to say that prawn-svg embeds the SVG.
|
385
|
+
Rather, prawn-svg is an SVG _renderer_.
|
386
|
+
prawn-svg translates an SVG into native PDF text and graphic objects.
|
387
|
+
You can think of the SVG as a sequence of drawing commands.
|
388
|
+
The result becomes indistinguishable from other PDF objects.
|
389
|
+
|
390
|
+
What that means for text is that any font family used for text in the SVG _must_ be registered in the Asciidoctor PDF theme file (and thus with Prawn).
|
391
|
+
Otherwise, Prawn will fallback to using the closest matching built-in (afm) font from PDF (e.g., sans-serif becomes Helvetica).
|
392
|
+
Recall that afm fonts only support basic Latin.
|
393
|
+
As we like to say, PDF is <<docs/theming-guide#built-in-afm-fonts,bring your own font>>.
|
394
|
+
|
395
|
+
If you're using Asciidoctor Diagram to generate SVGs to embed in the PDF, you likely need to specify the default font the diagramming tool uses.
|
396
|
+
Let's assume you are making a plantuml diagram.
|
397
|
+
|
398
|
+
To set the font used in the diagram, first create a file named [.path]_plantuml.cfg_ and populate it with the following content:
|
399
|
+
|
400
|
+
----
|
401
|
+
skinparam defaultFontName Noto Serif
|
402
|
+
----
|
403
|
+
|
404
|
+
TIP: You can choose any font name that is registered in your Asciidoctor PDF theme file.
|
405
|
+
When using the default theme, your options are "Noto Serif", "M+ 1mn", and "M+ 1p Fallback".
|
406
|
+
|
407
|
+
Next, pass that path to the `plantumlconfig` attribute in your AsciiDoc document (or set the attribute via the CLI or API):
|
408
|
+
|
409
|
+
----
|
410
|
+
:plantumlconfig: plantuml.cfg
|
411
|
+
----
|
412
|
+
|
413
|
+
Clear the cache of your diagrams and run Asciidoctor PDF with Asciidoctor Diagram enabled.
|
414
|
+
The diagrams will be generated using Noto Serif as the default font, and Asciidoctor PDF will know what to do.
|
415
|
+
|
416
|
+
The bottom line is this:
|
417
|
+
If you're using fonts in your SVG, and you want those fonts to be preserved, those fonts must be defined in the Asciidoctor PDF theme file.
|
418
|
+
|
419
|
+
== Supporting Additional Image File Formats
|
420
|
+
|
421
|
+
In order to embed an image into a PDF, Asciidoctor PDF must understand how to read it.
|
422
|
+
To perform this work, Asciidoctor delegates to the underlying libraries.
|
423
|
+
{uri-prawn}[Prawn] provides support for reading JPG and PNG images.
|
424
|
+
{uri-prawn-svg}[prawn-svg] brings support for SVG images.
|
425
|
+
Without any additional libraries, those are the only supported image file formats.
|
426
|
+
|
427
|
+
If you need support for additional file formats, such as GIF or TIFF, you must install the {uri-prawn-gmagick}[prawn-gmagick] Ruby gem.
|
428
|
+
prawn-gmagick is an extension for Prawn based on {uri-graphicsmagick}[GraphicsMagick] and brings supports all the formats recognized by that library.
|
429
|
+
|
430
|
+
The prawn-gmagick gem uses native extensions to compile against GraphicsMagick.
|
431
|
+
This system prerequisite limits installation to Linux and OSX.
|
432
|
+
Please refer to the {uri-prawn-gmagick}[README for prawn-gmagick] to learn how to install it.
|
433
|
+
|
434
|
+
Once this gem is installed, Asciidoctor automatically switches over to it to handle embedding of all images.
|
435
|
+
In addition to support for more additional image file formats, this gem also speeds up image processing considerably, so we highly recommend using it if you can.
|
436
|
+
|
437
|
+
== STEM Support
|
438
|
+
|
439
|
+
Unlike the built-in HTML converter, Asciidoctor PDF does not provide native support for STEM blocks and inline macros.
|
440
|
+
That's because Asciidoctor core doesn't actually process STEM equations.
|
441
|
+
In the HTML output, Asciidoctor relies on the JavaScript-based MathJax library to parse and render the equations in the browser.
|
442
|
+
All the HTML converter does is wrap the equations so MathJax is able to find them.
|
443
|
+
|
444
|
+
In order to insert a rendered equation into the PDF, the toolchain has to parse the equations and convert them to a format the PDF writer (Prawn) can understand.
|
445
|
+
That typically means converting to an image.
|
446
|
+
|
447
|
+
The recommended solution is an extension named Asciidoctor Mathematical, which we'll cover here.
|
448
|
+
Another solution still under development uses Mathoid to convert STEM equations to images.
|
449
|
+
Mathoid is a library that invokes MathJax using a headless browser.
|
450
|
+
That prototype can be found in the https://github.com/asciidoctor/asciidoctor-extensions-lab#extension-catalog[Asciidoctor extensions lab].
|
451
|
+
|
452
|
+
=== Asciidoctor Mathematical
|
453
|
+
|
454
|
+
{uri-asciidoctor-mathematical}[Asciidoctor Mathematical] is an extension for Asciidoctor that provides alternate processing of STEM blocks and inline macros.
|
455
|
+
After the document has been parsed, the extension locates all the STEM blocks and inline macros, converts the equations to images using Mathematical, then replaces them with image nodes.
|
456
|
+
Conversion then proceeds as normal.
|
457
|
+
|
458
|
+
Asciidoctor Mathematical is a Ruby gem that uses native extensions.
|
459
|
+
It has a few system prerequisites which limit installation to Linux and OSX.
|
460
|
+
Please refer to the {uri-asciidoctor-mathematical}#installation[installation section] in the Asciidoctor Mathematical README to learn how to install it.
|
461
|
+
|
462
|
+
Once Asciidoctor Mathematical is installed, you just need to enable it when invoking Asciidoctor PDF using the `-r` flag:
|
463
|
+
|
464
|
+
$ asciidoctor-pdf -r asciidoctor-mathematical sample.adoc
|
465
|
+
|
466
|
+
If you're invoking Asciidoctor via the API, all you need to do is require the gem before invoking Asciidoctor:
|
467
|
+
|
468
|
+
[source,ruby]
|
469
|
+
----
|
470
|
+
require 'asciidoctor-mathematical'
|
471
|
+
|
472
|
+
Asciidoctor.convert_file 'sample.adoc', safe: :safe
|
473
|
+
----
|
474
|
+
|
475
|
+
CAUTION: Asciidoctor Mathematical does not currently process STEM blocks and inline macros inside AsciiDoc table cells or STEM inline macros in normal table cells.
|
476
|
+
You can track the progress of these improvements by following {uri-asciidoctor-mathematical}/issues/20[issue #20] and {uri-asciidoctor-mathematical}/issues/19[issue #19], respectively.
|
477
|
+
|
478
|
+
To get the best quality equations, and the maximize speed of conversion, we recommend configuring Asciidoctor Mathematical to convert equations to SVG.
|
479
|
+
You control this setting using the `mathematical-format` AsciiDoc attribute:
|
480
|
+
|
481
|
+
$ asciidoctor-pdf -r asciidoctor-mathematical -a mathematical-format=svg sample.adoc
|
482
|
+
|
483
|
+
Refer to the {uri-asciidoctor-mathematical}#readme[README] for Asciidoctor Mathematical to learn about additional settings and options.
|
484
|
+
|
485
|
+
== Autofitting Text
|
486
|
+
|
487
|
+
Verbatim blocks often have long lines that don't fit within the fixed width of the PDF canvas.
|
488
|
+
And unlike on the web, the PDF reader cannot scroll horizontally to reveal the overflow text.
|
489
|
+
Therefore, the long lines are forced to wrap.
|
490
|
+
Wrapped lines can make the verbatim blocks hard to read or even cause confusion.
|
491
|
+
|
492
|
+
To help address this problem, Asciidoctor PDF provides the `autofit` option on all verbatim (i.e., literal, listing and source) blocks to attempt to fit the text within the available width.
|
493
|
+
When the `autofit` option is enabled, Asciidoctor PDF will decrease the font size until the longest line fits without wrapping.
|
494
|
+
|
495
|
+
CAUTION: The font size will not be decreased beyond the value of the `base_font_size_min` key specified in the PDF theme.
|
496
|
+
If that threshold is reached, lines may still wrap.
|
497
|
+
|
498
|
+
Here's an example of the autofit option enabled on a source block:
|
499
|
+
|
500
|
+
[source,asciidoc]
|
501
|
+
....
|
502
|
+
[source%autofit,java]
|
503
|
+
----
|
504
|
+
@SessionScoped
|
505
|
+
public class WidgetRepository {
|
506
|
+
@GET
|
507
|
+
@Produces("application/json")
|
508
|
+
public List<String> listAll(@QueryParam("start") Integer start, @QueryParam("max") Integer max) {
|
509
|
+
...
|
510
|
+
}
|
511
|
+
}
|
512
|
+
----
|
513
|
+
....
|
514
|
+
|
515
|
+
If you want to enable the autofit option globally, set the `autofit-option` document attribute in the document header (or somewhere before the relevant blocks):
|
516
|
+
|
517
|
+
[source,asciidoc]
|
518
|
+
----
|
519
|
+
:autofit-option:
|
520
|
+
----
|
357
521
|
|
358
|
-
|
359
|
-
The image height is scaled down to 75% of the specified width (px to pt conversion).
|
360
|
-
If the image height is more than 1.5x the height of the surrounding line of text, the font size and line metrics of the fragment are modified to fit the image in the line.
|
522
|
+
== Printing Page Ranges
|
361
523
|
|
362
|
-
|
524
|
+
The print dialog doesn't understand the page numbers labels (which appear in the running content).
|
525
|
+
Instead, it only considers physical pages.
|
526
|
+
Therefore, to print a range of pages as they are labeled in the document, you need to add the number of front matter pages (i.e., the non-numbered pages) to the page number range in the print dialog.
|
363
527
|
|
364
|
-
|
365
|
-
|
366
|
-
Instead, it only considers the physical pages.
|
528
|
+
For example, if you only want to print the first 5 pages labeled with a page number (e.g., 1-5), and there are 2 pages before the page labeled as page 1, you need to add 2 to both numbers in the range, giving you a physical page range of 3-7.
|
529
|
+
That's the range you need to enter into the print dialog.
|
367
530
|
|
368
531
|
== Optional Scripts
|
369
532
|
|
@@ -383,7 +546,7 @@ IMPORTANT: The `optimize-pdf` script relies on Ghostscript >= 9.10.
|
|
383
546
|
Otherwise, it may actually make the PDF larger.
|
384
547
|
Also, you should only consider using it if the file size of the original PDF is > 5MB.
|
385
548
|
|
386
|
-
If a file is found with the extension `.
|
549
|
+
If a file is found with the extension `.pdfmark` and the same rootname as the input file, it is used to add metadata to the generated PDF document.
|
387
550
|
This file is necessary to preserve the document metadata since Ghostscript will otherwise drop it.
|
388
551
|
That's why {project-name} always creates this file in addition to the PDF.
|
389
552
|
|
@@ -471,8 +634,8 @@ For best results, be sure to always use `bundle exec` whenever invoking the `./b
|
|
471
634
|
|
472
635
|
== Copyright
|
473
636
|
|
474
|
-
Copyright (C) 2014-
|
637
|
+
Copyright (C) 2014-2017 OpenDevise Inc. and the Asciidoctor Project.
|
475
638
|
Free use of this software is granted under the terms of the MIT License.
|
476
639
|
|
477
|
-
For the full text of the license, see the <<LICENSE
|
478
|
-
Refer to the <<NOTICE
|
640
|
+
For the full text of the license, see the <<LICENSE#,LICENSE>> file.
|
641
|
+
Refer to the <<NOTICE#,NOTICE>> file for information about third-party Open Source software in use.
|