asciidoctor-pdf 1.5.0.alpha.17 → 1.5.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +75 -2
- data/NOTICE.adoc +14 -11
- data/README.adoc +105 -27
- data/asciidoctor-pdf.gemspec +4 -1
- data/data/themes/base-theme.yml +4 -0
- data/data/themes/default-theme.yml +17 -34
- data/data/themes/default-with-fallback-font-theme.yml +22 -0
- data/docs/theming-guide.adoc +1057 -867
- data/lib/asciidoctor-pdf/asciidoctor_ext/abstract_block.rb +5 -0
- data/lib/asciidoctor-pdf/asciidoctor_ext/document.rb +3 -0
- data/lib/asciidoctor-pdf/asciidoctor_ext/image.rb +4 -4
- data/lib/asciidoctor-pdf/asciidoctor_ext/logging_shim.rb +8 -2
- data/lib/asciidoctor-pdf/asciidoctor_ext/section.rb +16 -8
- data/lib/asciidoctor-pdf/asciidoctor_ext.rb +3 -1
- data/lib/asciidoctor-pdf/converter.rb +758 -499
- data/lib/asciidoctor-pdf/core_ext/hash.rb +5 -0
- data/lib/asciidoctor-pdf/core_ext/regexp.rb +3 -0
- data/lib/asciidoctor-pdf/core_ext.rb +2 -0
- data/lib/asciidoctor-pdf/formatted_text/formatter.rb +8 -1
- data/lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb +3 -1
- data/lib/asciidoctor-pdf/formatted_text/parser.rb +24 -12
- data/lib/asciidoctor-pdf/formatted_text/parser.treetop +1 -1
- data/lib/asciidoctor-pdf/formatted_text/text_background_and_border_renderer.rb +45 -0
- data/lib/asciidoctor-pdf/formatted_text/transform.rb +44 -21
- data/lib/asciidoctor-pdf/formatted_text.rb +1 -0
- data/lib/asciidoctor-pdf/index_catalog.rb +9 -3
- data/lib/asciidoctor-pdf/measurements.rb +1 -1
- data/lib/asciidoctor-pdf/prawn_ext/extensions.rb +37 -21
- data/lib/asciidoctor-pdf/prawn_ext/images.rb +18 -7
- data/lib/asciidoctor-pdf/roman_numeral.rb +12 -0
- data/lib/asciidoctor-pdf/theme_loader.rb +99 -69
- data/lib/asciidoctor-pdf/version.rb +1 -1
- metadata +45 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 032a48f8d8cda0a29e3e7c3249cb2c74aaccc0f910adcb4607ef30733b70b948
|
4
|
+
data.tar.gz: 1e995ab8292dedab7deef06867f5da0ca41570be9abe88e6be81af999fe4965b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 945a1f3e02ee7c08e7a08f5566dc9bf79aac394674f44665285cf40f7fbaf1bd16c2b2d491b37ad467a5e718c23fa311e245b46f4d46de3f1fe54badf83a69e9
|
7
|
+
data.tar.gz: e3d6c083f0b4ecf716a2264127f523f4a8febfa0a2915838c31f67a4d2cf5201b2178d15a5e6b057528bad4d7b5f685cbc69a8dcaa44538359d2a27532ab8a4c
|
data/CHANGELOG.adoc
CHANGED
@@ -5,6 +5,77 @@
|
|
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.beta.1 (2019-07-08) - @mojavelinux
|
9
|
+
|
10
|
+
* rename pdf-style and pdf-stylesdir attributes to pdf-theme and pdf-themesdir, respectively (while still honoring the old names for compatibility) (#1127)
|
11
|
+
* don't load fallback font by default; move fallback font to default-with-fallback-font theme
|
12
|
+
* apply cell padding to table cells in the head row (#1098)
|
13
|
+
* allow the theme to control the padding of table cells in the head row using the table_head_cell_padding key (#1098)
|
14
|
+
* fix position of table caption for reduced-width tables when caption align is center (#1138)
|
15
|
+
* adjust width of table caption to match width of table unless table_caption_max_width is none in theme (#1138)
|
16
|
+
* fix position of text in running header (#1087)
|
17
|
+
* ignore start attribute on ordered list if marker is disabled
|
18
|
+
* allow start value to be negative for ordered lists that use arabic or roman numbering (#498)
|
19
|
+
* don't convert values in theme which are not color keys to a string (#1089)
|
20
|
+
* apply page layout specified on page break even when break falls page boundary (#1091)
|
21
|
+
* scale SVG background image to fit page in the same way raster image is scaled (#765)
|
22
|
+
* allow page background size to be controlled using image macro attributes (#1117)
|
23
|
+
* allow page background image position to be controlled using position attribute on image macro (#1124)
|
24
|
+
* add support for fit=cover for cover page, page background, and running content images (#1136)
|
25
|
+
* change default background image position to center (#1124)
|
26
|
+
* allow cover image position to be controlled using position attribute on image macro (#1134)
|
27
|
+
* change default cover image position to center (#1134)
|
28
|
+
* set enable_file_requests_with_root and enable_web_requests options for all SVGs (#683)
|
29
|
+
* automatically set pdf-stylesdir if pdf-style ends with .yml and pdf-stylesdir is not specified (#1126)
|
30
|
+
* replace hyphens with underscores in top-level theme keys
|
31
|
+
* allow hyphens to be used in variable references in theme (#1122)
|
32
|
+
* allow theme to control background and border of inline code (literal) (#306)
|
33
|
+
* allow theme to control background and border of inline button (#451)
|
34
|
+
* resolve null color value in theme to nil (aka not set)
|
35
|
+
* add support for cgi-style options on source language when syntax highlighting with Rouge (#1102)
|
36
|
+
* apply custom theme to chronicles example to customize running content and demonstrate how to extend default theme
|
37
|
+
* drop remapping of legacy running content keys in theme data
|
38
|
+
* resize running content to fit page layout (#1036)
|
39
|
+
* exclude border width from running content area (#1109)
|
40
|
+
* support text-transform property in running content (#702)
|
41
|
+
* make depth of section titles assigned to section-title attribute in running content configurable (#1141)
|
42
|
+
* support width attribute on image in running content if no other dimension attribute is specified
|
43
|
+
* apply correct scale-down logic to image in running content
|
44
|
+
* allow image format to be specified using format attribute (cover page image, page background image, running content image) (#1132)
|
45
|
+
* allow theme to set bottom border properties (color, style, and width) of table head row (#770)
|
46
|
+
* allow column rule and spacing to be specified for running content when multiple columns are specified (#1093)
|
47
|
+
* never load base theme when loading default theme; otherwise load base theme if extends isn't specified, but only if theme data hasn't been initialized
|
48
|
+
* shorten text-alignment attribute to text-align
|
49
|
+
* set PDF version to 1.4 by default (#302)
|
50
|
+
* allow PDF version to be set using pdf-version document attribute (#302)
|
51
|
+
|
52
|
+
== 1.5.0.alpha.18 (2019-06-01) - @mojavelinux
|
53
|
+
|
54
|
+
* restore compatibility with Asciidoctor back to 1.5.3 and add verification to test matrix (#1038)
|
55
|
+
* allow theme to set text indent for paragraphs using prose_text_indent (#191)
|
56
|
+
* allow theme to set spacing between adjacent paragraphs using prose_margin_inner (#191)
|
57
|
+
* show parts in toc when toclevels=0 (#783)
|
58
|
+
* add support for autonumbered callouts in source blocks (#1076)
|
59
|
+
* fix duplication of footnotes in keep together regions (#1047)
|
60
|
+
* display standalone preamble in book normally (#1051)
|
61
|
+
* allow outline depth to be set using outlinelevels attribute independent of toclevels (#1054)
|
62
|
+
* fix compounding cell padding (#1053)
|
63
|
+
* add support for qanda list (#1013)
|
64
|
+
* fix parsing of bibref and link inside footnote text (#1061)
|
65
|
+
* restore square brackets around ID of bibliography entry with custom ID (#1065)
|
66
|
+
* add page_numbering_start_at key to theme to control start page for page numbering (#1041)
|
67
|
+
* don't allow running_content_start_at key to affect page numbering (#1041)
|
68
|
+
* substitute \{chapter-title} property on front matter pages (replace with doctitle and toc-title, respectively, when running content starts before first page of body) (#1040)
|
69
|
+
* allow side margins to be set on elements on title page (#824)
|
70
|
+
* don't promote preamble to preface if preface-title attribute is empty
|
71
|
+
* expand padding value for running content (header and footer) to array
|
72
|
+
* add support for unnumbered (and no-bullet) style on ordered list (#1073)
|
73
|
+
* add visual regression capability to test suite (@beatchristen)
|
74
|
+
* ensure index section doesn't get numbered when using Asciidoctor < 1.5.7
|
75
|
+
* add part signifier and part number to part title if partnums is set; allow signifier to be customized using part-signifier attribute (#597)
|
76
|
+
* add support for the chapter-signifier attribute as the prefered alternative to chapter-label
|
77
|
+
* warn if the image referenced in the running content cannot be found (#731)
|
78
|
+
|
8
79
|
== 1.5.0.alpha.17 (2019-04-23) - @mojavelinux
|
9
80
|
|
10
81
|
* drop support for Ruby < 2.3 (and installation will fail for Ruby < 2.1)
|
@@ -18,6 +89,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
|
|
18
89
|
* add support for nbsp named entity (i.e., `+ `); replace occurances of nbsp named entity with a single space in outline
|
19
90
|
* upgrade to FontAwesome 5; introduce the fas, far, and fab icon sets, now preferred over fa; drop support for octicons (#891) (@jessedoyle)
|
20
91
|
* place footnotes at end of chapters in books or end of document otherwise (#85) (@bcourtine)
|
92
|
+
* fix rendering of footnotes directly adjacent to text in a normal table cell (#927)
|
21
93
|
* place toc directly after document title when doctype is not book (#233) (@ogmios-voice)
|
22
94
|
* add page layout control to page break (#490) (@resort-diaper)
|
23
95
|
* allow additional style properties to be set per heading level (#176) (@billybooth)
|
@@ -34,8 +106,8 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
|
|
34
106
|
* handle case when uri to make breakable is empty (#936)
|
35
107
|
* add support for frame=ends as alternative to frame=topbot on table
|
36
108
|
* 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
|
109
|
+
* disable table stripes by default (#1049)
|
110
|
+
* allow table stripes to be enabled globally using table-stripes attribute (#1049)
|
39
111
|
* use new logging subsystem, if available; otherwise, use shim (#905)
|
40
112
|
* allow alignment of list text to be controlled using roles (#182)
|
41
113
|
* allow text alignment to be set for abstract (#893)
|
@@ -56,6 +128,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
|
|
56
128
|
* guard against pygments returning nil (#884)
|
57
129
|
* encode quotes in alt text of inline image (#977)
|
58
130
|
* fix crash when menu macro is used in a section or block title (#934)
|
131
|
+
* remove duplicate message when syntax highlighter is unavailable; don't crash processor (#1078)
|
59
132
|
* only look for the start attribute on the code block itself when highlighting with rouge
|
60
133
|
* apply block styling to background for line-oriented tokens in rouge by default
|
61
134
|
* detect pagenum ranges in index when media is print or prepress (#906)
|
data/NOTICE.adoc
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= Asciidoctor PDF
|
2
2
|
OpenDevise Inc.; Asciidoctor Project
|
3
3
|
|
4
|
-
Copyright (C) 2014-
|
4
|
+
Copyright (C) 2014-2019 OpenDevise Inc. and the Asciidoctor Project.
|
5
5
|
|
6
6
|
Please visit the Asciidoctor project site for more information:
|
7
7
|
|
@@ -26,7 +26,7 @@ M+ OUTLINE FONTS (M+ TESTFLIGHT 058)::
|
|
26
26
|
|
27
27
|
- http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index-en.html
|
28
28
|
|
29
|
-
Noto Serif Font (
|
29
|
+
Noto Serif Font (v2015-06-05)::
|
30
30
|
Noto is font family developed by the Google Internationalization Team that aims to support all the world's languages.
|
31
31
|
The Noto Serif font is used for headings and body copy and is bundled in the PDF file.
|
32
32
|
The Noto fonts are licensed under the Apache 2.0 License.
|
@@ -36,7 +36,7 @@ Noto Serif Font (v2014-01-30)::
|
|
36
36
|
|
37
37
|
- https://code.google.com/p/noto/
|
38
38
|
|
39
|
-
Font Awesome Icon Font (
|
39
|
+
Font Awesome Icon Font (v5.4)::
|
40
40
|
Font Awesome (@fontawesome), the iconic font designed for Bootstrap by David Gandy (@davegandy), is used for the admonition icons and other icons in author's content and bundled in the PDF file.
|
41
41
|
Font Awesome is fully open source and GPL compatible.
|
42
42
|
The font is licensed under the SIL Open Font 1.1 License (OFL).
|
@@ -46,14 +46,6 @@ Font Awesome Icon Font (v4.0.3)::
|
|
46
46
|
|
47
47
|
- http://fontawesome.io
|
48
48
|
|
49
|
-
Liberation Fonts (v2.00.1)::
|
50
|
-
The Liberation(tm) Fonts 2.00.1, which are used by default, are licensed under the SIL Open Font License, Version 1.1.
|
51
|
-
You may obtain a copy of the license at:
|
52
|
-
|
53
|
-
http://scripts.sil.org/OFL
|
54
|
-
|
55
|
-
- https://fedorahosted.org/liberation-fonts
|
56
|
-
|
57
49
|
RomanNumeral class::
|
58
50
|
The RomanNumeral class, which is used for numbering of ordered lists, is borrowed from the roman-numerals RubyGem and modified for the purpose of this application.
|
59
51
|
The original RomanNumerals class was written by Andrew Vos and is licensed under the MIT License.
|
@@ -74,3 +66,14 @@ Bootstrap (v3.0.3)::
|
|
74
66
|
The default theme is inspired by Bootstrap 3.0.3.
|
75
67
|
|
76
68
|
- http://getbootstrap.com
|
69
|
+
|
70
|
+
spec/fixtures/cover.jpg::
|
71
|
+
Attribution: Dominicus Johannes Bergsma; License: Creative Commons Attribution-Share Alike 3.0 Unported
|
72
|
+
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
|
73
|
+
|
74
|
+
- https://commons.wikimedia.org/wiki/File:Dahlia_%27Bishop_of_Auckland.JPG
|
75
|
+
|
76
|
+
spec/fixtures/tux.png::
|
77
|
+
Attribution: Larry Ewing, Simon Budig, Garrett LeSage; License: Creative Commons CC0 1.0 Universal Public Domain Dedication
|
78
|
+
|
79
|
+
- https://commons.wikimedia.org/wiki/File:Tux.svg
|
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.
|
3
|
+
v1.5.0.beta.1, 2019-07-08
|
4
4
|
// Settings:
|
5
5
|
:experimental:
|
6
6
|
:idprefix:
|
@@ -24,7 +24,7 @@ endif::[]
|
|
24
24
|
:project-name: Asciidoctor PDF
|
25
25
|
:project-handle: asciidoctor-pdf
|
26
26
|
// Variables:
|
27
|
-
:release-version: 1.5.0.
|
27
|
+
:release-version: 1.5.0.beta.1
|
28
28
|
// URIs:
|
29
29
|
:uri-asciidoctor: http://asciidoctor.org
|
30
30
|
:uri-gem: http://rubygems.org/gems/asciidoctor-pdf
|
@@ -41,6 +41,7 @@ endif::[]
|
|
41
41
|
|
42
42
|
ifdef::status[]
|
43
43
|
image:https://img.shields.io/travis/asciidoctor/asciidoctor-pdf/master.svg[Build Status (Travis CI),link=https://travis-ci.org/asciidoctor/asciidoctor-pdf]
|
44
|
+
image:https://ci.appveyor.com/api/projects/status/524bhoms3j2dp1o3/branch/master?svg=true[Build Status (AppVeyor),link=https://ci.appveyor.com/project/asciidoctor/asciidoctor-pdf]
|
44
45
|
image:https://img.shields.io/gem/v/asciidoctor-pdf.svg[Latest Release, link={uri-gem}]
|
45
46
|
image:https://img.shields.io/badge/license-MIT-blue.svg[MIT License, link=#copyright]
|
46
47
|
endif::[]
|
@@ -99,7 +100,7 @@ endif::[]
|
|
99
100
|
== Highlights
|
100
101
|
|
101
102
|
* Direct AsciiDoc to PDF conversion
|
102
|
-
* <<docs/theming-guide#,Configuration-driven style and layout>>
|
103
|
+
* <<docs/theming-guide#,Configuration-driven theme (style and layout)>>
|
103
104
|
* SVG support
|
104
105
|
* PDF document outline (i.e., bookmarks)
|
105
106
|
* Table of contents page(s)
|
@@ -118,7 +119,7 @@ endif::[]
|
|
118
119
|
|
119
120
|
== Prerequisites
|
120
121
|
|
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.
|
122
|
+
All that's needed is Ruby 2.3 or better and a few Ruby gems (including at least Asciidoctor 1.5.3), which we explain how to install in the next section.
|
122
123
|
|
123
124
|
To check if you have Ruby available, use the `ruby` command to query the version installed:
|
124
125
|
|
@@ -391,12 +392,11 @@ In this case, the image is scaled down to fit on a single page.
|
|
391
392
|
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
393
|
This is most useful when using vw units because you can make the image cover the entire width of the page.
|
393
394
|
|
394
|
-
Images in running content also support the `fit` attribute.
|
395
|
+
Images in running content and page background images also support the `fit` attribute (when specified using the image macro).
|
395
396
|
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.
|
396
397
|
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.
|
397
398
|
|
398
|
-
|
399
|
-
Any explicit sizing is ignored for those images.
|
399
|
+
If sizing information is not specified for a page background image, the image is automatically scaled to fit the bounds of the page (i.e., `fit=contain`).
|
400
400
|
|
401
401
|
=== Using the pdfwidth Attribute
|
402
402
|
|
@@ -489,7 +489,7 @@ To perform this work, Asciidoctor delegates to the underlying libraries.
|
|
489
489
|
{uri-prawn-svg}[prawn-svg] brings support for SVG images.
|
490
490
|
Without any additional libraries, those are the only supported image file formats.
|
491
491
|
|
492
|
-
If you need support for additional image formats, such as GIF, TIFF, or interlaced PNG--and you don't want to convert those images to a supported format--you must install the {uri-prawn-gmagick}[prawn-gmagick] Ruby gem.
|
492
|
+
If you need support for additional image formats, such as GIF, TIFF, or interlaced PNG--and you don't want to convert those images to a supported format--you must install the {uri-prawn-gmagick}[prawn-gmagick] (>= 0.0.9) Ruby gem.
|
493
493
|
prawn-gmagick is an extension for Prawn based on {uri-graphicsmagick}[GraphicsMagick] that adds support for all the image formats recognized by that library.
|
494
494
|
prawn-gmagick has the added benefit of significantly reducing the time it takes to generate a PDF containing a lot of images.
|
495
495
|
|
@@ -502,23 +502,25 @@ In addition to support for more additional image file formats, this gem also spe
|
|
502
502
|
|
503
503
|
== STEM Support
|
504
504
|
|
505
|
-
Unlike the built-in HTML converter, Asciidoctor PDF does not provide native support for STEM blocks and inline macros.
|
506
|
-
That's because Asciidoctor core doesn't
|
507
|
-
|
508
|
-
|
505
|
+
Unlike the built-in HTML converter, Asciidoctor PDF does not provide native support for STEM blocks and inline macros (i.e., asciimath and latexmath).
|
506
|
+
That's because Asciidoctor core doesn't process the STEM content itself.
|
507
|
+
It just passes it through to the converter.
|
508
|
+
In the HTML output, Asciidoctor relies on the JavaScript-based MathJax library to parse and render the equations in the browser when the page is loaded.
|
509
|
+
The HTML converter simply wraps the equations in special markup so MathJax can find them.
|
509
510
|
|
510
511
|
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.
|
511
512
|
That typically means converting to an image.
|
512
513
|
|
513
|
-
The recommended solution is an extension named Asciidoctor Mathematical, which we'll cover
|
514
|
-
|
515
|
-
|
514
|
+
The recommended solution is an extension named Asciidoctor Mathematical, which we'll cover in this document.
|
515
|
+
|
516
|
+
Another solution, which is still under development, uses Mathoid to convert STEM equations to images.
|
517
|
+
Mathoid is a library that invokes MathJax using a headless browser, so it supports both asciimath and latexmath equations.
|
516
518
|
That prototype can be found in the https://github.com/asciidoctor/asciidoctor-extensions-lab#extension-catalog[Asciidoctor extensions lab].
|
517
519
|
|
518
520
|
=== Asciidoctor Mathematical
|
519
521
|
|
520
|
-
{uri-asciidoctor-mathematical}[Asciidoctor Mathematical] is an extension for Asciidoctor that provides alternate processing of STEM blocks and inline macros.
|
521
|
-
After the document has been parsed, the extension locates all the
|
522
|
+
{uri-asciidoctor-mathematical}[Asciidoctor Mathematical] is an extension for Asciidoctor that provides alternate processing of STEM blocks and inline macros (currently only latexmath).
|
523
|
+
After the document has been parsed, the extension locates all the latexmath blocks and inline macros, converts the equations to images using Mathematical, then replaces them with image nodes.
|
522
524
|
Conversion then proceeds as normal.
|
523
525
|
|
524
526
|
Asciidoctor Mathematical is a Ruby gem that uses native extensions.
|
@@ -626,6 +628,20 @@ Therefore, to print a range of pages as they are labeled in the document, you ne
|
|
626
628
|
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.
|
627
629
|
That's the range you need to enter into the print dialog.
|
628
630
|
|
631
|
+
== Title Page
|
632
|
+
|
633
|
+
Unlike other converters, the PDF converter introduces a dedicated title page at the start of the document.
|
634
|
+
The title page contains the doctitle, author, date, and revision info.
|
635
|
+
If a front cover image is specified, the title page comes after the front cover.
|
636
|
+
The title page can be styled using the theme and/or reserved page attributes.
|
637
|
+
|
638
|
+
The title page is enabled if either of these conditions are met:
|
639
|
+
|
640
|
+
* The document has the `book` doctype.
|
641
|
+
* The `title-page` attribute is set (with an empty value) in the document header.
|
642
|
+
|
643
|
+
When the title page is enabled, the table of contents (aka TOC) also gets is own page (or pages, if necessary).
|
644
|
+
|
629
645
|
== Table of Contents
|
630
646
|
|
631
647
|
The table of contents (TOC) is not included by default.
|
@@ -660,28 +676,56 @@ The only restriction is that no index terms may be defined below this section.
|
|
660
676
|
NOTE: Although the catalog is generated automatically, you have to mark the index terms manually.
|
661
677
|
However, you could use an extension, such as a TreeProcessor, to automatically mark index terms.
|
662
678
|
|
663
|
-
==
|
679
|
+
== Optimizing the Generated PDF
|
680
|
+
|
681
|
+
=== optimize-pdf
|
664
682
|
|
665
|
-
{project-name} also provides a shell script that
|
683
|
+
{project-name} also provides a shell script that uses GhostScript (`gs`) to optimize and compress the generated PDF (with minimal impact on quality).
|
666
684
|
You must have Ghostscript installed to use it.
|
667
685
|
|
668
686
|
Here's an example usage:
|
669
687
|
|
670
688
|
$ ./bin/optimize-pdf basic-example.pdf
|
671
689
|
|
672
|
-
The command will generate the file [.path]
|
690
|
+
The command will generate the file [.path]_basic-example-optimized.pdf_ in the same directory.
|
673
691
|
|
674
692
|
WARNING: The `optimize-pdf` script currently requires a Bash shell (Linux, OSX, etc).
|
675
693
|
We plan to rewrite the script in Ruby so it works across platforms (see https://github.com/asciidoctor/asciidoctor-pdf/issues/1[issue #1])
|
676
694
|
|
677
|
-
IMPORTANT: The `optimize-pdf` script relies on Ghostscript >= 9.10.
|
678
|
-
Otherwise, it may actually make the PDF larger.
|
679
|
-
Also, you should only consider using it if the file size of the original PDF is > 5MB.
|
680
|
-
|
681
695
|
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.
|
682
696
|
This file is necessary to preserve the document metadata since Ghostscript will otherwise drop it.
|
683
697
|
That's why {project-name} always creates this file in addition to the PDF.
|
684
698
|
|
699
|
+
IMPORTANT: The `optimize-pdf` script relies on Ghostscript >= 9.10.
|
700
|
+
Otherwise, it may actually make the PDF larger.
|
701
|
+
You should probably only consider using it if the file size of the original PDF is > 5MB.
|
702
|
+
|
703
|
+
=== hexapdf
|
704
|
+
|
705
|
+
Another option to optimize the PDF is https://hexapdf.gettalong.org/[hexapdf] (gem: hexapdf, command: hexapdf).
|
706
|
+
Before introducing it, though, it's important to point out that its license is AGPL.
|
707
|
+
If that's okay with you, read on to learn how to use it.
|
708
|
+
|
709
|
+
First, install the hexapdf gem using the following command:
|
710
|
+
|
711
|
+
$ gem install hexapdf
|
712
|
+
|
713
|
+
You can then use it to optimize your PDF as follows:
|
714
|
+
|
715
|
+
$ hexapdf optimize --compress-pages --force basic-example.pdf basic-example-optimized.pdf
|
716
|
+
|
717
|
+
This command does not manipulate the images in any way.
|
718
|
+
It merely compresses the objects in the PDF and prunes any unreachable references.
|
719
|
+
But given how much waste Prawn leaves behind, this turns out to reduce the file size significantly.
|
720
|
+
|
721
|
+
To see more options, run:
|
722
|
+
|
723
|
+
$ hexapdf help optimize
|
724
|
+
|
725
|
+
For example, to make the source of the PDF a bit more readable, set the stream-related options to `preserve`.
|
726
|
+
|
727
|
+
hexapdf also allows you to add password protection to your PDF, if that's something you're interested in doing.
|
728
|
+
|
685
729
|
ifndef::env-site[]
|
686
730
|
== Contributing
|
687
731
|
|
@@ -756,7 +800,15 @@ To run the tests, simply invoke rspec via bundler.
|
|
756
800
|
|
757
801
|
$ bundle exec rspec
|
758
802
|
|
759
|
-
|
803
|
+
To disable the visual integration tests, pass the `` option:
|
804
|
+
|
805
|
+
$ bundle exec rspec -t ~integration
|
806
|
+
|
807
|
+
If a visual integration test fails, you can instruct the test suite to keep the files in the [.path]_spec/output_ directory by setting the `DEBUG` environment variable:
|
808
|
+
|
809
|
+
$ DEBUG=true bundle exec rspec -t integration
|
810
|
+
|
811
|
+
If you want to see the name of each test as it is run, add the `-fd` option:
|
760
812
|
|
761
813
|
$ bundle exec rspec -fd
|
762
814
|
|
@@ -769,11 +821,15 @@ Running tests using `rspec` directly gives you the advantage of being able to sp
|
|
769
821
|
To run a single test, you can filter by the name of the test.
|
770
822
|
For example, to run all tests that pertain to failures, use:
|
771
823
|
|
772
|
-
$ bundle exec rspec -e fail
|
824
|
+
$ bundle exec rspec -e fail
|
825
|
+
|
826
|
+
To run all tests that have `wip` in the name, use:
|
827
|
+
|
828
|
+
$ bundle exec rspec -e wip
|
773
829
|
|
774
830
|
You can also run all tests in a given file by passing the file's path to rspec:
|
775
831
|
|
776
|
-
$ bundle exec rspec
|
832
|
+
$ bundle exec rspec spec/toc_spec.rb
|
777
833
|
|
778
834
|
For a full list of options that rspec provides, run `rspec -h`.
|
779
835
|
|
@@ -790,6 +846,28 @@ You can use the application to convert a document as follows:
|
|
790
846
|
|
791
847
|
$ bundle exec asciidoctor-pdf /path/to/sample.adoc
|
792
848
|
|
849
|
+
=== Install the Application (optional)
|
850
|
+
|
851
|
+
If you want to install the application globally so you can run it anywhere, use the following `rake` task:
|
852
|
+
|
853
|
+
$ bundle exec rake install
|
854
|
+
|
855
|
+
This task will package the gem and install it into your system gems.
|
856
|
+
|
857
|
+
If you want to install the gem using a separate command, first use the following `rake` task to build it:
|
858
|
+
|
859
|
+
$ rm -rf pkg
|
860
|
+
bundle exec rake build
|
861
|
+
|
862
|
+
This task packages the application as a gem and writes it to the [.path]_pkg_ directory.
|
863
|
+
A message will be printed to the console telling you the exact filename.
|
864
|
+
You can now use the `gem install` command to install it.
|
865
|
+
|
866
|
+
$ gem install pkg/*.gem
|
867
|
+
|
868
|
+
You'll want to pay attention to which Ruby installation you are installing the gem into.
|
869
|
+
If successful, the `asciidoctor-pdf` executable will be available on your PATH.
|
870
|
+
|
793
871
|
endif::[]
|
794
872
|
|
795
873
|
=== Test a Pull Request
|
data/asciidoctor-pdf.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
s.require_paths = ['lib']
|
36
36
|
#s.test_files = files.grep %r/^(?:test|spec|feature)\/.*$/
|
37
37
|
|
38
|
-
s.add_runtime_dependency 'asciidoctor', '>= 1.5.
|
38
|
+
s.add_runtime_dependency 'asciidoctor', '>= 1.5.3', '< 3.0.0'
|
39
39
|
s.add_runtime_dependency 'prawn', '~> 2.2.0'
|
40
40
|
s.add_runtime_dependency 'prawn-table', '~> 0.2.0'
|
41
41
|
s.add_runtime_dependency 'prawn-templates', '~> 0.1.0'
|
@@ -48,6 +48,9 @@ Gem::Specification.new do |s|
|
|
48
48
|
s.add_runtime_dependency 'treetop', '~> 1.5.0'
|
49
49
|
|
50
50
|
s.add_development_dependency 'rake', '~> 12.3.0'
|
51
|
+
# Asciidoctor PDF supports Rouge >= 2; Rouge 3.4.1 emits a superfluous warning in verbose mode
|
52
|
+
s.add_development_dependency 'rouge', '~> 3.4.0', '!= 3.4.1'
|
51
53
|
s.add_development_dependency 'rspec', '~> 3.8.0'
|
52
54
|
s.add_development_dependency 'pdf-inspector', '~> 1.3.0'
|
55
|
+
s.add_development_dependency 'chunky_png', '~> 1.3.0'
|
53
56
|
end
|
data/data/themes/base-theme.yml
CHANGED
@@ -21,6 +21,9 @@ base_line_height: 1.15
|
|
21
21
|
base_line_height_length: 13.8
|
22
22
|
base_border_color: 'EEEEEE'
|
23
23
|
base_border_width: 0.5
|
24
|
+
button_content: '[%s]'
|
25
|
+
button_font_family: Courier
|
26
|
+
button_font_style: bold
|
24
27
|
link_font_color: '0000EE'
|
25
28
|
literal_font_family: Courier
|
26
29
|
heading_font_style: bold
|
@@ -91,6 +94,7 @@ table_border_style: solid
|
|
91
94
|
table_border_width: 0.5
|
92
95
|
table_cell_padding: 2
|
93
96
|
table_head_font_style: bold
|
97
|
+
table_head_border_bottom_width: 1.25
|
94
98
|
table_body_stripe_background_color: 'EEEEEE'
|
95
99
|
thematic_break_border_color: 'EEEEEE'
|
96
100
|
thematic_break_border_style: solid
|
@@ -12,15 +12,6 @@ font:
|
|
12
12
|
bold: mplus1mn-bold-ascii.ttf
|
13
13
|
italic: mplus1mn-italic-ascii.ttf
|
14
14
|
bold_italic: mplus1mn-bold_italic-ascii.ttf
|
15
|
-
# M+ 1p supports Latin, Latin-1 Supplement, Latin Extended, Greek, Cyrillic, Vietnamese, Japanese & an assortment of symbols
|
16
|
-
# It also provides arrows for ->, <-, => and <= replacements in case these glyphs are missing from font
|
17
|
-
M+ 1p Fallback:
|
18
|
-
normal: mplus1p-regular-fallback.ttf
|
19
|
-
bold: mplus1p-regular-fallback.ttf
|
20
|
-
italic: mplus1p-regular-fallback.ttf
|
21
|
-
bold_italic: mplus1p-regular-fallback.ttf
|
22
|
-
fallbacks:
|
23
|
-
- M+ 1p Fallback
|
24
15
|
page:
|
25
16
|
background_color: ffffff
|
26
17
|
layout: portrait
|
@@ -67,13 +58,17 @@ vertical_rhythm: $base_line_height_length
|
|
67
58
|
horizontal_rhythm: $base_line_height_length
|
68
59
|
# QUESTION should vertical_spacing be block_spacing instead?
|
69
60
|
vertical_spacing: $vertical_rhythm
|
61
|
+
button:
|
62
|
+
content: "[\u2009%s\u2009]"
|
63
|
+
font_style: bold
|
70
64
|
link:
|
71
65
|
font_color: 428bca
|
72
66
|
# literal is currently used for inline monospaced in prose and table cells
|
73
67
|
literal:
|
74
68
|
font_color: b12146
|
75
69
|
font_family: M+ 1mn
|
76
|
-
|
70
|
+
menu:
|
71
|
+
caret_content: " <font size=\"1.15em\"><color rgb=\"b12146\">\u203a</color></font> "
|
77
72
|
heading:
|
78
73
|
align: left
|
79
74
|
#font_color: 181818
|
@@ -173,7 +168,7 @@ code:
|
|
173
168
|
border_radius: $base_border_radius
|
174
169
|
border_width: 0.75
|
175
170
|
conum:
|
176
|
-
font_family:
|
171
|
+
font_family: $literal_font_family
|
177
172
|
font_color: $literal_font_color
|
178
173
|
font_size: $base_font_size
|
179
174
|
line_height: 4 / 3
|
@@ -219,15 +214,16 @@ outline_list:
|
|
219
214
|
item_spacing: $vertical_rhythm / 2
|
220
215
|
table:
|
221
216
|
background_color: $page_background_color
|
222
|
-
#head_background_color: <hex value>
|
223
|
-
#head_font_color: $base_font_color
|
224
|
-
head_font_style: bold
|
225
|
-
#body_background_color: <hex value>
|
226
|
-
body_stripe_background_color: f9f9f9
|
227
|
-
foot_background_color: f0f0f0
|
228
217
|
border_color: dddddd
|
229
218
|
border_width: $base_border_width
|
230
219
|
cell_padding: 3
|
220
|
+
head:
|
221
|
+
font_style: bold
|
222
|
+
border_bottom_width: $base_border_width * 2.5
|
223
|
+
body:
|
224
|
+
stripe_background_color: f9f9f9
|
225
|
+
foot:
|
226
|
+
background_color: f0f0f0
|
231
227
|
toc:
|
232
228
|
indent: $horizontal_rhythm
|
233
229
|
line_height: 1.4
|
@@ -238,7 +234,10 @@ toc:
|
|
238
234
|
footnotes:
|
239
235
|
font_size: round($base_font_size * 0.75)
|
240
236
|
item_spacing: $outline_list_item_spacing / 2
|
241
|
-
|
237
|
+
header:
|
238
|
+
font_size: $base_font_size_small
|
239
|
+
line_height: 1
|
240
|
+
vertical_align: middle
|
242
241
|
footer:
|
243
242
|
font_size: $base_font_size_small
|
244
243
|
# NOTE if background_color is set, background and border will span width of page
|
@@ -248,27 +247,11 @@ footer:
|
|
248
247
|
line_height: 1
|
249
248
|
padding: [$base_line_height_length / 2, 1, 0, 1]
|
250
249
|
vertical_align: top
|
251
|
-
#image_vertical_align: <alignment> or <number>
|
252
|
-
# additional attributes for content:
|
253
|
-
# * {page-count}
|
254
|
-
# * {page-number}
|
255
|
-
# * {document-title}
|
256
|
-
# * {document-subtitle}
|
257
|
-
# * {chapter-title}
|
258
|
-
# * {section-title}
|
259
|
-
# * {section-or-chapter-title}
|
260
250
|
recto:
|
261
251
|
#columns: "<50% =0% >50%"
|
262
252
|
right:
|
263
253
|
content: '{page-number}'
|
264
|
-
#content: '{section-or-chapter-title} | {page-number}'
|
265
|
-
#content: '{document-title} | {page-number}'
|
266
|
-
#center:
|
267
|
-
# content: '{page-number}'
|
268
254
|
verso:
|
269
255
|
#columns: $footer_recto_columns
|
270
256
|
left:
|
271
257
|
content: $footer_recto_right_content
|
272
|
-
#content: '{page-number} | {chapter-title}'
|
273
|
-
#center:
|
274
|
-
# content: '{page-number}'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
extends: default
|
2
|
+
font:
|
3
|
+
catalog:
|
4
|
+
Noto Serif:
|
5
|
+
normal: notoserif-regular-subset.ttf
|
6
|
+
bold: notoserif-bold-subset.ttf
|
7
|
+
italic: notoserif-italic-subset.ttf
|
8
|
+
bold_italic: notoserif-bold_italic-subset.ttf
|
9
|
+
M+ 1mn:
|
10
|
+
normal: mplus1mn-regular-ascii-conums.ttf
|
11
|
+
bold: mplus1mn-bold-ascii.ttf
|
12
|
+
italic: mplus1mn-italic-ascii.ttf
|
13
|
+
bold_italic: mplus1mn-bold_italic-ascii.ttf
|
14
|
+
# M+ 1p supports Latin, Latin-1 Supplement, Latin Extended, Greek, Cyrillic, Vietnamese, Japanese & an assortment of symbols
|
15
|
+
# It also provides arrows for ->, <-, => and <= replacements in case these glyphs are missing from font
|
16
|
+
M+ 1p Fallback:
|
17
|
+
normal: mplus1p-regular-fallback.ttf
|
18
|
+
bold: mplus1p-regular-fallback.ttf
|
19
|
+
italic: mplus1p-regular-fallback.ttf
|
20
|
+
bold_italic: mplus1p-regular-fallback.ttf
|
21
|
+
fallbacks:
|
22
|
+
- M+ 1p Fallback
|