asciidoctor-pdf 1.5.0.rc.3 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +13 -0
- data/README.adoc +19 -18
- data/docs/theming-guide.adoc +7 -3
- data/lib/asciidoctor/pdf/converter.rb +67 -32
- data/lib/asciidoctor/pdf/ext/asciidoctor/image.rb +10 -2
- data/lib/asciidoctor/pdf/ext/pdf-core/page.rb +2 -1
- data/lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb +1 -1
- data/lib/asciidoctor/pdf/ext/prawn/extensions.rb +7 -8
- data/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb +12 -3
- data/lib/asciidoctor/pdf/formatted_text/inline_image_arranger.rb +1 -0
- data/lib/asciidoctor/pdf/formatted_text/inline_image_renderer.rb +1 -1
- data/lib/asciidoctor/pdf/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b745a95bf56222abcbf7b3bb4d86f1b6fa1212db2f7647e80f5afd8b2a7aaf5f
|
4
|
+
data.tar.gz: f7c78b8f11502cea2922d97fe11f28bcf2d3e55f1597ba4f454d0c32e21e4f91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccd5ed955367f8580e72583c28ea2754089326e79e80cb443499c41054d545b0bc88ff0225502058b6f5d856dbfd52120a6f52441eb9cd25f50ec5b2afabe83b
|
7
|
+
data.tar.gz: d3c062fca45030355a179b677794c5fc458872b3990d15f31056c6aef92800765b14bda103d999bfcfa100875f55338f7587779c44fa23ff8ef50ffb27c9fde5
|
data/CHANGELOG.adoc
CHANGED
@@ -5,6 +5,19 @@
|
|
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 (2020-02-11) - @mojavelinux
|
9
|
+
|
10
|
+
* support table with multiple head rows & decorate accordingly (#1539)
|
11
|
+
* draw background and border around entire delimited block with wrapped text that appears inside an AsciiDoc table cell (#820)
|
12
|
+
* fix crash when document has PDF cover page and SVG page background (#1546)
|
13
|
+
* allow page mode to be fully configured using pdf-page-mode attribute or page_mode theme key (#840)
|
14
|
+
* allow background image to be specified using a data URI
|
15
|
+
* allow running content image to be specified using a data URI
|
16
|
+
* support creating empty front or back cover by assigning empty value to front-cover-image or back-cover-image attribute
|
17
|
+
* only warn once per missing character (#1545)
|
18
|
+
* render pass block as listing block, using raw source as contents
|
19
|
+
* prevent image placeholder from altering character spacing in inline SVG (#1550)
|
20
|
+
|
8
21
|
== 1.5.0.rc.3 (2020-02-04) - @mojavelinux
|
9
22
|
|
10
23
|
* reserve space for inline image correctly so it doesn't mangle the character spacing in the line when the image wraps (#1516)
|
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, 2020-02-11
|
4
4
|
// Settings:
|
5
5
|
:experimental:
|
6
6
|
:idprefix:
|
@@ -23,7 +23,7 @@ endif::[]
|
|
23
23
|
:project-name: Asciidoctor PDF
|
24
24
|
:project-handle: asciidoctor-pdf
|
25
25
|
// Variables:
|
26
|
-
:release-version: 1.5.0
|
26
|
+
:release-version: 1.5.0
|
27
27
|
// URIs:
|
28
28
|
:url-asciidoctor: http://asciidoctor.org
|
29
29
|
:url-gem: http://rubygems.org/gems/asciidoctor-pdf
|
@@ -40,14 +40,14 @@ endif::[]
|
|
40
40
|
|
41
41
|
ifdef::status[]
|
42
42
|
image:https://img.shields.io/travis/asciidoctor/asciidoctor-pdf/master.svg[Build Status (Travis CI),link=https://travis-ci.org/asciidoctor/asciidoctor-pdf]
|
43
|
-
image:https://
|
43
|
+
image:https://github.com/asciidoctor/asciidoctor-pdf/workflows/CI/badge.svg[Build Status (GitHub Actions),link=https://github.com/asciidoctor/asciidoctor-pdf/actions?query=workflow%3ACI]
|
44
44
|
image:https://img.shields.io/gem/v/asciidoctor-pdf.svg[Latest Release, link={url-gem}]
|
45
45
|
image:https://img.shields.io/badge/license-MIT-blue.svg[MIT License, link=#copyright]
|
46
46
|
endif::[]
|
47
47
|
|
48
48
|
Asciidoctor PDF is a native PDF converter for AsciiDoc.
|
49
|
-
It bypasses the requirement to generate an
|
50
|
-
Instead, you can use this extension to convert directly from AsciiDoc to PDF.
|
49
|
+
It bypasses the requirement to generate an intermediary format such as DocBook, Apache FO, or LaTeX.
|
50
|
+
Instead, you can use this extension to convert your documents directly from AsciiDoc to PDF.
|
51
51
|
Its aim is to take the pain out of creating PDF documents from AsciiDoc.
|
52
52
|
|
53
53
|
toc::[]
|
@@ -55,28 +55,32 @@ toc::[]
|
|
55
55
|
== Overview
|
56
56
|
|
57
57
|
{project-name} is an Asciidoctor extension that converts an AsciiDoc document directly to a PDF document.
|
58
|
-
The style and layout of the PDF is controlled by a
|
59
|
-
To the degree possible, this converter supports all the features of AsciiDoc supported by the built-in converters
|
58
|
+
The style and layout of the PDF is controlled by a dedicated theme file.
|
59
|
+
To the degree possible, this converter supports all the features of AsciiDoc that are supported by the built-in converters.
|
60
|
+
However, there are <<known-limitations,certain limits>> imposed by the PDF format and the PDF library this extension uses.
|
60
61
|
|
61
|
-
Under the covers, {project-name} uses the Prawn gem
|
62
|
+
Under the covers, {project-name} uses the Prawn gem and its extensions (e.g., prawn-svg and prawn-table) to generate the PDF document.
|
62
63
|
{url-prawn}[Prawn] is a general purpose PDF generator for Ruby that features high-level APIs for common needs like setting up the page and inserting images and low-level APIs for positioning and rendering text and graphics.
|
63
64
|
|
64
65
|
Prawn takes the pain out of creating (basic) PDF documents.
|
65
66
|
Likewise, {project-name} takes the pain out of creating PDF documents _directly from AsciiDoc_.
|
66
67
|
Skip ahead to <<getting-started,Getting started>> to start putting {project-name} use.
|
67
|
-
But don't miss the <<Highlights>>
|
68
|
+
But don't miss the <<Highlights>> to get a preview of what's possible.
|
68
69
|
|
69
70
|
== Highlights
|
70
71
|
|
71
72
|
* Direct AsciiDoc to PDF conversion
|
72
73
|
* <<docs/theming-guide.adoc#,Configuration-driven theme (style and layout)>>
|
73
|
-
*
|
74
|
+
* Custom (TTF) fonts
|
75
|
+
* Full SVG support (thanks to https://github.com/mogest/prawn-svg[prawn-svg])
|
74
76
|
* PDF document outline (i.e., bookmarks)
|
75
77
|
* Title page
|
76
78
|
* Table of contents page(s)
|
77
|
-
* Document metadata (title, authors, subject, keywords, etc)
|
79
|
+
* Document metadata (title, authors, subject, keywords, etc.)
|
80
|
+
* Configurable page size (e.g., A4, Letter, Legal, etc)
|
78
81
|
* Internal cross reference links
|
79
|
-
* Syntax highlighting with Rouge, Pygments, or CodeRay
|
82
|
+
* Syntax highlighting with Rouge (preferred), Pygments, or CodeRay
|
83
|
+
* Cover pages
|
80
84
|
* Page background color or page background image with named scaling
|
81
85
|
* Page numbering
|
82
86
|
* Double-sided (aka prepress) printing mode (i.e., margins alternate on recto and verso pages)
|
@@ -86,11 +90,10 @@ But don't miss the <<Highlights>> and <<Known Limitations>> sections to understa
|
|
86
90
|
* Autofit verbatim blocks (as permitted by base_font_size_min setting)
|
87
91
|
* Table border settings honored
|
88
92
|
* Font-based icons
|
89
|
-
* Custom (TTF) fonts
|
90
93
|
* Auto-generated index
|
91
94
|
* Automatic hyphenation (when enabled)
|
92
|
-
* Compression / optimization of output file
|
93
95
|
* Permissive line breaking for CJK languages
|
96
|
+
* Compression / optimization of output file
|
94
97
|
|
95
98
|
== Known Limitations
|
96
99
|
|
@@ -105,6 +108,7 @@ But don't miss the <<Highlights>> and <<Known Limitations>> sections to understa
|
|
105
108
|
* Prawn does not support double-wide box drawing glyphs correctly, so box drawings aren't aligned properly in verbatim blocks (see https://github.com/prawnpdf/prawn/issues/1002[prawn#1002]
|
106
109
|
* Orphan / widow support is limited; a page break can occur between a section title and its section content, a table caption and the caption, etc.; use a manual page break to avoid
|
107
110
|
* If a no-break hyphen is surrounded by formatted text on both sides (or is formatted individually), it will not prevent a line break
|
111
|
+
* Images cannot float
|
108
112
|
|
109
113
|
== Prerequisites
|
110
114
|
|
@@ -137,13 +141,10 @@ ifndef::env-site[You can also <<development,run the code from source>> if you wa
|
|
137
141
|
|
138
142
|
=== Install the Published Gem
|
139
143
|
|
140
|
-
{project-name} is published to RubyGems.org as a pre-release.
|
141
|
-
Since it's in pre-release, you have to specify the `--pre` flag when installing using the `gem` command.
|
142
|
-
|
143
144
|
To install {project-name}, first make sure you have satisfied the <<Prerequisites,prerequisites>>.
|
144
145
|
Then, install the gem from RubyGems.org using the following command:
|
145
146
|
|
146
|
-
$ gem install asciidoctor-pdf
|
147
|
+
$ gem install asciidoctor-pdf
|
147
148
|
|
148
149
|
==== Installation Troubleshooting
|
149
150
|
|
data/docs/theming-guide.adoc
CHANGED
@@ -1225,10 +1225,10 @@ See <<Title Page>> for details.
|
|
1225
1225
|
margin-outer: 0.59in
|
1226
1226
|
|
1227
1227
|
|mode
|
1228
|
-
|fullscreen
|
1229
|
-
(default:
|
1228
|
+
|outline {vbar} none {vbar} thumbs {vbar} fullscreen {vbar} fullscreen outline {vbar} fullscreen none {vbar} fullscreen thumbs +
|
1229
|
+
(default: outline)
|
1230
1230
|
|page:
|
1231
|
-
mode: fullscreen
|
1231
|
+
mode: fullscreen none
|
1232
1232
|
|
1233
1233
|
|size
|
1234
1234
|
|https://github.com/prawnpdf/pdf-core/blob/0.6.0/lib/pdf/core/page_geometry.rb#L16-L68[Named size^] {vbar} <<measurement-units,Measurement[width,height]>> +
|
@@ -4963,6 +4963,10 @@ These settings override equivalent keys defined in the theme file, where applica
|
|
4963
4963
|
|<<measurement-units,Measurement>> {vbar} <<measurement-units,Measurement[top,right,bottom,left]>>
|
4964
4964
|
|:pdf-page-margin: [1in, 0.5in]
|
4965
4965
|
|
4966
|
+
|pdf-page-mode
|
4967
|
+
|outline {vbar} none {vbar} thumbs {vbar} fullscreen {vbar} fullscreen outline {vbar} fullscreen none {vbar} fullscreen thumbs (default: outline)
|
4968
|
+
|:pdf-page-mode: fullscreen none
|
4969
|
+
|
4966
4970
|
|pdf-page-size
|
4967
4971
|
|https://github.com/prawnpdf/pdf-core/blob/0.6.0/lib/pdf/core/page_geometry.rb#L16-L68[Named size^] {vbar} <<measurement-units,Measurement[width, height]>>
|
4968
4972
|
|:pdf-page-size: [6in, 9in]
|
@@ -48,6 +48,15 @@ module Asciidoctor
|
|
48
48
|
AlignmentTable = { '<' => :left, '=' => :center, '>' => :right }
|
49
49
|
ColumnPositions = [:left, :center, :right]
|
50
50
|
PageLayouts = [:portrait, :landscape]
|
51
|
+
(PageModes = {
|
52
|
+
'fullscreen' => [:FullScreen, :UseOutlines],
|
53
|
+
'fullscreen none' => [:FullScreen, :UseNone],
|
54
|
+
'fullscreen outline' => [:FullScreen, :UseOutlines],
|
55
|
+
'fullscreen thumbs' => [:FullScreen, :UseThumbs],
|
56
|
+
'none' => :UseNone,
|
57
|
+
'outline' => :UseOutlines,
|
58
|
+
'thumbs' => :UseThumbs,
|
59
|
+
}).default = :UseOutlines
|
51
60
|
PageSides = [:recto, :verso]
|
52
61
|
(PDFVersions = { '1.3' => 1.3, '1.4' => 1.4, '1.5' => 1.5, '1.6' => 1.6, '1.7' => 1.7 }).default = 1.4
|
53
62
|
AuthorAttributeNames = %w(author authorinitials firstname middlename lastname email)
|
@@ -275,7 +284,6 @@ module Asciidoctor
|
|
275
284
|
layout_running_content :footer, doc, skip: num_front_matter_pages, body_start_page_number: body_start_page_number unless doc.nofooter || @theme.footer_height.to_f == 0
|
276
285
|
end
|
277
286
|
|
278
|
-
catalog.data[:PageMode] = :FullScreen if (doc.attr 'pdf-page-mode', @theme.page_mode) == 'fullscreen'
|
279
287
|
add_outline doc, (doc.attr 'outlinelevels', toc_num_levels), toc_page_nums, num_front_matter_pages[1], has_front_cover
|
280
288
|
if !state.pages.empty? && (initial_zoom = @theme.page_initial_zoom)
|
281
289
|
case initial_zoom.to_sym
|
@@ -513,7 +521,8 @@ module Asciidoctor
|
|
513
521
|
end
|
514
522
|
if (bg_image = @page_bg_image[page_side])
|
515
523
|
tare = true
|
516
|
-
|
524
|
+
# NOTE: float is necessary since prawn-svg may mess with cursor position
|
525
|
+
float { canvas { image bg_image[0], ({ position: :center, vposition: :center }.merge bg_image[1]) } }
|
517
526
|
end
|
518
527
|
page.tare_content_stream if tare
|
519
528
|
end
|
@@ -1778,6 +1787,14 @@ module Asciidoctor
|
|
1778
1787
|
|
1779
1788
|
alias convert_listing convert_listing_or_literal
|
1780
1789
|
alias convert_literal convert_listing_or_literal
|
1790
|
+
|
1791
|
+
def convert_pass node
|
1792
|
+
node = node.dup
|
1793
|
+
(subs = node.subs.dup).unshift :specialcharacters
|
1794
|
+
node.instance_variable_set :@subs, subs.uniq
|
1795
|
+
convert_listing_or_literal node
|
1796
|
+
end
|
1797
|
+
|
1781
1798
|
alias convert_stem convert_listing_or_literal
|
1782
1799
|
|
1783
1800
|
# Extract callout marks from string, indexed by 0-based line number
|
@@ -1865,7 +1882,7 @@ module Asciidoctor
|
|
1865
1882
|
# TODO: we could skip a lot of the logic below when num_rows == 0
|
1866
1883
|
num_rows = node.attr 'rowcount'
|
1867
1884
|
num_cols = node.columns.size
|
1868
|
-
|
1885
|
+
table_header_size = false
|
1869
1886
|
theme = @theme
|
1870
1887
|
|
1871
1888
|
tbl_bg_color = resolve_theme_color :table_background_color
|
@@ -1888,8 +1905,14 @@ module Asciidoctor
|
|
1888
1905
|
table_data = []
|
1889
1906
|
theme_font :table do
|
1890
1907
|
head_rows = node.rows[:head]
|
1908
|
+
body_rows = node.rows[:body]
|
1909
|
+
#if (hrows = node.attr 'hrows', false, nil) && (shift_rows = hrows.to_i - head_rows.size) > 0
|
1910
|
+
# head_rows = head_rows.dup
|
1911
|
+
# body_rows = body_rows.dup
|
1912
|
+
# shift_rows.times { head_rows << body_rows.shift unless body_rows.empty? }
|
1913
|
+
#end
|
1891
1914
|
theme_font :table_head do
|
1892
|
-
|
1915
|
+
table_header_size = head_rows.size
|
1893
1916
|
head_font_info = font_info
|
1894
1917
|
head_line_metrics = calc_line_metrics theme.base_line_height
|
1895
1918
|
head_cell_padding = theme.table_head_cell_padding || theme.table_cell_padding
|
@@ -1932,7 +1955,7 @@ module Asciidoctor
|
|
1932
1955
|
text_color: @font_color,
|
1933
1956
|
}
|
1934
1957
|
body_cell_line_metrics = calc_line_metrics theme.base_line_height
|
1935
|
-
(
|
1958
|
+
(body_rows + node.rows[:foot]).each do |row|
|
1936
1959
|
table_data << (row.map do |cell|
|
1937
1960
|
cell_data = base_cell_data.merge \
|
1938
1961
|
colspan: cell.colspan || 1,
|
@@ -2048,7 +2071,7 @@ module Asciidoctor
|
|
2048
2071
|
table_border_color = theme.table_border_color || theme.table_grid_color || theme.base_border_color
|
2049
2072
|
table_border_style = (theme.table_border_style || :solid).to_sym
|
2050
2073
|
table_border_width = theme.table_border_width
|
2051
|
-
if
|
2074
|
+
if table_header_size
|
2052
2075
|
head_border_bottom_color = theme.table_head_border_bottom_color || table_border_color
|
2053
2076
|
head_border_bottom_style = (theme.table_head_border_bottom_style || table_border_style).to_sym
|
2054
2077
|
head_border_bottom_width = theme.table_head_border_bottom_width || table_border_width
|
@@ -2105,7 +2128,7 @@ module Asciidoctor
|
|
2105
2128
|
caption_max_width = theme.table_caption_max_width || 'fit-content'
|
2106
2129
|
|
2107
2130
|
table_settings = {
|
2108
|
-
header:
|
2131
|
+
header: table_header_size,
|
2109
2132
|
# NOTE: position is handled by this method
|
2110
2133
|
position: :left,
|
2111
2134
|
cell_style: {
|
@@ -2151,28 +2174,26 @@ module Asciidoctor
|
|
2151
2174
|
end
|
2152
2175
|
end
|
2153
2176
|
if grid == 'none' && frame == 'none'
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
end
|
2160
|
-
end
|
2177
|
+
rows(table_header_size).tap do |r|
|
2178
|
+
r.border_bottom_color = head_border_bottom_color
|
2179
|
+
r.border_bottom_line = head_border_bottom_style
|
2180
|
+
r.border_bottom_width = head_border_bottom_width
|
2181
|
+
end if table_header_size
|
2161
2182
|
else
|
2162
2183
|
# apply the grid setting first across all cells
|
2163
2184
|
cells.border_width = [border_width[:rows], border_width[:cols], border_width[:rows], border_width[:cols]]
|
2164
2185
|
|
2165
|
-
if
|
2166
|
-
rows(
|
2186
|
+
if table_header_size
|
2187
|
+
rows(table_header_size - 1).tap do |r|
|
2167
2188
|
r.border_bottom_color = head_border_bottom_color
|
2168
2189
|
r.border_bottom_line = head_border_bottom_style
|
2169
2190
|
r.border_bottom_width = head_border_bottom_width
|
2170
2191
|
end
|
2171
|
-
rows(
|
2192
|
+
rows(table_header_size).tap do |r|
|
2172
2193
|
r.border_top_color = head_border_bottom_color
|
2173
2194
|
r.border_top_line = head_border_bottom_style
|
2174
2195
|
r.border_top_width = head_border_bottom_width
|
2175
|
-
end if num_rows >
|
2196
|
+
end if num_rows > table_header_size
|
2176
2197
|
end
|
2177
2198
|
|
2178
2199
|
# top edge of table
|
@@ -2490,11 +2511,12 @@ module Asciidoctor
|
|
2490
2511
|
|
2491
2512
|
def convert_inline_indexterm node
|
2492
2513
|
# NOTE indexterms not supported if text gets substituted before PDF is initialized
|
2493
|
-
|
2494
|
-
|
2514
|
+
if !(defined? @index)
|
2515
|
+
''
|
2516
|
+
elsif scratch?
|
2495
2517
|
node.type == :visible ? node.text : ''
|
2496
2518
|
else
|
2497
|
-
# NOTE page number is added
|
2519
|
+
# NOTE page number (:page key) is added by InlineDestinationMarker
|
2498
2520
|
dest = { anchor: (anchor_name = @index.next_anchor_name) }
|
2499
2521
|
anchor = %(<a id="#{anchor_name}" type="indexterm">#{DummyText}</a>)
|
2500
2522
|
if node.type == :visible
|
@@ -2713,7 +2735,13 @@ module Asciidoctor
|
|
2713
2735
|
def layout_cover_page doc, face
|
2714
2736
|
# TODO: turn processing of attribute with inline image a utility function in Asciidoctor
|
2715
2737
|
if (image_path = (doc.attr %(#{face}-cover-image)))
|
2716
|
-
if image_path
|
2738
|
+
if image_path.empty?
|
2739
|
+
go_to_page page_count if face == :back
|
2740
|
+
start_new_page_discretely
|
2741
|
+
# NOTE open graphics state to prevent page from being reused
|
2742
|
+
open_graphics_state if face == :front
|
2743
|
+
return
|
2744
|
+
elsif image_path == '~'
|
2717
2745
|
image_path = nil
|
2718
2746
|
@page_margin_by_side[:cover] = @page_margin_by_side[:recto] if @media == 'prepress'
|
2719
2747
|
elsif (image_path.include? ':') && image_path =~ ImageAttributeValueRx
|
@@ -3412,13 +3440,15 @@ module Asciidoctor
|
|
3412
3440
|
ColumnPositions.each do |position|
|
3413
3441
|
unless (val = @theme[%(#{periphery}_#{side}_#{position}_content)]).nil_or_empty?
|
3414
3442
|
if (val.include? ':') && val =~ ImageAttributeValueRx
|
3415
|
-
|
3416
|
-
|
3443
|
+
attrlist = $2
|
3444
|
+
image_attrs = (AttributeList.new attrlist).parse %w(alt width)
|
3445
|
+
image_path, image_format = ::Asciidoctor::Image.target_and_format $1, image_attrs
|
3446
|
+
if (image_path = resolve_image_path doc, image_path, @themesdir, image_format) && (::File.readable? image_path)
|
3417
3447
|
image_opts = resolve_image_options image_path, image_attrs, container_size: [colspec_dict[side][position][:width], trim_styles[:content_height]], format: image_format
|
3418
3448
|
side_content[position] = [image_path, image_opts, image_attrs['link']]
|
3419
3449
|
else
|
3420
3450
|
# NOTE allows inline image handler to report invalid reference and replace with alt text
|
3421
|
-
side_content[position] = %(image:#{image_path}[#{
|
3451
|
+
side_content[position] = %(image:#{image_path}[#{attrlist}])
|
3422
3452
|
end
|
3423
3453
|
else
|
3424
3454
|
side_content[position] = val
|
@@ -3498,7 +3528,9 @@ module Asciidoctor
|
|
3498
3528
|
toc_section.parent.blocks.delete toc_section if toc_section
|
3499
3529
|
|
3500
3530
|
catalog.data[:PageLabels] = state.store.ref Nums: pagenum_labels.flatten
|
3501
|
-
|
3531
|
+
primary_page_mode, secondary_page_mode = PageModes[(doc.attr 'pdf-page-mode') || @theme.page_mode]
|
3532
|
+
catalog.data[:PageMode] = primary_page_mode
|
3533
|
+
catalog.data[:NonFullScreenPageMode] = secondary_page_mode if secondary_page_mode
|
3502
3534
|
nil
|
3503
3535
|
end
|
3504
3536
|
|
@@ -4089,18 +4121,21 @@ module Asciidoctor
|
|
4089
4121
|
return []
|
4090
4122
|
elsif (image_path.include? ':') && image_path =~ ImageAttributeValueRx
|
4091
4123
|
image_attrs = (AttributeList.new $2).parse %w(alt width)
|
4092
|
-
image_format = image_attrs['format']
|
4093
4124
|
if from_theme
|
4094
|
-
image_path =
|
4125
|
+
image_path = sub_attributes_discretely doc, $1
|
4126
|
+
image_relative_to = @themesdir
|
4095
4127
|
else
|
4096
|
-
image_path =
|
4128
|
+
image_path = $1
|
4129
|
+
image_relative_to = true
|
4097
4130
|
end
|
4098
4131
|
elsif from_theme
|
4099
|
-
image_path =
|
4100
|
-
|
4101
|
-
image_path = resolve_image_path doc, image_path, false
|
4132
|
+
image_path = sub_attributes_discretely doc, image_path
|
4133
|
+
image_relative_to = @themesdir
|
4102
4134
|
end
|
4103
4135
|
|
4136
|
+
image_path, image_format = ::Asciidoctor::Image.target_and_format image_path, image_attrs
|
4137
|
+
image_path = resolve_image_path doc, image_path, image_relative_to, image_format
|
4138
|
+
|
4104
4139
|
return unless image_path
|
4105
4140
|
|
4106
4141
|
unless ::File.readable? image_path
|
@@ -6,8 +6,16 @@ module Asciidoctor
|
|
6
6
|
FormatAliases = { 'jpg' => 'jpeg', 'svg+xml' => 'svg' }
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def format
|
10
|
-
(attributes && attributes['format']) || ((ext = ::File.extname
|
9
|
+
def format image_path, attributes = nil
|
10
|
+
(attributes && attributes['format']) || ((ext = ::File.extname image_path).downcase.slice 1, ext.length)
|
11
|
+
end
|
12
|
+
|
13
|
+
def target_and_format image_path, attributes = nil
|
14
|
+
if (image_path.start_with? 'data:') && (m = DataUriRx.match image_path)
|
15
|
+
[(m[:data].extend ::Base64), (FormatAliases.fetch m[:fmt], m[:fmt])]
|
16
|
+
else
|
17
|
+
[image_path, (attributes && attributes['format']) || ((ext = ::File.extname image_path).downcase.slice 1, ext.length)]
|
18
|
+
end
|
11
19
|
end
|
12
20
|
end
|
13
21
|
|
@@ -43,7 +43,8 @@ class PDF::Core::Page
|
|
43
43
|
# Note that this method may leave behind an orphaned background image.
|
44
44
|
def reset_content
|
45
45
|
unless content.stream.filtered_stream == InitialPageContent
|
46
|
-
|
46
|
+
xobjects.clear
|
47
|
+
ext_gstates.clear
|
47
48
|
new_content = document.state.store[document.ref({})]
|
48
49
|
new_content << 'q' << ?\n
|
49
50
|
content.replace new_content
|
@@ -855,20 +855,19 @@ module Asciidoctor
|
|
855
855
|
scratch.start_new_page
|
856
856
|
start_page_number = scratch.page_number
|
857
857
|
start_y = scratch.y
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
end
|
858
|
+
scratch_bounds = scratch.bounds
|
859
|
+
original_x = scratch_bounds.absolute_left
|
860
|
+
original_width = scratch_bounds.width
|
861
|
+
scratch_bounds.instance_variable_set :@x, bounds.absolute_left
|
862
|
+
scratch_bounds.instance_variable_set :@width, bounds.width
|
864
863
|
scratch.font font_family, style: font_style, size: font_size do
|
865
864
|
scratch.instance_exec(&block)
|
866
865
|
end
|
867
866
|
# NOTE don't count excess if cursor exceeds writable area (due to padding)
|
868
867
|
full_page_height = scratch.effective_page_height
|
869
868
|
partial_page_height = [full_page_height, start_y - scratch.y].min
|
870
|
-
|
871
|
-
|
869
|
+
scratch_bounds.instance_variable_set :@x, original_x
|
870
|
+
scratch_bounds.instance_variable_set :@width, original_width
|
872
871
|
whole_pages = scratch.page_number - start_page_number
|
873
872
|
[(whole_pages * full_page_height + partial_page_height), whole_pages, partial_page_height]
|
874
873
|
end
|
@@ -18,11 +18,20 @@ Prawn::Text::Formatted::Box.prepend (Module.new do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def find_font_for_this_glyph char, current_font, fallback_fonts_to_check, original_font = current_font
|
21
|
-
@document.font current_font
|
21
|
+
(doc = @document).font current_font
|
22
22
|
if fallback_fonts_to_check.empty?
|
23
|
-
|
23
|
+
if logger.info? && !doc.scratch?
|
24
|
+
fonts_checked = @fallback_fonts.dup.unshift original_font
|
25
|
+
missing_chars = (doc.instance_variable_defined? :@missing_chars) ?
|
26
|
+
(doc.instance_variable_get :@missing_chars) : (doc.instance_variable_set :@missing_chars, {})
|
27
|
+
previous_fonts_checked = (missing_chars[char] ||= [])
|
28
|
+
if previous_fonts_checked.empty? && !(previous_fonts_checked.include? fonts_checked)
|
29
|
+
logger.warn %(Could not locate the character `#{char}' in the following fonts: #{fonts_checked.join ', '})
|
30
|
+
previous_fonts_checked << fonts_checked
|
31
|
+
end
|
32
|
+
end
|
24
33
|
current_font
|
25
|
-
elsif
|
34
|
+
elsif doc.font.glyph_present? char
|
26
35
|
current_font
|
27
36
|
else
|
28
37
|
find_font_for_this_glyph char, fallback_fonts_to_check.shift, fallback_fonts_to_check, original_font
|
@@ -110,6 +110,7 @@ module Asciidoctor::PDF::FormattedText
|
|
110
110
|
# NOTE we can't rely on the fragment width because the line wrap mechanism ignores it;
|
111
111
|
# it only considers the text (string) and character spacing, rebuilding the string several times
|
112
112
|
fragment[:text] = PlaceholderChar
|
113
|
+
fragment[:actual_character_spacing] = doc.character_spacing
|
113
114
|
fragment[:character_spacing] = image_w
|
114
115
|
fragment[:image_width] = fragment[:width] = image_w
|
115
116
|
fragment[:image_height] = image_h
|
@@ -32,7 +32,7 @@ module Asciidoctor::PDF::FormattedText
|
|
32
32
|
# NOTE prawn-svg messes with the cursor; use float to workaround
|
33
33
|
# NOTE prawn-svg 0.24.0, 0.25.0, & 0.25.1 didn't restore font after call to draw (see mogest/prawn-svg#80)
|
34
34
|
pdf.float do
|
35
|
-
image_obj.draw
|
35
|
+
pdf.character_spacing(data[:actual_character_spacing]) { image_obj.draw }
|
36
36
|
image_obj.document.warnings.each do |img_warning|
|
37
37
|
# NOTE shim logger can't be imported into a module, so use the one from the PDF document instead
|
38
38
|
pdf.logger.warn %(problem encountered in image: #{data[:image_path]}; #{img_warning})
|
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
|
4
|
+
version: 1.5.0
|
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: 2020-02-
|
12
|
+
date: 2020-02-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: asciidoctor
|
@@ -388,9 +388,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
388
388
|
version: '0'
|
389
389
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
390
390
|
requirements:
|
391
|
-
- - "
|
391
|
+
- - ">="
|
392
392
|
- !ruby/object:Gem::Version
|
393
|
-
version:
|
393
|
+
version: '0'
|
394
394
|
requirements: []
|
395
395
|
rubygems_version: 3.0.6
|
396
396
|
signing_key:
|