asciidoctor-pdf 2.0.0.beta.1 → 2.0.0.beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +128 -82
- data/README.adoc +6 -119
- data/data/themes/base-theme.yml +1 -1
- data/data/themes/default-for-print-theme.yml +4 -4
- data/data/themes/default-for-print-with-fallback-font-theme.yml +2 -3
- data/data/themes/default-for-print-with-font-fallbacks-theme.yml +3 -0
- data/data/themes/{sans-with-fallback-font-theme.yml → default-sans-theme.yml} +1 -1
- data/data/themes/default-sans-with-font-fallbacks-theme.yml +3 -0
- data/data/themes/default-theme.yml +3 -2
- data/data/themes/default-with-fallback-font-theme.yml +2 -9
- data/data/themes/default-with-font-fallbacks-theme.yml +9 -0
- data/docs/theming-guide.adoc +5 -6051
- data/lib/asciidoctor/pdf/converter.rb +237 -92
- data/lib/asciidoctor/pdf/ext/prawn/document/column_box.rb +16 -0
- data/lib/asciidoctor/pdf/ext/prawn/extensions.rb +50 -23
- data/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb +14 -0
- data/lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb +39 -0
- data/lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb +2 -9
- data/lib/asciidoctor/pdf/ext/prawn.rb +2 -0
- data/lib/asciidoctor/pdf/formatted_text/source_wrap.rb +7 -2
- data/lib/asciidoctor/pdf/version.rb +1 -1
- metadata +8 -3
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
|
-
v2.0.0.beta.
|
3
|
+
v2.0.0.beta.2, 2022-05-14
|
4
4
|
// Settings:
|
5
5
|
:experimental:
|
6
6
|
:idprefix:
|
@@ -24,7 +24,7 @@ endif::[]
|
|
24
24
|
:project-handle: asciidoctor-pdf
|
25
25
|
// Variables:
|
26
26
|
:release-line: 2.0.x
|
27
|
-
:release-version: 2.0.0.beta.
|
27
|
+
:release-version: 2.0.0.beta.2
|
28
28
|
// URIs:
|
29
29
|
:url-asciidoctor: http://asciidoctor.org
|
30
30
|
:url-gem: http://rubygems.org/gems/asciidoctor-pdf
|
@@ -49,7 +49,7 @@ It bypasses the requirement to generate an intermediary format such as DocBook,
|
|
49
49
|
Instead, you can use this extension to convert your documents directly from AsciiDoc to PDF.
|
50
50
|
Its aim is to take the pain out of creating PDF documents from AsciiDoc.
|
51
51
|
|
52
|
-
NOTE:
|
52
|
+
NOTE: The documentation for Asciidoctor PDF {release-line} is now available at https://docs.asciidoctor.org/pdf-converter/latest/.
|
53
53
|
If you're looking for the documentation for another release line, please refer to one of the following branches: +
|
54
54
|
{url-project-repo}/tree/v1.5.x#readme[1.5.x]
|
55
55
|
-
|
@@ -75,7 +75,7 @@ But don't miss the <<Highlights>> to get a preview of what's possible.
|
|
75
75
|
== Highlights
|
76
76
|
|
77
77
|
* Direct AsciiDoc to PDF conversion
|
78
|
-
*
|
78
|
+
* Configuration-driven theme (style and layout)
|
79
79
|
* Custom fonts (TTF or OTF)
|
80
80
|
* Full SVG support (thanks to https://github.com/mogest/prawn-svg[prawn-svg])
|
81
81
|
* PDF document outline (i.e., bookmarks)
|
@@ -319,7 +319,7 @@ The pain of the DocBook toolchain should be melting away about now.
|
|
319
319
|
== Themes
|
320
320
|
|
321
321
|
The layout and styling of the PDF is driven by a YAML configuration file.
|
322
|
-
To learn how the theming system works and how to create and apply custom themes, refer to the
|
322
|
+
To learn how the theming system works and how to create and apply custom themes, refer to the https://docs.asciidoctor.org/pdf-converter/latest/theme/[Asciidoctor PDF theming documentation].
|
323
323
|
You can use the built-in theme files, which you can find in the [.path]_data/themes_ directory, as examples.
|
324
324
|
|
325
325
|
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.
|
@@ -328,7 +328,7 @@ For example, to configure Rouge to use the built-in monokai theme, run Asciidoct
|
|
328
328
|
$ asciidoctor-pdf -a rouge-style=monokai basic-example.adoc
|
329
329
|
|
330
330
|
It's possible to develop your own theme for Rouge.
|
331
|
-
Refer to the
|
331
|
+
Refer to the https://docs.asciidoctor.org/pdf-converter/latest/theme/[Asciidoctor PDF theming documentation] for details.
|
332
332
|
|
333
333
|
== Support for Non-Latin Languages
|
334
334
|
|
@@ -343,80 +343,6 @@ There's no one font that supports all the world's languages (though some, like N
|
|
343
343
|
Even if there were such a font, bundling that font with the main gem would make it enormous.
|
344
344
|
It would also severely limit the style choices in the default theme, which targets Latin-based languages.
|
345
345
|
Therefore, we're taking the strategy of creating separate dedicated theme gems that target each language family, such as CJK.
|
346
|
-
Read on to find out how to use these themes.
|
347
|
-
|
348
|
-
Asciidoctor PDF provides a built-in theme that provides a broad range of characters in the CJK charsets, so you can start with that theme:
|
349
|
-
|
350
|
-
$ asciidoctor-pdf -a scripts=cjk -a pdf-theme=default-with-fallback-font document.adoc
|
351
|
-
|
352
|
-
Notice the `-a scripts=cjk` option.
|
353
|
-
That's important.
|
354
|
-
It tells the converter to insert break opportunities between CJK characters so that the line wraps properly when mixing English and a CJK language like Japanese.
|
355
|
-
|
356
|
-
If the built-in theme with the fallback font doesn't go far enough, you'll need to use a theme that is optimized for CJK text.
|
357
|
-
You can get such a theme by installing the `asciidoctor-pdf-cjk-kai_gen_gothic` gem.
|
358
|
-
The https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic[asciidoctor-pdf-cjk-kai_gen_gothic] project provides themes optimized for CJK languages based on the kai_gen_gothic font.
|
359
|
-
See the https://github.com/chloerei/asciidoctor-pdf-cjk-kai_gen_gothic[asciidoctor-pdf-cjk-kai_gen_gothic] project README for detailed setup instructions.
|
360
|
-
|
361
|
-
WARNING: The theme provided by the `asciidoctor-pdf-cjk-kai_gen_gothic` gem is no longer compatiable with the stable release of Asciidoctor PDF.
|
362
|
-
However, you can still use it to create a <<Create a Custom CJK Theme,custom CJK theme>>.
|
363
|
-
|
364
|
-
Once you have that gem installed (and the fonts), you need to tell Asciidoctor PDF to use one of the themes.
|
365
|
-
If you're converting a document that is primarily written in Japanese, you'd run Asciidoctor PDF as follows:
|
366
|
-
|
367
|
-
asciidoctor-pdf -r asciidoctor-pdf-cjk-kai_gen_gothic -a pdf-theme=KaiGenGothicJP document.adoc
|
368
|
-
|
369
|
-
If that command fails, you may have better luck creating your own CJK theme.
|
370
|
-
|
371
|
-
=== Create a Custom CJK Theme
|
372
|
-
|
373
|
-
You also have to option of creating your own theme gem that uses fonts of your choice.
|
374
|
-
For example, if you want to use the `asciidoctor-pdf-cjk-kai_gen_gothic` gem to fetch fonts, but then use them in your own theme, here's how you'd do it.
|
375
|
-
|
376
|
-
. Install the `asciidoctor-pdf-cjk-kai_gen_gothic` gem:
|
377
|
-
|
378
|
-
$ gem install asciidoctor-pdf-cjk-kai_gen_gothic
|
379
|
-
|
380
|
-
. Download / install the fonts:
|
381
|
-
|
382
|
-
$ asciidoctor-pdf-cjk-kai_gen_gothic-install
|
383
|
-
|
384
|
-
. Create a theme file named [.path]_cjk-theme.yml_ that extends the default theme to override the fonts:
|
385
|
-
+
|
386
|
-
[source,yml]
|
387
|
-
----
|
388
|
-
extends: default
|
389
|
-
font:
|
390
|
-
catalog:
|
391
|
-
merge: true
|
392
|
-
KaiGen Gothic CN:
|
393
|
-
normal: KaiGenGothicCN-Regular.ttf
|
394
|
-
bold: KaiGenGothicCN-Bold.ttf
|
395
|
-
italic: KaiGenGothicCN-Regular-Italic.ttf
|
396
|
-
bold_italic: KaiGenGothicCN-Bold-Italic.ttf
|
397
|
-
fallbacks:
|
398
|
-
- KaiGen Gothic CN
|
399
|
-
base:
|
400
|
-
font-family: KaiGen Gothic CN
|
401
|
-
heading:
|
402
|
-
font-family: $base-font-family
|
403
|
-
abstract:
|
404
|
-
title:
|
405
|
-
font-family: $heading-font-family
|
406
|
-
sidebar:
|
407
|
-
title:
|
408
|
-
font-family: $heading-font-family
|
409
|
-
----
|
410
|
-
|
411
|
-
. Load your theme when running Asciidoctor PDF:
|
412
|
-
|
413
|
-
$ asciidoctor-pdf -a scripts=cjk -a pdf-theme=./cjk-theme.yml -a pdf-fontsdir=GEM_FONTS_DIR,`ruby -r asciidoctor-pdf-cjk-kai_gen_gothic -e "print File.expand_path '../fonts', (Gem.datadir 'asciidoctor-pdf-cjk-kai_gen_gothic')"` document.adoc
|
414
|
-
|
415
|
-
The `-a pdf-fontsdir` option is important to tell Asciidoctor PDF where to find your custom fonts.
|
416
|
-
(Note that the inclusion of GEM_FONTS_DIR in the value is only required when using Asciidoctor PDF 1.5).
|
417
|
-
|
418
|
-
Rather than using the installer from the `asciidoctor-pdf-cjk-kai_gen_gothic` gem, you can download fonts whatever way you choose.
|
419
|
-
When using your own fonts, be sure to consult the <<docs/theming-guide.adoc#preparing-a-custom-font,Preparing a Custom Font>> section of the theming guide to find recommended modifications.
|
420
346
|
|
421
347
|
== Font-Based Icons
|
422
348
|
|
@@ -672,45 +598,6 @@ Here's how to move it to the bottom right:
|
|
672
598
|
|
673
599
|
If an image dimension matches the height or width of the page, the positioning keyword for that axis has no effect.
|
674
600
|
|
675
|
-
== Fonts in SVG Images
|
676
|
-
|
677
|
-
Asciidoctor PDF uses {url-prawn-svg}[prawn-svg] to embed SVGs in the PDF document, including SVGs generated by Asciidoctor Diagram.
|
678
|
-
|
679
|
-
Actually, it's not accurate to say that prawn-svg embeds the SVG.
|
680
|
-
Rather, prawn-svg is an SVG _renderer_.
|
681
|
-
prawn-svg translates an SVG into native PDF text and graphic objects.
|
682
|
-
You can think of the SVG as a sequence of drawing commands.
|
683
|
-
The result becomes indistinguishable from other PDF objects.
|
684
|
-
|
685
|
-
What that means for text is that any font family used for text in the SVG _must_ be registered in the Asciidoctor PDF theme file (and thus with Prawn).
|
686
|
-
Otherwise, Prawn will fallback to using the closest matching built-in (afm) font from PDF (e.g., sans-serif becomes Helvetica).
|
687
|
-
Recall that afm fonts only support basic Latin.
|
688
|
-
As we like to say, PDF is <<docs/theming-guide.adoc#built-in-afm-fonts,bring your own font>>.
|
689
|
-
|
690
|
-
If you're using Asciidoctor Diagram to generate SVGs to embed in the PDF, you likely need to specify the default font the diagramming tool uses.
|
691
|
-
Let's assume you are making a plantuml diagram.
|
692
|
-
|
693
|
-
To set the font used in the diagram, first create a file named [.path]_plantuml.cfg_ and populate it with the following content:
|
694
|
-
|
695
|
-
----
|
696
|
-
skinparam defaultFontName Noto Serif
|
697
|
-
----
|
698
|
-
|
699
|
-
TIP: You can choose any font name that is registered in your Asciidoctor PDF theme file.
|
700
|
-
When using the default theme, your options are "Noto Serif", "M+ 1mn", and "M+ 1p Fallback".
|
701
|
-
|
702
|
-
Next, pass that path to the `plantumlconfig` attribute in your AsciiDoc document (or set the attribute via the CLI or API):
|
703
|
-
|
704
|
-
----
|
705
|
-
:plantumlconfig: plantuml.cfg
|
706
|
-
----
|
707
|
-
|
708
|
-
Clear the cache of your diagrams and run Asciidoctor PDF with Asciidoctor Diagram enabled.
|
709
|
-
The diagrams will be generated using Noto Serif as the default font, and Asciidoctor PDF will know what to do.
|
710
|
-
|
711
|
-
The bottom line is this:
|
712
|
-
If you're using fonts in your SVG, and you want those fonts to be preserved, those fonts must be defined in the Asciidoctor PDF theme file.
|
713
|
-
|
714
601
|
== Supporting Additional Image File Formats
|
715
602
|
|
716
603
|
In order to embed an image into a PDF, Asciidoctor PDF must understand how to decode it.
|
data/data/themes/base-theme.yml
CHANGED
@@ -96,7 +96,7 @@ table_head_border_bottom_width: 1.25
|
|
96
96
|
table_body_stripe_background_color: 'EEEEEE'
|
97
97
|
thematic_break_border_style: solid
|
98
98
|
thematic_break_border_width: 0.5
|
99
|
-
|
99
|
+
thematic_break_padding: 0
|
100
100
|
toc_indent: 15
|
101
101
|
toc_line_height: 1.4
|
102
102
|
footnotes_font_size: 9
|
@@ -3,7 +3,7 @@ base_border_color: BBBBBB
|
|
3
3
|
base_font_color: 000000
|
4
4
|
role_subtitle_font_color: 666666
|
5
5
|
link_font_color: ~
|
6
|
-
|
6
|
+
codespan_font_color: ~
|
7
7
|
mark_background_color: CCCCCC
|
8
8
|
menu_caret_content: " <font size=\"1.15em\">\u203a</font> "
|
9
9
|
heading_font_color: $base_font_color
|
@@ -11,10 +11,10 @@ title_page_title_font_color: $role_subtitle_font_color
|
|
11
11
|
abstract_font_color: 2C2C2C
|
12
12
|
abstract_title_font_color: $heading_font_color
|
13
13
|
admonition_column_rule_color: $base_border_color
|
14
|
-
|
15
|
-
|
14
|
+
quote_border_color: $base_border_color
|
15
|
+
quote_cite_font_color: $role_subtitle_font_color
|
16
16
|
verse_border_color: $base_border_color
|
17
|
-
verse_cite_font_color: $
|
17
|
+
verse_cite_font_color: $quote_cite_font_color
|
18
18
|
code_font_color: $base_font_color
|
19
19
|
conum_font_color: $base_font_color
|
20
20
|
example_border_color: $base_border_color
|
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
- default-with-fallback-font
|
1
|
+
# DEPRECATED
|
2
|
+
extends: default-for-print-with-font-fallbacks
|
@@ -226,8 +226,7 @@ thematic_break:
|
|
226
226
|
border_color: $base_border_color
|
227
227
|
border_style: solid
|
228
228
|
border_width: $base_border_width
|
229
|
-
|
230
|
-
margin_bottom: $vertical_rhythm * 1.5
|
229
|
+
padding: [$vertical_rhythm * 0.5, 0]
|
231
230
|
list:
|
232
231
|
indent: $horizontal_rhythm * 1.5
|
233
232
|
#marker_font_color: 404040
|
@@ -262,6 +261,8 @@ toc:
|
|
262
261
|
footnotes:
|
263
262
|
font_size: round($base_font_size * 0.75)
|
264
263
|
item_spacing: $list_item_spacing / 2
|
264
|
+
index:
|
265
|
+
column_gap: $vertical_rhythm
|
265
266
|
header:
|
266
267
|
font_size: $base_font_size_small
|
267
268
|
line_height: 1
|
@@ -1,9 +1,2 @@
|
|
1
|
-
|
2
|
-
font
|
3
|
-
catalog:
|
4
|
-
merge: true
|
5
|
-
# M+ 1p supports Latin, Latin-1 Supplement, Latin Extended, Greek, Cyrillic, Vietnamese, Japanese & an assortment of symbols
|
6
|
-
# It also provides arrows for ->, <-, => and <= replacements in case these glyphs are missing from font
|
7
|
-
M+ 1p Fallback: GEM_FONTS_DIR/mplus1p-regular-fallback.ttf
|
8
|
-
Noto Emoji: GEM_FONTS_DIR/notoemoji-subset.ttf
|
9
|
-
fallbacks: [M+ 1p Fallback, Noto Emoji]
|
1
|
+
# DEPRECATED
|
2
|
+
extends: default-with-font-fallbacks
|
@@ -0,0 +1,9 @@
|
|
1
|
+
extends: default
|
2
|
+
font:
|
3
|
+
catalog:
|
4
|
+
merge: true
|
5
|
+
# M+ 1p supports Latin, Latin-1 Supplement, Latin Extended, Greek, Cyrillic, Vietnamese, Japanese & an assortment of symbols
|
6
|
+
# It also provides arrows for ->, <-, => and <= replacements in case these glyphs are missing from font
|
7
|
+
M+ 1p Fallback: GEM_FONTS_DIR/mplus1p-regular-fallback.ttf
|
8
|
+
Noto Emoji: GEM_FONTS_DIR/notoemoji-subset.ttf
|
9
|
+
fallbacks: [M+ 1p Fallback, Noto Emoji]
|