asciidoctor-pdf 1.5.0.alpha.16 → 1.5.0.alpha.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.yardopts +12 -0
- data/CHANGELOG.adoc +66 -0
- data/LICENSE.adoc +1 -1
- data/README.adoc +221 -68
- data/asciidoctor-pdf.gemspec +41 -42
- data/bin/asciidoctor-pdf +3 -3
- data/data/fonts/mplus1p-regular-fallback.ttf +0 -0
- data/data/fonts/notoserif-bold-subset.ttf +0 -0
- data/data/fonts/notoserif-bold_italic-subset.ttf +0 -0
- data/data/fonts/notoserif-italic-subset.ttf +0 -0
- data/data/fonts/notoserif-regular-subset.ttf +0 -0
- data/data/themes/default-theme.yml +6 -3
- data/docs/theming-guide.adoc +162 -23
- data/lib/asciidoctor-pdf.rb +2 -1
- data/lib/asciidoctor-pdf/asciidoctor_ext.rb +1 -0
- data/lib/asciidoctor-pdf/asciidoctor_ext/logging_shim.rb +19 -0
- data/lib/asciidoctor-pdf/converter.rb +408 -186
- data/lib/asciidoctor-pdf/core_ext/array.rb +0 -6
- data/lib/asciidoctor-pdf/core_ext/numeric.rb +21 -12
- data/lib/asciidoctor-pdf/core_ext/ostruct.rb +3 -12
- data/lib/asciidoctor-pdf/core_ext/string.rb +1 -1
- data/lib/asciidoctor-pdf/formatted_text.rb +1 -0
- data/lib/asciidoctor-pdf/formatted_text/formatter.rb +8 -2
- data/lib/asciidoctor-pdf/formatted_text/inline_destination_marker.rb +1 -1
- data/lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb +18 -32
- data/lib/asciidoctor-pdf/formatted_text/inline_image_renderer.rb +3 -3
- data/lib/asciidoctor-pdf/formatted_text/inline_text_aligner.rb +20 -0
- data/lib/asciidoctor-pdf/formatted_text/parser.rb +124 -38
- data/lib/asciidoctor-pdf/formatted_text/parser.treetop +17 -10
- data/lib/asciidoctor-pdf/formatted_text/transform.rb +30 -20
- data/lib/asciidoctor-pdf/implicit_header_processor.rb +2 -2
- data/lib/asciidoctor-pdf/index_catalog.rb +25 -23
- data/lib/asciidoctor-pdf/measurements.rb +1 -1
- data/lib/asciidoctor-pdf/pdf-core_ext/pdf_object.rb +1 -1
- data/lib/asciidoctor-pdf/pdfmark.rb +13 -13
- data/lib/asciidoctor-pdf/prawn-svg_ext.rb +2 -2
- data/lib/asciidoctor-pdf/prawn-svg_ext/interface.rb +2 -2
- data/lib/asciidoctor-pdf/prawn-table_ext.rb +1 -0
- data/lib/asciidoctor-pdf/prawn-table_ext/cell.rb +60 -0
- data/lib/asciidoctor-pdf/prawn-table_ext/cell/text.rb +3 -3
- data/lib/asciidoctor-pdf/prawn_ext/coderay_encoder.rb +3 -3
- data/lib/asciidoctor-pdf/prawn_ext/extensions.rb +39 -14
- data/lib/asciidoctor-pdf/prawn_ext/formatted_text/fragment.rb +9 -10
- data/lib/asciidoctor-pdf/prawn_ext/images.rb +2 -2
- data/lib/asciidoctor-pdf/roman_numeral.rb +7 -7
- data/lib/asciidoctor-pdf/rouge_ext.rb +2 -2
- data/lib/asciidoctor-pdf/rouge_ext/formatters/prawn.rb +20 -9
- data/lib/asciidoctor-pdf/rouge_ext/themes/{pastie.rb → asciidoctor_pdf_default.rb} +5 -5
- data/lib/asciidoctor-pdf/rouge_ext/themes/bw.rb +38 -0
- data/lib/asciidoctor-pdf/sanitizer.rb +36 -23
- data/lib/asciidoctor-pdf/temporary_path.rb +1 -1
- data/lib/asciidoctor-pdf/theme_loader.rb +17 -14
- data/lib/asciidoctor-pdf/version.rb +3 -2
- data/lib/asciidoctor/pdf.rb +1 -0
- data/lib/asciidoctor/pdf/version.rb +1 -0
- metadata +113 -84
- data/Gemfile +0 -22
- data/Rakefile +0 -81
- data/lib/asciidoctor-pdf/rouge_ext/css_theme.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fcb6c79a944028551c1ec56650df511a0f4be9984d379de22c891031ce743fe2
|
4
|
+
data.tar.gz: d75bce156557910b7aa82c703b97fd266a5035cd4b37707756ca2f3e29359363
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be77878203c03b479682a80f50baf8278599b6c9d5d24e3dba46e2ad798f26641f223a6b620cff240d6e893eed4d12804b0693f5dbbd926b79e65c40c704e4cc
|
7
|
+
data.tar.gz: 2c3d80e93665b076bda8c1c6b4d6dd59225eb6437d9ad679ebed6995ad1523cadf215a0d6dbe3bab461a089ecf1433bab259cc8bdab519737029659acc175355
|
data/.yardopts
ADDED
data/CHANGELOG.adoc
CHANGED
@@ -5,6 +5,69 @@
|
|
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.17 (2019-04-23) - @mojavelinux
|
9
|
+
|
10
|
+
* drop support for Ruby < 2.3 (and installation will fail for Ruby < 2.1)
|
11
|
+
* add asciidoctor/pdf and asciidoctor/pdf/version require aliases (#262)
|
12
|
+
* rename module to Asciidoctor::PDF and define Asciidoctor::Pdf alias for backwards compatibility (#262)
|
13
|
+
* switch to tilde dependency versions (flexible patch number) instead of ranges
|
14
|
+
* upgrade prawn-svg to 0.29.1; resolves numerous SVG rendering issues (#886, #430)
|
15
|
+
* drop support for Rouge < 2
|
16
|
+
* add a test suite (#37)
|
17
|
+
* allow running content (header and footer) to be enabled on title and toc pages; controlled by running_content_start_at property in theme (#606)
|
18
|
+
* add support for nbsp named entity (i.e., `+ `); replace occurances of nbsp named entity with a single space in outline
|
19
|
+
* upgrade to FontAwesome 5; introduce the fas, far, and fab icon sets, now preferred over fa; drop support for octicons (#891) (@jessedoyle)
|
20
|
+
* place footnotes at end of chapters in books or end of document otherwise (#85) (@bcourtine)
|
21
|
+
* place toc directly after document title when doctype is not book (#233) (@ogmios-voice)
|
22
|
+
* add page layout control to page break (#490) (@resort-diaper)
|
23
|
+
* allow additional style properties to be set per heading level (#176) (@billybooth)
|
24
|
+
* add support for hexadecimal character references, including in link href (#486)
|
25
|
+
* force set data-uri attribute on document so Asciidoctor Diagram returns absolute image paths (#1033)
|
26
|
+
* set line spacing for non-AsciiDoc table cells (#296)
|
27
|
+
* consider all scripts when looking for leading alpha characters in index (#853)
|
28
|
+
* don't create title page for article doctype unless title-page attribute is set (#105)
|
29
|
+
* don't show article title if notitle attribute is set (#998)
|
30
|
+
* generate name section for manpage doctype automatically (#882)
|
31
|
+
* remove unprocessed passthroughs in literal cells
|
32
|
+
* apply font style from theme to formatted text description list term (#854)
|
33
|
+
* prevent tempfile for remote image from being deleted before it's used (#947)
|
34
|
+
* handle case when uri to make breakable is empty (#936)
|
35
|
+
* add support for frame=ends as alternative to frame=topbot on table
|
36
|
+
* allow table frame and grid to be set globally using the table-frame and table-grid attributes (#822)
|
37
|
+
* disable table stripes by default
|
38
|
+
* allow table stripes to be enabled globally using table-stripes attribute
|
39
|
+
* use new logging subsystem, if available; otherwise, use shim (#905)
|
40
|
+
* allow alignment of list text to be controlled using roles (#182)
|
41
|
+
* allow text alignment to be set for abstract (#893)
|
42
|
+
* prevent text from overlapping page number in TOC (#839)
|
43
|
+
* allow ulist marker to be controlled by theme (#798)
|
44
|
+
* add support for reftext for bibliography entry (#864)
|
45
|
+
* add support for fw (full-width) icons (#890)
|
46
|
+
* decouple vw units with alignment (#948)
|
47
|
+
* add align-to-page option for block images (#948)
|
48
|
+
* add support for SVG admonition icons (#828) (@keith-packard)
|
49
|
+
* rename pastie theme for Rouge to asciidoctor_pdf_default
|
50
|
+
* add bw theme for Rouge (#1018)
|
51
|
+
* reset top margin of index columns when overflowing to new page (#929)
|
52
|
+
* add support for line numbers in source listings (#224)
|
53
|
+
* add U+2060 (word joiner) character to built-in Noto Serif font and fallback font (#877)
|
54
|
+
* add U+202F (narrow no-break space) character to fallback font (#807)
|
55
|
+
* ensure callout number ends up on same page as item text (#914)
|
56
|
+
* guard against pygments returning nil (#884)
|
57
|
+
* encode quotes in alt text of inline image (#977)
|
58
|
+
* fix crash when menu macro is used in a section or block title (#934)
|
59
|
+
* only look for the start attribute on the code block itself when highlighting with rouge
|
60
|
+
* apply block styling to background for line-oriented tokens in rouge by default
|
61
|
+
* detect pagenum ranges in index when media is print or prepress (#906)
|
62
|
+
* ignore style when resolving icon font (#956, #874)
|
63
|
+
* remove correct width method when overloading Prawn::Text::Formatted::Fragment
|
64
|
+
* remove ZWSP from alt text of image to prevent fragment from being duplicated (#958)
|
65
|
+
* avoid call to super in prepended module to fix Ruby 1.9.3
|
66
|
+
* look for correct file to require in bin script
|
67
|
+
* upgrade prawn-icon from 1.3.0 to 1.4.0
|
68
|
+
* upgrade rouge to 2.2.1
|
69
|
+
* add concurrent-ruby to runtime dependencies for compatiblity w/ Asciidoctor 1.5.8
|
70
|
+
|
8
71
|
== 1.5.0.alpha.16 (2017-07-30) - @mojavelinux
|
9
72
|
|
10
73
|
* add support for xrefstyle attribute (#464)
|
@@ -117,6 +180,8 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
|
|
117
180
|
* map dynamic section-title attribute in running content to current section if page has no section (#709)
|
118
181
|
* assign dynamic part-title attribute for use in running content (#596)
|
119
182
|
* don't set dynamic chapter-title attribute in running content for preface unless doctype is book
|
183
|
+
* clear section and chapter title in running content when part changes (#910, #879)
|
184
|
+
* clear section title in running content when chapter changes (#910)
|
120
185
|
* assign page number label to each page (#641)
|
121
186
|
* don't set dynamic page-number attribute in running content of pagenums is disabled
|
122
187
|
* allow toc title properties to be controlled by theme (#701)
|
@@ -130,6 +195,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
|
|
130
195
|
* don't crash if image in running content fails to embed (#728)
|
131
196
|
* treat abstract section as abstract block (#703)
|
132
197
|
* set example block background to white by default
|
198
|
+
* automatically wire unspecified code and conum font family to literal font family
|
133
199
|
* add support for background colors when highlighting code with Rouge
|
134
200
|
* add support underline style for token in Rouge theme (#665)
|
135
201
|
* drop background colors on strings in rouge pastie theme
|
data/LICENSE.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
.The MIT License
|
2
2
|
....
|
3
|
-
Copyright (C) 2014-
|
3
|
+
Copyright (C) 2014-2019 OpenDevise Inc. and the Asciidoctor Project
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
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.17, 2019-04-23
|
4
4
|
// Settings:
|
5
5
|
:experimental:
|
6
6
|
:idprefix:
|
@@ -23,6 +23,8 @@ endif::[]
|
|
23
23
|
// Aliases:
|
24
24
|
:project-name: Asciidoctor PDF
|
25
25
|
:project-handle: asciidoctor-pdf
|
26
|
+
// Variables:
|
27
|
+
:release-version: 1.5.0.alpha.17
|
26
28
|
// URIs:
|
27
29
|
:uri-asciidoctor: http://asciidoctor.org
|
28
30
|
:uri-gem: http://rubygems.org/gems/asciidoctor-pdf
|
@@ -30,7 +32,7 @@ endif::[]
|
|
30
32
|
:uri-project-repo: {uri-project}
|
31
33
|
:uri-project-issues: {uri-project-repo}/issues
|
32
34
|
:uri-project-list: http://discuss.asciidoctor.org
|
33
|
-
:uri-prawn: http://
|
35
|
+
:uri-prawn: http://prawnpdf.org
|
34
36
|
:uri-prawn-gmagick: https://github.com/packetmonkey/prawn-gmagick
|
35
37
|
:uri-prawn-svg: https://github.com/mogest/prawn-svg
|
36
38
|
:uri-asciidoctor-mathematical: https://github.com/asciidoctor/asciidoctor-mathematical
|
@@ -38,10 +40,18 @@ endif::[]
|
|
38
40
|
:uri-graphicsmagick: http://www.graphicsmagick.org
|
39
41
|
|
40
42
|
ifdef::status[]
|
43
|
+
image:https://img.shields.io/travis/asciidoctor/asciidoctor-pdf/master.svg[Build Status (Travis CI),link=https://travis-ci.org/asciidoctor/asciidoctor-pdf]
|
41
44
|
image:https://img.shields.io/gem/v/asciidoctor-pdf.svg[Latest Release, link={uri-gem}]
|
42
45
|
image:https://img.shields.io/badge/license-MIT-blue.svg[MIT License, link=#copyright]
|
43
46
|
endif::[]
|
44
47
|
|
48
|
+
ifdef::env-site[]
|
49
|
+
Asciidoctor PDF is a native PDF converter for AsciiDoc.
|
50
|
+
It bypasses the requirement to generate an interim format such as DocBook, Apache FO, or LaTeX.
|
51
|
+
Instead, you can use it to convert directly from AsciiDoc to PDF.
|
52
|
+
Its aim is to take the pain out of creating PDF documents from AsciiDoc.
|
53
|
+
endif::[]
|
54
|
+
ifndef::env-site[]
|
45
55
|
_Lo and behold_, a native PDF converter for AsciiDoc built with {uri-asciidoctor}[Asciidoctor] and {uri-prawn}[Prawn]! +
|
46
56
|
_No more middleman._ +
|
47
57
|
_No more DocBook toolchain._ +
|
@@ -84,10 +94,9 @@ Skip ahead to <<getting-started,Getting started>> to start putting it use.
|
|
84
94
|
Prawn is the _killer library_ for PDF generation we've needed to close this critical gap in Asciidoctor.
|
85
95
|
It absolutely takes the pain out of creating printable documents.
|
86
96
|
Picking up from there, {project-name} takes the pain out of creating PDF documents _from AsciiDoc_.
|
97
|
+
endif::[]
|
87
98
|
|
88
|
-
==
|
89
|
-
|
90
|
-
=== Notable Features
|
99
|
+
== Highlights
|
91
100
|
|
92
101
|
* Direct AsciiDoc to PDF conversion
|
93
102
|
* <<docs/theming-guide#,Configuration-driven style and layout>>
|
@@ -107,44 +116,16 @@ Picking up from there, {project-name} takes the pain out of creating PDF documen
|
|
107
116
|
* Custom (TTF) fonts
|
108
117
|
* Double-sided printing mode (margins alternate on recto and verso pages)
|
109
118
|
|
110
|
-
=== Missing Features
|
111
|
-
|
112
|
-
See <<WORKLOG#,WORKLOG>>.
|
113
|
-
|
114
119
|
== Prerequisites
|
115
120
|
|
116
|
-
All that's needed is Ruby
|
121
|
+
All that's needed is Ruby 2.3 or better and a few Ruby gems, which we explain how to install in the next section.
|
117
122
|
|
118
123
|
To check if you have Ruby available, use the `ruby` command to query the version installed:
|
119
124
|
|
120
125
|
$ ruby --version
|
121
126
|
|
122
|
-
|
123
|
-
|
124
|
-
By default, Asciidoctor PDF automatically installs the latest version of Prawn if you don't already have Prawn installed.
|
125
|
-
This will fail on older versions of Ruby.
|
126
|
-
To workaround, you need to install certain dependencies first.
|
127
|
-
|
128
|
-
Starting with Prawn 2.0.0, Prawn requires Ruby >= 2.0.0 during installation.
|
129
|
-
Therefore, to use Asciidoctor PDF with Ruby 1.9.3, you must first explicitly install the following dependencies to lock the versions:
|
130
|
-
|
131
|
-
$ gem install prawn --version 1.3.0
|
132
|
-
gem install addressable --version 2.4.0
|
133
|
-
gem install prawn-svg --version 0.21.0
|
134
|
-
gem install prawn-templates --version 0.0.3
|
135
|
-
|
136
|
-
You can then proceed with installation of Asciidoctor PDF on Ruby 1.9.3.
|
137
|
-
|
138
|
-
Starting with Prawn 2.2.0, Prawn requires Ruby >= 2.1.0 during installation.
|
139
|
-
Therefore, to use Asciidoctor PDF with Ruby 2.0.0, you must first explicitly install the following dependencies to lock the versions:
|
140
|
-
|
141
|
-
$ gem install prawn --version 2.1.0
|
142
|
-
gem install prawn-svg --version 0.26.0
|
143
|
-
gem install prawn-templates --version 0.0.4
|
144
|
-
|
145
|
-
For all other versions of Ruby, you can simply install the Asciidoctor PDF gem.
|
146
|
-
It will transitively install the required dependencies.
|
147
|
-
====
|
127
|
+
Make sure this command reports a Ruby version that's at least 2.3.
|
128
|
+
If so, you may proceed.
|
148
129
|
|
149
130
|
=== System Encoding
|
150
131
|
|
@@ -161,7 +142,8 @@ Once you make this change, all your Unicode headaches will be behind you.
|
|
161
142
|
|
162
143
|
== Getting Started
|
163
144
|
|
164
|
-
You can get {project-name} by <<install-the-published-gem,installing the published gem
|
145
|
+
You can get {project-name} by <<install-the-published-gem,installing the published gem>>.
|
146
|
+
ifndef::env-site[You can also <<development,run the code from source>> if you want to use a development version or participate in development.]
|
165
147
|
|
166
148
|
=== Install the Published Gem
|
167
149
|
|
@@ -170,11 +152,11 @@ First, make sure you have satisfied the <<Prerequisites,prerequisites>>.
|
|
170
152
|
Then, you can install the published gem using the following command:
|
171
153
|
|
172
154
|
$ gem install asciidoctor-pdf --pre
|
173
|
-
|
155
|
+
|
174
156
|
If you want to syntax highlight source listings, you'll also want to install Rouge, Pygments, or CodeRay.
|
175
157
|
Choose one (or more) of the following:
|
176
158
|
|
177
|
-
.Rouge (preferred)
|
159
|
+
.Rouge (preferred, minimum version: 2.0.0)
|
178
160
|
$ gem install rouge
|
179
161
|
|
180
162
|
.Pygments
|
@@ -187,20 +169,22 @@ You then activate syntax highlighting for a given document by adding the `source
|
|
187
169
|
|
188
170
|
[source,asciidoc]
|
189
171
|
----
|
190
|
-
:source-highlighter: rouge
|
172
|
+
:source-highlighter: rouge
|
191
173
|
----
|
192
174
|
|
175
|
+
=== Run the Application
|
176
|
+
|
193
177
|
Assuming all the required gems install properly, verify you can run the `asciidoctor-pdf` script:
|
194
178
|
|
195
179
|
$ asciidoctor-pdf -v
|
196
180
|
|
197
|
-
If you see the version of {project-name} printed, you're ready to use {project-name}
|
181
|
+
If you see the version of {project-name} printed, you're ready to use {project-name}!
|
198
182
|
|
199
|
-
Let's grab an AsciiDoc document to distill and start putting {project-name} to use
|
183
|
+
Let's grab an AsciiDoc document to distill and start putting {project-name} to use.
|
200
184
|
|
201
185
|
=== An Example AsciiDoc Document
|
202
186
|
|
203
|
-
If you don't already have an AsciiDoc document, you can use the
|
187
|
+
If you don't already have an AsciiDoc document, you can use the <<examples/basic-example#,basic-example.adoc>> file found in the examples directory of this project.
|
204
188
|
|
205
189
|
ifeval::[{safe-mode-level} >= 20]
|
206
190
|
See <<examples/basic-example#,basic-example.adoc>>.
|
@@ -230,13 +214,15 @@ This command is just a shorthand way of running:
|
|
230
214
|
The `asciidoctor-pdf` command just saves you from having to remember all those flags.
|
231
215
|
That's why we created it.
|
232
216
|
|
233
|
-
When the script completes, you should see the file [
|
234
|
-
Open the [
|
217
|
+
When the script completes, you should see the file [.path]_basic-example.pdf_ in the same directory.
|
218
|
+
Open the [.path]_basic-example.pdf_ file with a PDF viewer to see the result.
|
235
219
|
|
236
220
|
.Example PDF document rendered in a PDF viewer
|
237
|
-
image::examples/example-pdf-screenshot.png[Screenshot of PDF document,width=
|
221
|
+
image::examples/example-pdf-screenshot.png[Screenshot of PDF document,width=850,467,scaledwidth=100%]
|
238
222
|
|
223
|
+
ifndef::env-site[]
|
239
224
|
You're also encouraged to try converting this <<README#,README>> as well as the documents in the examples directory to see more of what {project-name} can do.
|
225
|
+
endif::[]
|
240
226
|
|
241
227
|
The pain of the DocBook toolchain should be melting away about now.
|
242
228
|
|
@@ -244,12 +230,20 @@ The pain of the DocBook toolchain should be melting away about now.
|
|
244
230
|
|
245
231
|
The layout and styling of the PDF is driven by a YAML configuration file.
|
246
232
|
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>>.
|
247
|
-
You can use the built-in theme files, which you can find in the [
|
233
|
+
You can use the built-in theme files, which you can find in the [.path]_data/themes_ directory, as examples.
|
234
|
+
|
235
|
+
If you've enabled a source highlighter, you can control the style (aka theme) it applies to source blocks using the `coderay-style`, `pygments-style`, and `rouge-style` attributes, respectively.
|
236
|
+
For example, to configure Rouge to use the built-in monokai theme, run Asciidoctor PDF as follows:
|
237
|
+
|
238
|
+
$ asciidoctor-pdf -a rouge-style=monokai basic-example.adoc
|
239
|
+
|
240
|
+
It's possible to develop your own theme for Rouge.
|
241
|
+
Refer to the <<docs/theming-guide#,Asciidoctor PDF Theme Guide>> for details.
|
248
242
|
|
249
243
|
=== Support for Non-Latin Languages
|
250
244
|
|
251
245
|
Asciidoctor can process the full range of characters in the UTF-8 character set.
|
252
|
-
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.
|
246
|
+
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.
|
253
247
|
However, you may notice that certain characters for certain languages, such as Chinese, are missing in the PDF.
|
254
248
|
Read on to find out why and how to address it.
|
255
249
|
|
@@ -260,22 +254,27 @@ See the https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic[asciidoct
|
|
260
254
|
|
261
255
|
Using a dedicated theme is necessary because PDF is a "`bring your own font`" kind of system.
|
262
256
|
In other words, the font you provide must provide glyphs for all the characters.
|
263
|
-
There's no one font that supports all the worlds languages (though some, like Noto Serif, certainly come close).
|
257
|
+
There's no one font that supports all the worlds languages (though some, like Noto Serif, certainly come close).
|
264
258
|
Even if there were such a font, bundling that font with the main gem would make the package enormous.
|
265
259
|
It would also severely limit the style choices in the default theme, which targets Latin-based languages.
|
266
260
|
|
267
261
|
Therefore, we're taking the strategy of creating separate dedicated theme gems that target each language family, such as CJK.
|
268
|
-
The base theme for CJK languages is provided by the https://github.com/chloerei/asciidoctor-pdf-cjk[
|
262
|
+
The base theme for CJK languages is provided by the https://github.com/chloerei/asciidoctor-pdf-cjk[asciidoctor-pdf-cjk] project and a concrete implementation provided by the https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic[asciidoctor-pdf-cjk-kai_gen_gothic] project that's based on the kai_gen_gothic font.
|
269
263
|
Of course, you're free to follow this model and create your own theme gem that uses fonts of your choice.
|
270
264
|
|
271
265
|
== Font-Based Icons
|
272
266
|
|
273
267
|
You can use icons in your PDF document using any of the following icon sets:
|
274
268
|
|
275
|
-
* *fa* - https://
|
276
|
-
* *
|
269
|
+
* *fa* - https://fontawesome.com/v4.7.0/icons (default)
|
270
|
+
* *fas* - https://fontawesome.com/icons?d=gallery&s=solid[Font Awesome - Solid^]
|
271
|
+
* *fab* - https://fontawesome.com/icons?d=gallery&s=brands[Font Awesome - Brands^]
|
272
|
+
* *far* - https://fontawesome.com/icons?d=gallery&s=regular[Font Awesome - Regular^]
|
277
273
|
* *fi* - http://zurb.com/playground/foundation-icon-fonts-3[Foundation Icons^]
|
278
|
-
* *pf* -
|
274
|
+
* *pf* - https://paymentfont.com/[Payment font^]
|
275
|
+
|
276
|
+
The fa icon set is deprecated.
|
277
|
+
Please use one of the other three FontAwesome icon sets.
|
279
278
|
|
280
279
|
You can enable font-based icons by setting the following attribute in the header of your document:
|
281
280
|
|
@@ -292,7 +291,7 @@ If you want to override the font set globally, also set the `icon-set` attribute
|
|
292
291
|
:icon-set: pf
|
293
292
|
----
|
294
293
|
|
295
|
-
Here's an example that shows how to use the Amazon icon from the payment font (pf) icon set in a sentence:
|
294
|
+
Here's an example that shows how to use the Amazon icon from the payment font (pf) icon set in a sentence (assuming the `icon-set` is set to `pf):
|
296
295
|
|
297
296
|
[source,asciidoc]
|
298
297
|
----
|
@@ -306,6 +305,13 @@ You can use the `set` attribute on the icon macro to override the icon set for a
|
|
306
305
|
Available now at icon:amazon[set=pf].
|
307
306
|
----
|
308
307
|
|
308
|
+
You can also specify the font set using the following shorthand.
|
309
|
+
|
310
|
+
[source,asciidoc]
|
311
|
+
----
|
312
|
+
Available now at icon:amazon@pf[].
|
313
|
+
----
|
314
|
+
|
309
315
|
In addition to the sizes supported in the HTML backend (lg, 1x, 2x, etc), you can enter any relative value in the size attribute (e.g., 1.5em, 150%, etc).
|
310
316
|
|
311
317
|
[source,asciidoc]
|
@@ -315,21 +321,37 @@ icon:android[size=40em]
|
|
315
321
|
|
316
322
|
You can enable use of fonts during PDF generation (instead of in the document header) by passing the `icons` attribute to the `asciidoctor-pdf` command.
|
317
323
|
|
318
|
-
$ asciidoctor-pdf -a icons=font -a icon-set=
|
324
|
+
$ asciidoctor-pdf -a icons=font -a icon-set=pf sample.adoc
|
319
325
|
|
320
326
|
Icon-based fonts are handled by the `prawn-icon` gem.
|
321
327
|
To find a complete list of available icons, consult the https://github.com/jessedoyle/prawn-icon/tree/master/data/fonts[prawn-icon] repository.
|
322
328
|
|
323
329
|
== Image Paths
|
324
330
|
|
325
|
-
|
331
|
+
Relative images paths are resolved relative to the value of the `imagesdir` attribute at the time the converter is run.
|
326
332
|
This is effectively the same as how the built-in HTML converter works when the `data-uri` attribute is set.
|
327
|
-
The `imagesdir` is blank by default, which means images are resolved relative to the input document.
|
333
|
+
The `imagesdir` is blank by default, which means relative images paths are resolved relative to the input document.
|
334
|
+
Absolute image paths are used as is.
|
328
335
|
|
329
336
|
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.
|
330
337
|
|
331
338
|
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.
|
332
339
|
|
340
|
+
If the image is an SVG and that SVG links to another image, the linked image will be resolved using the same rules as the original image.
|
341
|
+
However, note that a width and height must be specified on the linked image or else the SVG library will fail to process it.
|
342
|
+
|
343
|
+
=== Asciidoctor Diagram Integration
|
344
|
+
|
345
|
+
As of Asciidoctor PDF 1.5.0.alpha.17 running on Asciidoctor 2 or better, Asciidoctor PDF provides better integration with Asciidoctor Diagram by setting the `data-uri` attribute by default.
|
346
|
+
When the `data-uri` attribute is set, Asciidoctor Diagram returns the absolute path to the generated image, which Asciidoctor PDF can then locate.
|
347
|
+
(This makes sense since technically, Asciidoctor Diagram must embed the image in the document, similar in spirit to the `data-uri` feature for HTML).
|
348
|
+
This means the input directory and the output directory (and thus the imagesoutdir) can differ and Asciidoctor PDF will still be able to locate the generate image.
|
349
|
+
|
350
|
+
Prior to Asciidoctor PDF 1.5.0.alpha.17 (or prior to Asciidoctor 2), the way to solve this problem is to set the `imagesdir` attribute to an absolute path.
|
351
|
+
That way, it won't matter where the generated image is written.
|
352
|
+
Asciidoctor PDF will still be able to find it.
|
353
|
+
Keep in mind that this strategy may introduce other side effects you'll have to work around.
|
354
|
+
|
333
355
|
== Image Scaling
|
334
356
|
|
335
357
|
Since PDF is a fixed-width canvas, you almost always need to specify a width to get the image to fit properly on the page.
|
@@ -366,6 +388,9 @@ The image is always sized according to the explicit or intrinsic width and its h
|
|
366
388
|
The height of the image is ignored by the PDF converter unless the height of the image exceeds the content height of the page.
|
367
389
|
In this case, the image is scaled down to fit on a single page.
|
368
390
|
|
391
|
+
If you want a block image to align to the boundaries of the page (not the content margin), specify the `align-to-page` option (e.g., `opts="align-to-page"`).
|
392
|
+
This is most useful when using vw units because you can make the image cover the entire width of the page.
|
393
|
+
|
369
394
|
Images in running content also support the `fit` attribute.
|
370
395
|
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.
|
371
396
|
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.
|
@@ -513,9 +538,6 @@ require 'asciidoctor-mathematical'
|
|
513
538
|
Asciidoctor.convert_file 'sample.adoc', safe: :safe
|
514
539
|
----
|
515
540
|
|
516
|
-
CAUTION: Asciidoctor Mathematical does not currently process STEM blocks and inline macros inside AsciiDoc table cells or STEM inline macros in normal table cells.
|
517
|
-
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.
|
518
|
-
|
519
541
|
To get the best quality equations, and the maximize speed of conversion, we recommend configuring Asciidoctor Mathematical to convert equations to SVG.
|
520
542
|
You control this setting using the `mathematical-format` AsciiDoc attribute:
|
521
543
|
|
@@ -523,6 +545,41 @@ You control this setting using the `mathematical-format` AsciiDoc attribute:
|
|
523
545
|
|
524
546
|
Refer to the {uri-asciidoctor-mathematical}#readme[README] for Asciidoctor Mathematical to learn about additional settings and options.
|
525
547
|
|
548
|
+
== Skipping Passthrough Content
|
549
|
+
|
550
|
+
Asciidoctor PDF does not support arbitrary passthrough content.
|
551
|
+
While the basebackend for the PDF converter is html, it only recognizes a limited subset of inline HTML elements that can be mapped to PDF (e.g., a, strong, em, code, ).
|
552
|
+
Therefore, if your content contains passthrough blocks or inlines, you most likely have to use a conditional preprocessor to skip them (and make other arrangements).
|
553
|
+
|
554
|
+
Here's an example of how to skip a passthrough block when converting to PDF:
|
555
|
+
|
556
|
+
[source,asciidoc]
|
557
|
+
----
|
558
|
+
\ifndef::backend-pdf[]
|
559
|
+
<script>
|
560
|
+
//...
|
561
|
+
</script>
|
562
|
+
\endif::[]
|
563
|
+
----
|
564
|
+
|
565
|
+
Here's an example of how to only enable a passthrough block when convertering to HTML5:
|
566
|
+
|
567
|
+
[source,asciidoc]
|
568
|
+
----
|
569
|
+
\ifdef::backend-html5[]
|
570
|
+
<script>
|
571
|
+
//...
|
572
|
+
</script>
|
573
|
+
\endif::[]
|
574
|
+
----
|
575
|
+
|
576
|
+
== Shaded Blocks and Performance
|
577
|
+
|
578
|
+
Certain blocks are rendered with a shaded background, such as verbatim (listing, literal, and source), sidebar, and example blocks.
|
579
|
+
In order to calculate the dimensions of the shaded region, Asciidoctor PDF has to "`dry run`" the block to determine how many pages it consumes.
|
580
|
+
While this strategy has a low impact when processing shorter blocks, it can drastically deteriorate performance when processing a block that spans dozens of pages.
|
581
|
+
As a general rule of thumb, you should avoid using shaded blocks which span more than a handful of pages.
|
582
|
+
|
526
583
|
== Autofitting Text
|
527
584
|
|
528
585
|
Verbatim blocks often have long lines that don't fit within the fixed width of the PDF canvas.
|
@@ -569,6 +626,40 @@ Therefore, to print a range of pages as they are labeled in the document, you ne
|
|
569
626
|
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.
|
570
627
|
That's the range you need to enter into the print dialog.
|
571
628
|
|
629
|
+
== Table of Contents
|
630
|
+
|
631
|
+
The table of contents (TOC) is not included by default.
|
632
|
+
The TOC is only included if the `toc` attribute is set on the document.
|
633
|
+
|
634
|
+
The placement of the table of contents is fixed, and thus the value of the `toc` attribute is effectively ignored in this backend.
|
635
|
+
For documents that have the book doctype, the TOC is inserted using discrete pages between the title page and the first page of content.
|
636
|
+
For all other doctypes (unless the `title-page` attribute is set), the TOC is inserted in the flow of text in between the document title and the first block of content.
|
637
|
+
|
638
|
+
While the table of contents is not included by default, the PDF outline is always included.
|
639
|
+
The `toclevels` attribute controls the depth of both the TOC and the PDF outline (regardless of whether the TOC is enabled).
|
640
|
+
|
641
|
+
NOTE: If a document that has the book doctype includes a preface, an entry for the preface is only included in the TOC if the `preface-title` is assigned a value (e.g., `preface-title=Preface`).
|
642
|
+
This value is used as the heading of the preface and as the text of the entry in the TOC.
|
643
|
+
|
644
|
+
== Index Catalog
|
645
|
+
|
646
|
+
Asciidoctor PDF supports generating an index catalog that itemizes all index terms defined in the document, allowing the reader to navigate the document by keyword.
|
647
|
+
|
648
|
+
To get Asciidoctor PDF to generate an index, simply add an level-1 section flagged with the `index` style near the end of your document.
|
649
|
+
The converter will automatically populate the catalog with the list of index terms in the document, organized by first letter.
|
650
|
+
|
651
|
+
[source,asciidoc]
|
652
|
+
----
|
653
|
+
[index]
|
654
|
+
= Index
|
655
|
+
----
|
656
|
+
|
657
|
+
You can use any text you want for the title of the section.
|
658
|
+
The only restriction is that no index terms may be defined below this section.
|
659
|
+
|
660
|
+
NOTE: Although the catalog is generated automatically, you have to mark the index terms manually.
|
661
|
+
However, you could use an extension, such as a TreeProcessor, to automatically mark index terms.
|
662
|
+
|
572
663
|
== Optional Scripts
|
573
664
|
|
574
665
|
{project-name} also provides a shell script that invokes GhostScript (`gs`) to optimize and compress the generated PDF with minimal impact on quality.
|
@@ -578,7 +669,7 @@ Here's an example usage:
|
|
578
669
|
|
579
670
|
$ ./bin/optimize-pdf basic-example.pdf
|
580
671
|
|
581
|
-
The command will generate the file [
|
672
|
+
The command will generate the file [.path]_example-optimized.pdf_ in the current directory.
|
582
673
|
|
583
674
|
WARNING: The `optimize-pdf` script currently requires a Bash shell (Linux, OSX, etc).
|
584
675
|
We plan to rewrite the script in Ruby so it works across platforms (see https://github.com/asciidoctor/asciidoctor-pdf/issues/1[issue #1])
|
@@ -591,11 +682,14 @@ If a file is found with the extension `.pdfmark` and the same rootname as the in
|
|
591
682
|
This file is necessary to preserve the document metadata since Ghostscript will otherwise drop it.
|
592
683
|
That's why {project-name} always creates this file in addition to the PDF.
|
593
684
|
|
685
|
+
ifndef::env-site[]
|
594
686
|
== Contributing
|
595
687
|
|
596
688
|
In the spirit of free software, _everyone_ is encouraged to help improve this project.
|
597
689
|
|
598
690
|
To contribute code, simply fork the project on GitHub, hack away and send a pull request with your proposed changes.
|
691
|
+
*All pull requests must include a) tests that verify the code change and b) an entry in the CHANGELOG.adoc file to document what changed.*
|
692
|
+
If a pull request is missing tests or a CHANGELOG entry, *it will not be merged*.
|
599
693
|
|
600
694
|
Feel free to use the {uri-project-issues}[issue tracker] or {uri-project-list}[Asciidoctor mailing list] to provide feedback or suggestions in other ways.
|
601
695
|
|
@@ -634,11 +728,11 @@ We'll leverage the project configuration to install the necessary dependencies.
|
|
634
728
|
|
635
729
|
If you're using {uri-rvm}[RVM], we recommend creating a new gemset to work with {project-name}:
|
636
730
|
|
637
|
-
$ rvm use 2.
|
731
|
+
$ rvm use 2.5@asciidoctor-pdf --create
|
638
732
|
|
639
733
|
We like RVM because it keeps the dependencies required by various projects isolated.
|
640
734
|
|
641
|
-
The dependencies needed to use {project-name} are defined in the [
|
735
|
+
The dependencies needed to use {project-name} are defined in the [.path]_Gemfile_ at the root of the project.
|
642
736
|
We can use Bundler to install the dependencies for us.
|
643
737
|
|
644
738
|
To check you have Bundler available, use the `bundle` command to query the installed version:
|
@@ -653,16 +747,75 @@ Then use the `bundle` command to install the project dependencies:
|
|
653
747
|
|
654
748
|
$ bundle
|
655
749
|
|
656
|
-
NOTE: You need to call `bundle` from the project directory so that it can find the [
|
750
|
+
NOTE: You need to call `bundle` from the project directory so that it can find the [.path]_Gemfile_.
|
751
|
+
|
752
|
+
=== Run the Tests
|
753
|
+
|
754
|
+
Tests are written using RSpec.
|
755
|
+
To run the tests, simply invoke rspec via bundler.
|
756
|
+
|
757
|
+
$ bundle exec rspec
|
758
|
+
|
759
|
+
If you want to see the name of each test that is run, add the `-fd` option:
|
760
|
+
|
761
|
+
$ bundle exec rspec -fd
|
762
|
+
|
763
|
+
You can also use the provided Rake task (note the name difference):
|
764
|
+
|
765
|
+
$ bundle exec rake spec
|
766
|
+
|
767
|
+
Running tests using `rspec` directly gives you the advantage of being able to specify additional options.
|
657
768
|
|
769
|
+
To run a single test, you can filter by the name of the test.
|
770
|
+
For example, to run all tests that pertain to failures, use:
|
771
|
+
|
772
|
+
$ bundle exec rspec -e fail -fd
|
773
|
+
|
774
|
+
You can also run all tests in a given file by passing the file's path to rspec:
|
775
|
+
|
776
|
+
$ bundle exec rspec -fd spec/toc_spec.rb
|
777
|
+
|
778
|
+
For a full list of options that rspec provides, run `rspec -h`.
|
779
|
+
|
780
|
+
=== Run the Application (optional)
|
781
|
+
|
782
|
+
Like with Bundler, you have to run the application from the project directory.
|
658
783
|
Assuming all the required gems install properly, verify you can run the `asciidoctor-pdf` script using Ruby:
|
659
784
|
|
660
|
-
$ bundle exec
|
785
|
+
$ bundle exec asciidoctor-pdf -v
|
661
786
|
|
662
787
|
If you see the version of {project-name} printed, you're ready to use {project-name}!
|
663
788
|
|
664
|
-
|
665
|
-
|
789
|
+
You can use the application to convert a document as follows:
|
790
|
+
|
791
|
+
$ bundle exec asciidoctor-pdf /path/to/sample.adoc
|
792
|
+
|
793
|
+
endif::[]
|
794
|
+
|
795
|
+
=== Test a Pull Request
|
796
|
+
|
797
|
+
To test a pull request (PR), you first need to fetch the branch that contains the change and switch to it.
|
798
|
+
The steps below are covered in detail in the https://help.github.com/articles/checking-out-pull-requests-locally[GitHub help].
|
799
|
+
|
800
|
+
Let's assume you want to test PR 955.
|
801
|
+
Here's how you fetch and switch to it:
|
802
|
+
|
803
|
+
$ git fetch origin pull/955/head:pr-955-review
|
804
|
+
git checkout pr-955-review
|
805
|
+
|
806
|
+
IMPORTANT: Make sure you replace the number with the number of the PR you want to test.
|
807
|
+
|
808
|
+
In case any dependencies have changed, you should run the `bundle` command again:
|
809
|
+
|
810
|
+
$ bundle
|
811
|
+
|
812
|
+
Now you can run the application as modified by the PR:
|
813
|
+
|
814
|
+
$ bundle exec asciidoctor-pdf /path/to/sample.adoc
|
815
|
+
|
816
|
+
To switch back to master, just type:
|
817
|
+
|
818
|
+
$ git checkout master
|
666
819
|
|
667
820
|
[[resources,Links]]
|
668
821
|
== Resources
|
@@ -675,7 +828,7 @@ For best results, be sure to always use `bundle exec` whenever invoking the `./b
|
|
675
828
|
|
676
829
|
== Copyright
|
677
830
|
|
678
|
-
Copyright (C) 2014-
|
831
|
+
Copyright (C) 2014-2019 OpenDevise Inc. and the Asciidoctor Project.
|
679
832
|
Free use of this software is granted under the terms of the MIT License.
|
680
833
|
|
681
834
|
For the full text of the license, see the <<LICENSE#,LICENSE>> file.
|