asciidoctor-pdf 1.5.0.alpha.9 → 1.5.0.alpha.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.adoc +1 -1
- data/NOTICE.adoc +2 -2
- data/README.adoc +67 -13
- data/docs/theming-guide.adoc +40 -11
- data/lib/asciidoctor-pdf/asciidoctor_ext/list.rb +1 -1
- data/lib/asciidoctor-pdf/asciidoctor_ext/list_item.rb +2 -2
- data/lib/asciidoctor-pdf/converter.rb +58 -20
- data/lib/asciidoctor-pdf/pdfmarks.rb +1 -0
- data/lib/asciidoctor-pdf/prawn_ext/coderay_encoder.rb +2 -1
- data/lib/asciidoctor-pdf/prawn_ext/extensions.rb +13 -8
- data/lib/asciidoctor-pdf/theme_loader.rb +8 -3
- data/lib/asciidoctor-pdf/version.rb +1 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03d9ab43813f8db41152d4b2d0004aaa5c6fdf08
|
4
|
+
data.tar.gz: 85f3a33dd273be7f2a3c96e57970243d28c6c3eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6fb7d474c712cc68dc57d9a7bd1e6f6c6e0804d42d53a90a4f452a4ce6da40b12f74ef50db6b88a62aa1b1649210ad6a7f7f8685235c3304765bceac4adaecb
|
7
|
+
data.tar.gz: 4b8d0b17b2ab5d015b586a8f2d1754c6ca97c4f7beee7645e343667e5adad634bb3b3d66592a87ce89448861c45817c37ec4825beeef927297c3ab9cc37d1fee
|
data/LICENSE.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
.The MIT License
|
2
2
|
....
|
3
|
-
Copyright (C) 2014 OpenDevise Inc. and the Asciidoctor Project
|
3
|
+
Copyright (C) 2014-2015 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/NOTICE.adoc
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= Asciidoctor PDF
|
2
2
|
OpenDevise Inc.; Asciidoctor Project
|
3
3
|
|
4
|
-
Copyright (C) 2014 OpenDevise Inc. and the Asciidoctor Project.
|
4
|
+
Copyright (C) 2014-2015 OpenDevise Inc. and the Asciidoctor Project.
|
5
5
|
|
6
6
|
Please visit the Asciidoctor project site for more information:
|
7
7
|
|
@@ -71,6 +71,6 @@ PrawnCodeRayEncoder class::
|
|
71
71
|
- https://github.com/prawnpdf/prawn
|
72
72
|
|
73
73
|
Bootstrap (v3.0.3)::
|
74
|
-
The default theme is
|
74
|
+
The default theme is inspired by Bootstrap 3.0.3.
|
75
75
|
|
76
76
|
- http://getbootstrap.com
|
data/README.adoc
CHANGED
@@ -1,20 +1,22 @@
|
|
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.10, 2015-11-01
|
3
4
|
// Settings:
|
4
5
|
:compat-mode!:
|
5
6
|
:experimental:
|
6
7
|
:idprefix:
|
7
8
|
:idseparator: -
|
8
9
|
:icons: font
|
10
|
+
ifdef::env-github,env-browser[:outfilesuffix: .adoc]
|
9
11
|
:pagenums:
|
10
|
-
ifdef::env-github[:relfileprefix: /blob/master]
|
11
|
-
ifdef::env-browser[:toc: preamble]
|
12
12
|
//:pdf-page-size: [8.25in, 11.69in]
|
13
13
|
//:pdf-page-size: A4
|
14
|
+
ifdef::env-browser[:toc: preamble]
|
14
15
|
// Aliases:
|
15
16
|
:project-name: Asciidoctor PDF
|
16
17
|
:project-handle: asciidoctor-pdf
|
17
18
|
// URIs:
|
19
|
+
//ifdef::env-github[:relfileprefix: /blob/master/]
|
18
20
|
:uri-project: https://github.com/asciidoctor/asciidoctor-pdf
|
19
21
|
:uri-project-repo: {uri-project}
|
20
22
|
:uri-project-issues: {uri-project-repo}/issues
|
@@ -23,10 +25,6 @@ ifdef::env-browser[:toc: preamble]
|
|
23
25
|
:uri-rvm: http://rvm.io
|
24
26
|
:uri-asciidoctor: http://asciidoctor.org
|
25
27
|
|
26
|
-
// FIXME See last line; Asciidoctor should only be using outfilesuffix defined in header
|
27
|
-
:original-outfilesuffix: {outfilesuffix}
|
28
|
-
:outfilesuffix: .adoc
|
29
|
-
|
30
28
|
_Lo and behold_, a native PDF converter for AsciiDoc built with {uri-asciidoctor}[Asciidoctor] and {uri-prawn}[Prawn]! +
|
31
29
|
_No more middleman._ +
|
32
30
|
_No more DocBook toolchain._ +
|
@@ -43,7 +41,7 @@ See the milestone v1.5.0 in the {uri-project-issues}[issue tracker] for details.
|
|
43
41
|
And what a gem it is!
|
44
42
|
|
45
43
|
{uri-prawn}[Prawn] is a nimble PDF writer for Ruby.
|
46
|
-
More important, it's a hackable platform that offers both high level APIs for the most common needs and low level APIs for bending the document model to
|
44
|
+
More important, it's a hackable platform that offers both high level APIs for the most common needs and low level APIs for bending the document model to accommodate special circumstances.
|
47
45
|
|
48
46
|
With Prawn, you can write text, draw lines and shapes and place images _anywhere_ on the page and add as much color as you like.
|
49
47
|
In addition, it brings a fluent API and aggressive code re-use to the printable document space.
|
@@ -84,7 +82,7 @@ Picking up from there, {project-name} takes the pain out of creating PDF documen
|
|
84
82
|
* “Keep together” blocks (i.e., page breaks avoided in certain block content)
|
85
83
|
* Orphan section titles avoided
|
86
84
|
* Table border settings honored
|
87
|
-
* Font-based icons
|
85
|
+
* Font-based icons
|
88
86
|
* Custom fonts
|
89
87
|
|
90
88
|
=== Missing features
|
@@ -131,6 +129,13 @@ Choose one (or more) of the following:
|
|
131
129
|
|
132
130
|
.Pygments
|
133
131
|
$ gem install pygments.rb
|
132
|
+
|
133
|
+
You then activate syntax highlighting for a given document by adding the following attribute to the document header (CodeRay shown):
|
134
|
+
|
135
|
+
[source,asciidoc]
|
136
|
+
----
|
137
|
+
:source-highlighter: coderay
|
138
|
+
----
|
134
139
|
|
135
140
|
Assuming all the required gems install properly, verify you can run the `asciidoctor-pdf` script:
|
136
141
|
|
@@ -159,7 +164,7 @@ It's time to convert the AsciiDoc document directly to PDF.
|
|
159
164
|
|
160
165
|
=== Convert AsciiDoc to PDF
|
161
166
|
|
162
|
-
IMPORTANT: You'll need
|
167
|
+
IMPORTANT: You'll need the `coderay` gem installed to run this example since it uses the `source-highlighter` attribute with the value of `coderay`.
|
163
168
|
|
164
169
|
Converting to PDF is a simple as running the `asciidoctor-pdf` script using Ruby and passing our AsciiDoc document as the first argument.
|
165
170
|
|
@@ -185,6 +190,58 @@ The layout and styling of the PDF is driven by a YAML configuration file.
|
|
185
190
|
To learn how the theming system works and how to create and apply custom themes, refer to the <<docs/theming-guide.adoc#,Asciidoctor PDF Theme Guide>>.
|
186
191
|
You can use the built-in theme files, which you can find in the [file]_data/themes_ directory, as examples.
|
187
192
|
|
193
|
+
== Font-based Icons
|
194
|
+
|
195
|
+
You can use icons in your PDF document using any of the following icon sets:
|
196
|
+
|
197
|
+
* *fa* - https://fortawesome.github.io/Font-Awesome/[Font Awesome^] (default)
|
198
|
+
* *octicon* - https://octicons.github.com/[Octicons^]
|
199
|
+
* *fi* - http://zurb.com/playground/foundation-icon-fonts-3[Foundation Icons^]
|
200
|
+
* *pf* - http://paymentfont.io/[Payment font^]
|
201
|
+
|
202
|
+
You can enable font-based icons by setting the following attribute in the header of your document:
|
203
|
+
|
204
|
+
[source,asciidoc]
|
205
|
+
----
|
206
|
+
:icons: font
|
207
|
+
----
|
208
|
+
|
209
|
+
If you want to override the font set globally, also set the `icon-set` attribute:
|
210
|
+
|
211
|
+
[source,asciidoc]
|
212
|
+
----
|
213
|
+
:icons: font
|
214
|
+
:icon-set: pf
|
215
|
+
----
|
216
|
+
|
217
|
+
Here's an example that shows how to use the Amazon icon from the payment font (pf) icon set in a sentence:
|
218
|
+
|
219
|
+
[source,asciidoc]
|
220
|
+
----
|
221
|
+
Available now at icon:amazon[].
|
222
|
+
----
|
223
|
+
|
224
|
+
You can use the `set` attribute on the icon macro to override the icon set for a given icon.
|
225
|
+
|
226
|
+
[source,asciidoc]
|
227
|
+
----
|
228
|
+
Available now at icon:amazon[set=pf].
|
229
|
+
----
|
230
|
+
|
231
|
+
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).
|
232
|
+
|
233
|
+
[source,asciidoc]
|
234
|
+
----
|
235
|
+
icon:android[size=40em]
|
236
|
+
----
|
237
|
+
|
238
|
+
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.
|
239
|
+
|
240
|
+
$ asciidoctor-pdf -a icons=font -a icon-set=octicon sample.adoc
|
241
|
+
|
242
|
+
Icon-based fonts are handled by the `prawn-icon` gem.
|
243
|
+
To find a complete list of available icons, consult the https://github.com/jessedoyle/prawn-icon/tree/master/data/fonts[prawn-icon] repository.
|
244
|
+
|
188
245
|
== Optional scripts
|
189
246
|
|
190
247
|
{project-name} also provides a shell script that invokes GhostScript (`gs`) to optimize and compress the generated PDF with minimal impact on quality.
|
@@ -295,11 +352,8 @@ For best results, be sure to always use `bundle exec` whenever invoking the `./b
|
|
295
352
|
|
296
353
|
== Copyright
|
297
354
|
|
298
|
-
Copyright (C) 2014 OpenDevise Inc. and the Asciidoctor Project.
|
355
|
+
Copyright (C) 2014-2015 OpenDevise Inc. and the Asciidoctor Project.
|
299
356
|
Free use of this software is granted under the terms of the MIT License.
|
300
357
|
|
301
358
|
For the full text of the license, see the <<LICENSE.adoc#,LICENSE>> file.
|
302
359
|
Refer to the <<NOTICE.adoc#,NOTICE>> file for information about third-party Open Source software in use.
|
303
|
-
|
304
|
-
// FIXME Asciidoctor should be using outfilesuffix defined in header
|
305
|
-
:outfilesuffix: {original-outfilesuffix}
|
data/docs/theming-guide.adoc
CHANGED
@@ -459,7 +459,7 @@ title_page:
|
|
459
459
|
|
460
460
|
== Fonts
|
461
461
|
|
462
|
-
You can select from <<built-in-fonts,built-in PDF fonts>>, <<bundled-fonts,fonts bundled with Asciidoctor PDF>> or <<custom-fonts,custom fonts>> loaded from TrueType font (TTF) files.
|
462
|
+
You can select from <<built-in-afm-fonts,built-in PDF fonts>>, <<bundled-fonts,fonts bundled with Asciidoctor PDF>> or <<custom-fonts,custom fonts>> loaded from TrueType font (TTF) files.
|
463
463
|
If you want to use custom fonts, you must first declare them in your theme file.
|
464
464
|
|
465
465
|
=== Built-in (AFM) fonts
|
@@ -676,7 +676,7 @@ TBW
|
|
676
676
|
|
677
677
|
|page_background_image
|
678
678
|
|path (absolute or relative to pdf-stylesdir)
|
679
|
-
|
679
|
+
|+background_image: image:watermark.png[]+
|
680
680
|
|
681
681
|
|page_layout
|
682
682
|
|portrait, landscape +
|
@@ -885,7 +885,7 @@ The literal key is used for inline monospaced text in prose and table cells.
|
|
885
885
|
|
886
886
|
|title_page_background_image
|
887
887
|
|path (absolute or relative to pdf-stylesdir)
|
888
|
-
|
888
|
+
|+background_image: image:title.png[]+
|
889
889
|
|
890
890
|
|title_page_logo_align
|
891
891
|
|left, center, right
|
@@ -893,7 +893,7 @@ The literal key is used for inline monospaced text in prose and table cells.
|
|
893
893
|
|
894
894
|
|title_page_logo_image
|
895
895
|
|inline image macro
|
896
|
-
|
896
|
+
|+logo_image: image:logo.png[scaledwidth=25%]+
|
897
897
|
|
898
898
|
|title_page_logo_top
|
899
899
|
|percentage
|
@@ -1135,6 +1135,14 @@ Block styles are applied to the following block types:
|
|
1135
1135
|
|<<colors,color>>
|
1136
1136
|
|background_color: #eeeeee
|
1137
1137
|
|
1138
|
+
|sidebar_padding
|
1139
|
+
|<<measurement-units,measurement>>, <<measurement-units,measurement array [4]>>
|
1140
|
+
|padding: [12, 15, 0, 15]
|
1141
|
+
|
1142
|
+
|sidebar_title_align
|
1143
|
+
|left, center, right, justify
|
1144
|
+
|title_align: center
|
1145
|
+
|
1138
1146
|
|sidebar_title_font_color
|
1139
1147
|
|<<colors,color>>
|
1140
1148
|
|title_font_color: #333333
|
@@ -1150,10 +1158,6 @@ Block styles are applied to the following block types:
|
|
1150
1158
|
|sidebar_title_font_style
|
1151
1159
|
|normal, italic, bold, bold_italic
|
1152
1160
|
|title_font_style: bold
|
1153
|
-
|
1154
|
-
|sidebar_title_align
|
1155
|
-
|left, center, right, justify
|
1156
|
-
|title_align: center
|
1157
1161
|
|===
|
1158
1162
|
|
1159
1163
|
=== Example
|
@@ -1192,8 +1196,25 @@ Block styles are applied to the following block types:
|
|
1192
1196
|
|admonition_border_width
|
1193
1197
|
|<<values,number>>
|
1194
1198
|
|border_width: 0.5
|
1199
|
+
|
1200
|
+
|admonition_icon_<name>_name^[1]^
|
1201
|
+
|string^[2]^
|
1202
|
+
|admonition_icon_tip_name: fa-fire
|
1203
|
+
|
1204
|
+
|admonition_icon_<name>_stroke_color
|
1205
|
+
|<<colors,color>>
|
1206
|
+
|admonition_icon_tip_stroke_color: ff0000
|
1207
|
+
|
1208
|
+
|admonition_icon_<name>_size
|
1209
|
+
|<<values,number>> +
|
1210
|
+
(default: 24)
|
1211
|
+
|admonition_icon_tip_size: 24
|
1195
1212
|
|===
|
1196
1213
|
|
1214
|
+
^[1]^ `<name>` can be `note`, `tip`, `warning`, `important` or `caution`. +
|
1215
|
+
^[2]^ See the `.yml` files in the https://github.com/jessedoyle/prawn-icon/tree/master/data/fonts[prawn-icon repository] for a list of valid names.
|
1216
|
+
The prefix (e.g., `fa-`) determines which font set to use.
|
1217
|
+
|
1197
1218
|
=== Image
|
1198
1219
|
|
1199
1220
|
[cols="3,3,5m"]
|
@@ -1544,9 +1565,10 @@ NOTE: If content is not specified for the running footer, the page number (i.e.,
|
|
1544
1565
|
NOTE: The background color spans the width of the page.
|
1545
1566
|
When a background color is specified, the border also spans the width of the page.
|
1546
1567
|
|
1547
|
-
====
|
1568
|
+
==== Attribute references
|
1548
1569
|
|
1549
|
-
|
1570
|
+
You can use _any_ attribute defined in your AsciiDoc document in the content of the running header and footer.
|
1571
|
+
In addition, the following attributes are also available when defining the content keys in the footer:
|
1550
1572
|
|
1551
1573
|
* page-count
|
1552
1574
|
* page-number
|
@@ -1556,10 +1578,17 @@ In addition to the document-level attributes defined in the AsciiDoc document, t
|
|
1556
1578
|
* section-title
|
1557
1579
|
* section-or-chapter-title
|
1558
1580
|
|
1559
|
-
Here's an example that shows how
|
1581
|
+
Here's an example that shows how attributes can be used in the running footer:
|
1560
1582
|
|
1561
1583
|
[source,yaml]
|
1562
1584
|
----
|
1585
|
+
header:
|
1586
|
+
height: 0.75in
|
1587
|
+
line_height: 1
|
1588
|
+
recto_content:
|
1589
|
+
center: 'v{revnumber}, {docdate}'
|
1590
|
+
verso_content:
|
1591
|
+
center: $header_recto_content
|
1563
1592
|
footer:
|
1564
1593
|
height: 0.75in
|
1565
1594
|
line_height: 1
|
@@ -5,12 +5,12 @@ class Asciidoctor::ListItem
|
|
5
5
|
# Return false if the list item contains no blocks or it contains a nested outline list. Otherwise, return true.
|
6
6
|
def complex?
|
7
7
|
!simple?
|
8
|
-
end
|
8
|
+
end unless respond_to? :complex?
|
9
9
|
|
10
10
|
# Check whether this list item has simple content (i.e., no nested blocks aside from an outline list).
|
11
11
|
#
|
12
12
|
# Return true if the list item contains no blocks or it contains a nested outline list. Otherwise, return false.
|
13
13
|
def simple?
|
14
14
|
@blocks.empty? || (@blocks.size == 1 && ::Asciidoctor::List === (blk = @blocks[0]) && blk.outline?)
|
15
|
-
end
|
15
|
+
end unless respond_to? :simple?
|
16
16
|
end
|
@@ -33,13 +33,14 @@ class Converter < ::Prawn::Document
|
|
33
33
|
|
34
34
|
AsciidoctorVersion = ::Gem::Version.create ::Asciidoctor::VERSION
|
35
35
|
AdmonitionIcons = {
|
36
|
-
caution: {
|
37
|
-
important: {
|
38
|
-
note: {
|
39
|
-
tip: {
|
40
|
-
warning: {
|
36
|
+
caution: { name: 'fa-fire', stroke_color: 'BF3400', size: 24 },
|
37
|
+
important: { name: 'fa-exclamation-circle', stroke_color: 'BF0000', size: 24 },
|
38
|
+
note: { name: 'fa-info-circle', stroke_color: '19407C', size: 24 },
|
39
|
+
tip: { name: 'fa-lightbulb-o', stroke_color: '111111', size: 24 },
|
40
|
+
warning: { name: 'fa-exclamation-triangle', stroke_color: 'BF6900', size: 24 }
|
41
41
|
}
|
42
42
|
Alignments = [:left, :center, :right]
|
43
|
+
AlignmentNames = ['left', 'center', 'right']
|
43
44
|
EOL = %(\n)
|
44
45
|
TAB = %(\t)
|
45
46
|
InnerIndent = %(\n )
|
@@ -172,16 +173,18 @@ class Converter < ::Prawn::Document
|
|
172
173
|
(0..-1)
|
173
174
|
end
|
174
175
|
|
175
|
-
|
176
|
-
|
176
|
+
if page_count > num_front_matter_pages
|
177
|
+
layout_running_content :header, doc, skip: num_front_matter_pages unless doc.noheader
|
178
|
+
layout_running_content :footer, doc, skip: num_front_matter_pages unless doc.nofooter
|
179
|
+
end
|
177
180
|
|
178
181
|
add_outline doc, num_toc_levels, toc_page_nums, num_front_matter_pages
|
179
|
-
|
182
|
+
# TODO allow document (or theme) to override initial view magnification
|
183
|
+
# NOTE add 1 to page height to force initial scroll to 0; a nil value also seems to work
|
184
|
+
catalog.data[:OpenAction] = dest_fit_horizontally (page_height + 1), state.pages[0] if state.pages.size > 0
|
185
|
+
catalog.data[:ViewerPreferences] = { DisplayDocTitle: true }
|
180
186
|
|
181
187
|
layout_cover_page :back, doc
|
182
|
-
|
183
|
-
# NOTE we have to init pdfmarks here while we have a reference to the doc
|
184
|
-
@pdfmarks = Pdfmarks.new doc
|
185
188
|
end
|
186
189
|
|
187
190
|
# NOTE embedded only makes sense if perhaps we are building
|
@@ -208,6 +211,8 @@ class Converter < ::Prawn::Document
|
|
208
211
|
@font_color = theme.base_font_color
|
209
212
|
@text_transform = nil
|
210
213
|
@stamps = {}
|
214
|
+
# NOTE we have to init pdfmarks here while we have a reference to the doc
|
215
|
+
@pdfmarks = (doc.attr? 'pdfmarks') ? (Pdfmarks.new doc) : nil
|
211
216
|
init_scratch_prototype
|
212
217
|
self
|
213
218
|
end
|
@@ -430,8 +435,13 @@ class Converter < ::Prawn::Document
|
|
430
435
|
# FIXME HACK make title in this location look right
|
431
436
|
label_margin_top = node.title? ? @theme.caption_margin_inside : 0
|
432
437
|
if icons
|
433
|
-
|
434
|
-
icon
|
438
|
+
icon_data = admonition_icon_data label
|
439
|
+
icon icon_data[:name], {
|
440
|
+
valign: :center,
|
441
|
+
align: :center,
|
442
|
+
color: icon_data[:stroke_color],
|
443
|
+
size: (fit_icon_size node, icon_data[:size])
|
444
|
+
}
|
435
445
|
else
|
436
446
|
layout_prose label, valign: :center, style: :bold, line_height: 1, margin_top: label_margin_top, margin_bottom: 0
|
437
447
|
end
|
@@ -603,6 +613,11 @@ class Converter < ::Prawn::Document
|
|
603
613
|
|
604
614
|
def convert_dlist node
|
605
615
|
add_dest_for_block node if node.id
|
616
|
+
|
617
|
+
# TODO check if we're within one line of the bottom of the page
|
618
|
+
# and advance to the next page if so (similar to logic for section titles)
|
619
|
+
layout_caption node.title if node.title?
|
620
|
+
|
606
621
|
node.items.each do |terms, desc|
|
607
622
|
terms = [*terms]
|
608
623
|
# NOTE don't orphan the terms, allow for at least one line of content
|
@@ -677,6 +692,10 @@ class Converter < ::Prawn::Document
|
|
677
692
|
end
|
678
693
|
|
679
694
|
def convert_outline_list node
|
695
|
+
# TODO check if we're within one line of the bottom of the page
|
696
|
+
# and advance to the next page if so (similar to logic for section titles)
|
697
|
+
layout_caption node.title if node.title?
|
698
|
+
|
680
699
|
line_metrics = calc_line_metrics @theme.base_line_height
|
681
700
|
complex = false
|
682
701
|
# ...or if we want to give all items in the list the same treatment
|
@@ -847,6 +866,7 @@ class Converter < ::Prawn::Document
|
|
847
866
|
rendered_h = available_height
|
848
867
|
# FIXME workaround to fix Prawn not adding fill and stroke commands
|
849
868
|
# on page that only has an image; breakage occurs when line numbers are added
|
869
|
+
# NOTE this no longer seems to be an issue
|
850
870
|
fill_color self.fill_color
|
851
871
|
stroke_color self.stroke_color
|
852
872
|
end
|
@@ -1074,7 +1094,7 @@ class Converter < ::Prawn::Document
|
|
1074
1094
|
end
|
1075
1095
|
|
1076
1096
|
# Adds guards to preserve indentation
|
1077
|
-
def guard_indentation fragments
|
1097
|
+
def guard_indentation fragments
|
1078
1098
|
start_of_line = true
|
1079
1099
|
fragments.each do |fragment|
|
1080
1100
|
next if (text = fragment[:text]).empty?
|
@@ -1216,11 +1236,20 @@ class Converter < ::Prawn::Document
|
|
1216
1236
|
column_widths = []
|
1217
1237
|
else
|
1218
1238
|
table_width = bounds.width * ((node.attr 'tablepcwidth') / 100.0)
|
1219
|
-
|
1239
|
+
even_column_pct = 100.0 / node.columns.size
|
1240
|
+
column_widths = node.columns.map {|col| ((col.attr 'colpcwidth', even_column_pct) * table_width) / 100.0 }
|
1241
|
+
end
|
1242
|
+
|
1243
|
+
if ((position = node.attr 'align') && (AlignmentNames.include? position)) ||
|
1244
|
+
(position = (node.roles & AlignmentNames).last)
|
1245
|
+
position = position.to_sym
|
1246
|
+
else
|
1247
|
+
position = :left
|
1220
1248
|
end
|
1221
1249
|
|
1222
1250
|
table_settings = {
|
1223
1251
|
header: table_header,
|
1252
|
+
position: position,
|
1224
1253
|
cell_style: {
|
1225
1254
|
padding: theme.table_cell_padding,
|
1226
1255
|
border_width: 0,
|
@@ -1583,7 +1612,7 @@ class Converter < ::Prawn::Document
|
|
1583
1612
|
go_to_page page_count if position == :back
|
1584
1613
|
if cover_image.downcase.end_with? '.pdf'
|
1585
1614
|
# NOTE import_page automatically advances to next page afterwards
|
1586
|
-
import_page cover_image
|
1615
|
+
import_page cover_image, advance: position != :back
|
1587
1616
|
else
|
1588
1617
|
image_page cover_image, canvas: true
|
1589
1618
|
end
|
@@ -1685,6 +1714,7 @@ class Converter < ::Prawn::Document
|
|
1685
1714
|
|
1686
1715
|
def layout_toc doc, num_levels = 2, toc_page_number = 2, num_front_matter_pages = 0
|
1687
1716
|
go_to_page toc_page_number unless (page_number == toc_page_number) || scratch?
|
1717
|
+
start_page_number = page_number
|
1688
1718
|
theme_font :heading, level: 2 do
|
1689
1719
|
layout_heading doc.attr('toc-title')
|
1690
1720
|
end
|
@@ -1698,7 +1728,8 @@ class Converter < ::Prawn::Document
|
|
1698
1728
|
end
|
1699
1729
|
layout_toc_level doc.sections, num_levels, line_metrics, dot_width, num_front_matter_pages
|
1700
1730
|
end
|
1701
|
-
|
1731
|
+
# NOTE range must be calculated relative to toc_page_number; absolute page number in scratch document is arbitrary
|
1732
|
+
toc_page_numbers = (toc_page_number..(toc_page_number + (page_number - start_page_number)))
|
1702
1733
|
go_to_page page_count - 1 unless scratch?
|
1703
1734
|
toc_page_numbers
|
1704
1735
|
end
|
@@ -1746,9 +1777,16 @@ class Converter < ::Prawn::Document
|
|
1746
1777
|
|
1747
1778
|
# Reduce icon size to fit inside bounds.height. Icons will not render
|
1748
1779
|
# properly if they are larger than the current bounds.height.
|
1749
|
-
def
|
1750
|
-
min_height = bounds.height.floor
|
1751
|
-
|
1780
|
+
def fit_icon_size node, max_size = 24
|
1781
|
+
(min_height = bounds.height.floor) < max_size ? min_height : max_size
|
1782
|
+
end
|
1783
|
+
|
1784
|
+
def admonition_icon_data key
|
1785
|
+
if (icon_data = @theme[%(admonition_icon_#{key})])
|
1786
|
+
AdmonitionIcons[key].merge icon_data
|
1787
|
+
else
|
1788
|
+
AdmonitionIcons[key]
|
1789
|
+
end
|
1752
1790
|
end
|
1753
1791
|
|
1754
1792
|
# TODO delegate to layout_page_header and layout_page_footer per page
|
@@ -86,7 +86,8 @@ class CodeRayEncoder < ::CodeRay::Encoders::Encoder
|
|
86
86
|
if text == EOL
|
87
87
|
@out << { text: text }
|
88
88
|
@start_of_line = true
|
89
|
-
|
89
|
+
# NOTE text is nil and kind is :error when CodeRay ends parsing on an error
|
90
|
+
elsif text
|
90
91
|
# NOTE add guard character to prevent Prawn from trimming indentation
|
91
92
|
text[0] = GuardedIndent if @start_of_line && (text.start_with? ' ')
|
92
93
|
text.gsub! InnerIndent, GuardedInnerIndent if text.include? InnerIndent
|
@@ -602,7 +602,10 @@ module Extensions
|
|
602
602
|
|
603
603
|
# Import the specified page into the current document.
|
604
604
|
#
|
605
|
-
|
605
|
+
# By default, advance to the subsequent page, creating one if necessary.
|
606
|
+
# This behavior can be disabled by passing the option `advance: false`.
|
607
|
+
#
|
608
|
+
def import_page file, opts = {}
|
606
609
|
prev_page_layout = page.layout
|
607
610
|
prev_page_size = page.size
|
608
611
|
state.compress = false if state.compress # can't use compression if using template
|
@@ -611,13 +614,15 @@ module Extensions
|
|
611
614
|
start_new_page_discretely template: file
|
612
615
|
# prawn-templates sets text_rendering_mode to :unknown, which breaks running content; revert
|
613
616
|
@text_rendering_mode = prev_text_rendering_mode
|
614
|
-
if
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
617
|
+
if opts.fetch :advance, true
|
618
|
+
if last_page?
|
619
|
+
# NOTE set page size & layout explicitly in case imported page differs
|
620
|
+
# I'm not sure it's right to start a new page here, but unfortunately there's no other
|
621
|
+
# way atm to prevent the size & layout of the imported page from affecting subsequent pages
|
622
|
+
start_new_page size: prev_page_size, layout: prev_page_layout
|
623
|
+
else
|
624
|
+
go_to_page page_number + 1
|
625
|
+
end
|
621
626
|
end
|
622
627
|
nil
|
623
628
|
end
|
@@ -86,7 +86,12 @@ class ThemeLoader
|
|
86
86
|
private
|
87
87
|
|
88
88
|
def process_entry key, val, data
|
89
|
-
if key
|
89
|
+
if key.start_with? 'admonition_icon_'
|
90
|
+
data[key] = (val || {}).map do |(key2, val2)|
|
91
|
+
static_val2 = evaluate val2, data
|
92
|
+
[key2.to_sym, (key2.end_with? '_color') ? to_color(static_val2) : static_val2]
|
93
|
+
end.to_h
|
94
|
+
elsif key != 'font_catalog' && ::Hash === val
|
90
95
|
val.each do |key2, val2|
|
91
96
|
process_entry %(#{key}_#{key2.tr '-', '_'}), val2, data
|
92
97
|
end
|
@@ -106,7 +111,7 @@ class ThemeLoader
|
|
106
111
|
expr
|
107
112
|
end
|
108
113
|
end
|
109
|
-
|
114
|
+
|
110
115
|
# NOTE we assume expr is a String
|
111
116
|
def expand_vars expr, vars
|
112
117
|
if (idx = (expr.index '$'))
|
@@ -119,7 +124,7 @@ class ThemeLoader
|
|
119
124
|
expr
|
120
125
|
end
|
121
126
|
end
|
122
|
-
|
127
|
+
|
123
128
|
def evaluate_math expr
|
124
129
|
return expr if !(::String === expr) || ColorValue === expr
|
125
130
|
original = expr
|
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.alpha.
|
4
|
+
version: 1.5.0.alpha.10
|
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: 2015-
|
12
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -107,40 +107,40 @@ dependencies:
|
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: 1.0.0
|
111
111
|
type: :runtime
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 1.0.0
|
118
118
|
- !ruby/object:Gem::Dependency
|
119
119
|
name: safe_yaml
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.0.4
|
125
125
|
type: :runtime
|
126
126
|
prerelease: false
|
127
127
|
version_requirements: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: 1.0.4
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
133
|
name: thread_safe
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 0.3.5
|
139
139
|
type: :runtime
|
140
140
|
prerelease: false
|
141
141
|
version_requirements: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: 0.3.5
|
146
146
|
- !ruby/object:Gem::Dependency
|
@@ -250,8 +250,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
250
|
version: 1.3.1
|
251
251
|
requirements: []
|
252
252
|
rubyforge_project:
|
253
|
-
rubygems_version: 2.4.
|
253
|
+
rubygems_version: 2.4.8
|
254
254
|
signing_key:
|
255
255
|
specification_version: 4
|
256
256
|
summary: Converts AsciiDoc documents to PDF using Prawn
|
257
257
|
test_files: []
|
258
|
+
has_rdoc: true
|