asciidoctor-pdf 1.5.3 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71d676b5bc2fd2364a3e888aebe586cdb2d85ee259b23031409b5c919cd78ce3
4
- data.tar.gz: 638470c38ac1fe4a7445c118c33c08768b6cfbee54f2435ba65158ee9423f9ee
3
+ metadata.gz: 1d8bf8a71ecd7a6c684ae42c964f62d8a988cd0077fe1412766010e5898a1cee
4
+ data.tar.gz: 5d337eb1c1bb9439ff4684ae923419f99d9c5359a5555eaab3a846136cb44521
5
5
  SHA512:
6
- metadata.gz: 756f331bf5b74742739977ef159aa138743629a0fc91159767bb70994d7b939238bef3df1b2b05b8c58ed0ee837cdcd4153b531d132cd0ad31dc9b8e39ffc2e5
7
- data.tar.gz: 34b9adfc79269f7936cb941056cda2303ec7e8e49f5c53772b3c92723b4d03ecace31ad9a5912e737b5c8fd84e855420b8169bf9d35500079df995e1de64b85d
6
+ metadata.gz: 1d9ed8610fae3052c4c3e529b9518bcb1c5a71bb123e915f6361db7828eb9a23d169b9f7b9165b7536a16f7324177d081e20c6823874225e9fb045e54ced57cb
7
+ data.tar.gz: 12d09008f98b4572b0a8d3546200868ec0d6637d9b642918cbcf2a179be3b871d8ea9a26a5a99e82b5c3580808f277e610df18ff93013c891a5eee1ea99f3e67
@@ -5,6 +5,31 @@
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.4 (2021-01-09) - @mojavelinux
9
+
10
+ Bug Fixes::
11
+
12
+ * restore compatiblity with Asciidoctor 2.0.12 when using Pygments (#1846)
13
+ * fix numeric assertions in test suite (#1542)
14
+ * keep caption with image when image is scaled down to fit page (#1803)
15
+ * prevent inline image from rendering multiple times if fallback font is used for alt text (#1858)
16
+ * disable cache tests if open-uri-cache gem is not available
17
+ * disable hyphen tests if text-hyphen gem is not available
18
+ * compensate for change in how character_spacing is applied in FontMetricCache#width_of after Prawn 2.2.2
19
+ * allow inline image to be enclosed in link macro (alt text was breaking parsing)
20
+ * use oembed API over HTTPS to get thumbnail for Vimeo video
21
+ * use conum font family defined in theme for conum in verbatim block (#1611)
22
+ * patch float precision constant so prawn-table does not fail to arrange cells that span columns (#1835)
23
+ * resolve images in theme correctly when theme is loaded from classloader (JRuby only) (#1829)
24
+
25
+ Compliance::
26
+
27
+ * upgrade to prawn-svg 0.31 (adds support for loading embedded images from a data URI) (#1810)
28
+
29
+ Build / Infrastructure::
30
+
31
+ * migrate Linux CI jobs to GitHub Actions
32
+
8
33
  == 1.5.3 (2020-02-28) - @mojavelinux
9
34
 
10
35
  Bug Fixes::
@@ -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.3, 2020-02-28
3
+ v1.5.4, 2021-01-09
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.3
26
+ :release-version: 1.5.4
27
27
  // URIs:
28
28
  :url-asciidoctor: http://asciidoctor.org
29
29
  :url-gem: http://rubygems.org/gems/asciidoctor-pdf
@@ -39,8 +39,7 @@ endif::[]
39
39
  :url-graphicsmagick: http://www.graphicsmagick.org
40
40
 
41
41
  ifdef::status[]
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://github.com/asciidoctor/asciidoctor-pdf/workflows/CI/badge.svg[Build Status (GitHub Actions),link=https://github.com/asciidoctor/asciidoctor-pdf/actions?query=workflow%3ACI]
42
+ image:{url-project-repo}/workflows/CI/badge.svg?branch=v1.5.x[Build Status (GitHub Actions),link={url-project-repo}/actions?query=workflow%3ACI+branch%3Av1.5.x]
44
43
  image:https://img.shields.io/gem/v/asciidoctor-pdf.svg[Latest Release, link={url-gem}]
45
44
  image:https://img.shields.io/badge/license-MIT-blue.svg[MIT License, link=#copyright]
46
45
  endif::[]
@@ -98,7 +97,7 @@ But don't miss the <<Highlights>> to get a preview of what's possible.
98
97
  == Known Limitations
99
98
 
100
99
  * Footnotes are always rendered as endnotes (at end of chapter for books; at end of document for all other doctypes)
101
- * Table cells that exceed height of a single page will be truncated (see https://github.com/prawnpdf/prawn-table/issues/41[prawn-table#41])
100
+ * Table cells that exceed the height of a single page will be truncated (see https://github.com/prawnpdf/prawn-table/issues/41[prawn-table#41])
102
101
  * Inline images in table cells must fit within available space or Prawn::Errors::CannotFit error will be thrown
103
102
  * Columns cannot be assigned a 0% width (or a width less than the width of a single character); in the same vein, a column cannot be set to autowidth if width of all other columns meets or exceeds 100%; the result is that the converter with throw a Prawn::Errors::CannotFit error
104
103
  * An inline image in a table cell will not force the column wider if the width of the image exceeds the width of the column; either reduce the image width using `pdfwidth` or increase the width of the column using `cols`; another solution is to convert the cell to an AsciiDoc table cell (see https://github.com/asciidoctor/asciidoctor-pdf/issues/830)
@@ -202,12 +201,12 @@ You then activate syntax highlighting for a given document by adding the `source
202
201
  ==== Upgrade Prawn and Extensions (optional)
203
202
 
204
203
  {project-name} uses Prawn to handle the PDF generation, which has a different release cycle.
205
- At times, there may are development features in Prawn and its extensions you need to use which haven't yet been released.
204
+ At times, there may be development features in Prawn and its extensions you need to use which haven't yet been released.
206
205
  No problem.
207
206
  You can still gain access to these features by installing the unreleased gems directly from GitHub.
208
207
 
209
208
  To get started, first create a [.path]_Gemfile_ in the root of your project.
210
- In that file, declare the gem soruce, the {project-handle} gem, and the prawn gem and/or one of its extension gems.
209
+ In that file, declare the gem source, the {project-handle} gem, and the prawn gem and/or one of its extension gems.
211
210
  In this example, we'll install both the prawn and prawn-table gems from GitHub.
212
211
 
213
212
  .Gemfile
@@ -262,7 +261,7 @@ It's time to convert the AsciiDoc document directly to PDF.
262
261
 
263
262
  IMPORTANT: You'll need the `rouge` gem installed to run this example since it uses the `source-highlighter` attribute with the value of `rouge`.
264
263
 
265
- Converting to PDF is a simple as running the `asciidoctor-pdf` script using Ruby and passing our AsciiDoc document as the first argument.
264
+ Converting to PDF is as simple as running the `asciidoctor-pdf` script using Ruby and passing our AsciiDoc document as the first argument.
266
265
 
267
266
  $ asciidoctor-pdf basic-example.adoc
268
267
 
@@ -305,7 +304,7 @@ Asciidoctor can process the full range of characters in the UTF-8 character set.
305
304
  That means you can write your document in any language, save the file with UTF-8 encoding (_that's important!_), and expect Asciidoctor to convert the text properly.
306
305
  But you still need a font that provides the glyphs for those characters.
307
306
 
308
- When converting a document with Asciidoctor PDF, you may notice that some of the glyphs for certain languages, such as Chinese, are missing from the PDF.
307
+ When converting a document with Asciidoctor PDF, you may notice that some glyphs for certain languages, such as Chinese, are missing from the PDF.
309
308
  PDF is a "`bring your own font`" kind of system.
310
309
  In other words, the font you provide must provide glyphs for all the characters used.
311
310
  There's no one font that supports all the world's languages (though some, like Noto Serif, certainly come close).
@@ -471,7 +470,7 @@ Otherwise, the SVG library will fail to process it.
471
470
  As of Asciidoctor PDF 1.5.0.alpha.17 running on Asciidoctor 2 or better, Asciidoctor PDF provides better integration with Asciidoctor Diagram by setting the `data-uri` attribute by default.
472
471
  When the `data-uri` attribute is set, Asciidoctor Diagram returns the absolute path to the generated image, which Asciidoctor PDF can then locate.
473
472
  (This makes sense since technically, Asciidoctor Diagram must embed the image in the document, similar in spirit to the `data-uri` feature for HTML).
474
- This means the input directory and the output directory (and thus the imagesoutdir) can differ and Asciidoctor PDF will still be able to locate the generate image.
473
+ This means the input directory and the output directory (and thus the imagesoutdir) can differ and Asciidoctor PDF will still be able to locate the generated image.
475
474
 
476
475
  Prior to Asciidoctor PDF 1.5.0.alpha.17 (or prior to Asciidoctor 2), the way to solve this problem is to set the `imagesdir` attribute to an absolute path.
477
476
  That way, it won't matter where the generated image is written.
@@ -571,7 +570,7 @@ If the image height exceeds the height of the page, the image will be scaled dow
571
570
 
572
571
  In addition to the width-related attributes previously covered, cover and background images can be sized relative to the page using the `fit` attribute of the image macro.
573
572
  The `fit` attribute works similarly to the `object-fit` property in CSS.
574
- It's value must be specified as a single keyword, chosen from the table below.
573
+ Its value must be specified as a single keyword, chosen from the table below.
575
574
  The starting size of the image is determined by the explicit width, if specified, or the implicit width.
576
575
  The height is always derived from the width while respecting the implicit aspect ratio of the image.
577
576
  The available space for a background image (i.e., the canvas) is the page.
@@ -889,7 +888,7 @@ Here's an example of how to skip a passthrough block when converting to PDF:
889
888
  \endif::[]
890
889
  ----
891
890
 
892
- Here's an example of how to only enable a passthrough block when convertering to HTML5:
891
+ Here's an example of how to only enable a passthrough block when converting to HTML5:
893
892
 
894
893
  [source,asciidoc]
895
894
  ----
@@ -1011,7 +1010,7 @@ This value is used as the heading of the preface and as the text of the entry in
1011
1010
 
1012
1011
  Asciidoctor PDF supports generating an index catalog that itemizes all index terms defined in the document, allowing the reader to navigate the document by keyword.
1013
1012
 
1014
- To get Asciidoctor PDF to generate an index, simply add an level-1 section flagged with the `index` style near the end of your document.
1013
+ To get Asciidoctor PDF to generate an index, add a level-1 section flagged with the `index` style near the end of your document.
1015
1014
  The converter will automatically populate the catalog with the list of index terms in the document, organized by first letter.
1016
1015
 
1017
1016
  [source,asciidoc]
@@ -1034,7 +1033,7 @@ You can enable this feature by setting the `compress` attribute on the document:
1034
1033
 
1035
1034
  $ asciidoctor-pdf -a compress document.adoc
1036
1035
 
1037
- For more thorough optimzation, you can use either the built-in `asciidoctor-pdf-optimize` script or hexapdf.
1036
+ For more thorough optimization, you can use either the built-in `asciidoctor-pdf-optimize` script or hexapdf.
1038
1037
  Read on to learn how.
1039
1038
 
1040
1039
  === asciidoctor-pdf-optimize
@@ -35,12 +35,12 @@ Gem::Specification.new do |s|
35
35
 
36
36
  s.add_runtime_dependency 'asciidoctor', '>= 1.5.3', '< 3.0.0'
37
37
  s.add_runtime_dependency 'prawn', '~> 2.2.0'
38
- # NOTE ttfunk 1.6 generates TT instructions ghostscript cannot process, so lock the version of ttfunk
38
+ # NOTE ttfunk 1.6 is not compatible with Ruby 2.3, so lock version to 1.5 for consistency
39
39
  s.add_runtime_dependency 'ttfunk', ['~> 1.5.0'], ['>= 1.5.1']
40
40
  # NOTE must use prawn-table from master branch (defined in Gemfile) for full functionality
41
41
  s.add_runtime_dependency 'prawn-table', '~> 0.2.0'
42
42
  s.add_runtime_dependency 'prawn-templates', '~> 0.1.0'
43
- s.add_runtime_dependency 'prawn-svg', '~> 0.30.0'
43
+ s.add_runtime_dependency 'prawn-svg', '~> 0.31.0'
44
44
  s.add_runtime_dependency 'prawn-icon', '~> 2.5.0'
45
45
  s.add_runtime_dependency 'safe_yaml', '~> 1.0.0'
46
46
  s.add_runtime_dependency 'thread_safe', '~> 0.3.0'
@@ -1256,7 +1256,8 @@ To disable the image, use the value `none`.
1256
1256
  These margins and used when the value `prepress` is assigned to the `media` document attribute.
1257
1257
  If no cover is specified, the recto margin is not applied to the title page.
1258
1258
  To apply the recto margin to the title page, but not include a cover, assign the value `~` to the `front-cover-image` attribute.
1259
- . The `toc` value only applies if the toc is in the default location (before the first page of the body).
1259
+ . Only works if the document uses a title page (i.e., doctype is book or `title-page` attribute is set)
1260
+ The `toc` value only applies if the toc is in the default location (before the first page of the body).
1260
1261
  If the toc macro is used to position the toc, the start-at behavior is the same as if the toc is not enabled.
1261
1262
  If value is an integer, page numbering will start at the specified page of the body (i.e., 1 is first page, 2 is second page, etc.)
1262
1263
 
@@ -3363,7 +3364,7 @@ The keys in this category control the arrangement of block images.
3363
3364
  |font-style
3364
3365
  |<<font-styles,Font style>> +
3365
3366
  (default: normal)
3366
- |iamge:
3367
+ |image:
3367
3368
  alt:
3368
3369
  font-style: italic
3369
3370
 
@@ -3639,8 +3640,8 @@ The subject stop can be customized using the `subject-stop` attribute.
3639
3640
  [source,asciidoc]
3640
3641
  ----
3641
3642
  [unordered]
3642
- * alpha:: partially complete and unstable
3643
- * beta:: feature complete and undergoing testing
3643
+ alpha:: partially complete and unstable
3644
+ beta:: feature complete and undergoing testing
3644
3645
  ----
3645
3646
  ====
3646
3647
 
@@ -4135,7 +4136,7 @@ Since Asciidoctor 2, table stripes are not enabled by default (e.g., `stripes=no
4135
4136
  [#keys-footnotes]
4136
4137
  === Footnotes
4137
4138
 
4138
- The keys in this catagory control the style of the footnotes list at the end of the chapter (book) or document (otherwise).
4139
+ The keys in this category control the style of the footnotes list at the end of the chapter (book) or document (otherwise).
4139
4140
  If the `footnotes-title` attribute is specified, it is styled as a block caption.
4140
4141
  The styling of the links is controlled by the global link styles.
4141
4142
 
@@ -4678,7 +4679,8 @@ To avoid this problem, reduce the height of the running content periphery or mak
4678
4679
  The `columns` key can also be defined one level up (on `header` or `footer`), in which case the setting will be inherited.
4679
4680
  Where the page sides fall in relation to the physical or printed page number is controlled using the `pdf-folio-placement` attribute (except when `media=prepress`, which implies `physical`).
4680
4681
  . `<position>` can be `left`, `center` or `right`.
4681
- . The `toc` value only applies if the toc is in the default location (before the first page of the body).
4682
+ . Only works if the document uses a title page (i.e., doctype is book or `title-page` attribute is set)
4683
+ The `toc` value only applies if the toc is in the default location (before the first page of the body).
4682
4684
  If the toc macro is used to position the toc, the start-at behavior is the same as if the toc is not enabled.
4683
4685
  If value is an integer, the running content will start at the specified page of the body (i.e., 1 is first page, 2 is second page, etc.)
4684
4686
 
@@ -4741,7 +4743,7 @@ footer:
4741
4743
  ----
4742
4744
 
4743
4745
  The `&shared_footer` assigns an ID to the YAML subtree under the `recto` key and the `*shared_footer` outputs a copy of it under the `verso` key.
4744
- This technique can be used thoughout the theme file as it's a core feature of YAML.
4746
+ This technique can be used throughout the theme file as it's a core feature of YAML.
4745
4747
 
4746
4748
  ==== Attribute References
4747
4749
 
@@ -4762,7 +4764,7 @@ This feature allows you to have alternate lines that are selected when all the a
4762
4764
  One case where this is useful is when referencing the `page-number` attribute.
4763
4765
  If you unset the `pagenums` attribute on the document, any line in the running content that makes reference to `\{page-number}` will be dropped.
4764
4766
 
4765
- You can also built-in AsciiDoc text replacements like `+(C)+`, numeric character references like `+&#169;+`, hexidecimal character references like `+&#x20ac;+`, and inline formatting (e.g., bold, italic, monospace).
4767
+ You can also use built-in AsciiDoc text replacements like `+(C)+`, numeric character references like `+&#169;+`, hexadecimal character references like `+&#x20ac;+`, and inline formatting (e.g., bold, italic, monospace).
4766
4768
 
4767
4769
  Here's an example that shows how attributes and replacements can be used in the running footer:
4768
4770
 
@@ -4836,7 +4838,7 @@ header:
4836
4838
  center:
4837
4839
  content: $header-recto-center-content
4838
4840
  ----
4839
- <1> You can use the `image-vertical-align` key to slighly nudge the image up or down.
4841
+ <1> You can use the `image-vertical-align` key to slightly nudge the image up or down.
4840
4842
 
4841
4843
  CAUTION: By default, the image must fit in the allotted space for the running header or footer.
4842
4844
  Otherwise, you will run into layout issues.
@@ -5159,7 +5161,7 @@ Each style declaration accepts the following properties:
5159
5161
  * `inline_block` - fill the background color to the height of the line (Asciidoctor PDF only)
5160
5162
  * `extend` - extend the background color to the end of the line for a line-oriented match (Asciidoctor PDF only)
5161
5163
 
5162
- Colors are defined using hexidecimal format (e.g., #ff0000 for red).
5164
+ Colors are defined using hexadecimal format (e.g., #ff0000 for red).
5163
5165
 
5164
5166
  Use the `Text` token to set the background color of the source block and the default text color.
5165
5167
 
@@ -5219,7 +5221,7 @@ When you override an inline element, you return pseudo-HTML, which is then parse
5219
5221
 
5220
5222
  The pseudo-HTML in Asciidoctor PDF evolved from the inline formatting in Prawn, now supporting the following elements: a, br, button, code, color, del, em, font, img, key, mark, span, strong, sub, sup.
5221
5223
  All decimal and hexadecimal character references are supported, as well as the named entities amp, apos, gt, lt, nbsp, and quot (e.g., `\&apos;`).
5222
- You can change the font color using `rgb` attribue on the `color` element (e.g., `<color rgb="#ff0000">`) and the font family and size using `name` and `size` attributes on the `font` element, respectively (e.g., `<font name="sans" size="12">`).
5224
+ You can change the font color using the `rgb` attribute on the `color` element (e.g., `<color rgb="#ff0000">`) and the font family and size using the `name` and `size` attributes on the `font` element, respectively (e.g., `<font name="sans" size="12">`).
5223
5225
  You can also use the `style` attribute on `span` to control the font color, weight, and style using the relevant CSS property names.
5224
5226
  The pseudo-HTML in Asciidoctor PDF also supports the `class` attribute on any element for applying roles from the theme.
5225
5227
  (Though not recommended, you can pass this pseudo-HTML straight through to Prawn using an inline passthrough in AsciiDoc).
@@ -5239,7 +5241,7 @@ end
5239
5241
  ----
5240
5242
 
5241
5243
  As it stands, the converter doesn't do anything differently than the primary converter because we haven't yet overridden any of its methods.
5242
- Let's do that now, starting by overriding the thematic break (aka horizonal rule) to make it render like a ribbon:
5244
+ Let's do that now, starting by overriding the thematic break (aka horizontal rule) to make it render like a ribbon:
5243
5245
 
5244
5246
  [source,ruby]
5245
5247
  ----
@@ -3,6 +3,9 @@
3
3
  require_relative 'pdf/version'
4
4
  require 'asciidoctor' unless defined? Asciidoctor.load
5
5
  require 'prawn'
6
+ Prawn.send :remove_const, :FLOAT_PRECISION
7
+ Prawn::FLOAT_PRECISION = 1e-3
8
+ require 'prawn/templates'
6
9
  begin
7
10
  require 'prawn/gmagick'
8
11
  rescue LoadError
@@ -32,7 +32,7 @@ module Asciidoctor
32
32
  PygmentsRequirePath = ::File.join __dir__, 'ext/pygments'
33
33
  OptimizerRequirePath = ::File.join __dir__, 'optimizer'
34
34
 
35
- AsciidoctorVersion = ::Gem::Version.create ::Asciidoctor::VERSION
35
+ AsciidoctorVersion = ::Gem::Version.new ::Asciidoctor::VERSION
36
36
  AdmonitionIcons = {
37
37
  caution: { name: 'fas-fire', stroke_color: 'BF3400', size: 24 },
38
38
  important: { name: 'fas-exclamation-circle', stroke_color: 'BF0000', size: 24 },
@@ -92,7 +92,7 @@ module Asciidoctor
92
92
  'circled' => (?\u2460..?\u2473).to_a,
93
93
  'filled' => (?\u2776..?\u277f).to_a + (?\u24eb..?\u24f4).to_a,
94
94
  }
95
- SimpleAttributeRefRx = /(?<!\\)\{\w+(?:[\-]\w+)*\}/
95
+ SimpleAttributeRefRx = /(?<!\\)\{\w+(?:-\w+)*\}/
96
96
  MeasurementRxt = '\\d+(?:\\.\\d+)?(?:in|cm|mm|p[txc])?'
97
97
  MeasurementPartsRx = /^(\d+(?:\.\d+)?)(in|mm|cm|p[txc])?$/
98
98
  PageSizeRx = /^(?:\[(#{MeasurementRxt}), ?(#{MeasurementRxt})\]|(#{MeasurementRxt})(?: x |x)(#{MeasurementRxt})|\S+)$/
@@ -108,6 +108,7 @@ module Asciidoctor
108
108
  WhitespaceChars = ' ' + TAB + LF
109
109
  ValueSeparatorRx = /;|,/
110
110
  HexColorRx = /^#[a-fA-F0-9]{6}$/
111
+ VimeoThumbnailRx = /<thumbnail_url>(.*?)<\/thumbnail_url>/
111
112
  SourceHighlighters = %w(coderay pygments rouge).to_set
112
113
  ViewportWidth = ::Module.new
113
114
  (TitleStyles = {
@@ -126,8 +127,8 @@ module Asciidoctor
126
127
  doc.attributes['data-uri'] = ((doc.instance_variable_get :@attribute_overrides) || {})['data-uri'] = ''
127
128
  end
128
129
  @capabilities = {
129
- special_sectnums: AsciidoctorVersion >= (::Gem::Version.create '1.5.7'),
130
- syntax_highlighter: AsciidoctorVersion >= (::Gem::Version.create '2.0.0'),
130
+ special_sectnums: AsciidoctorVersion >= (::Gem::Version.new '1.5.7'),
131
+ syntax_highlighter: AsciidoctorVersion >= (::Gem::Version.new '2.0.0'),
131
132
  }
132
133
  @initial_instance_variables = [:@initial_instance_variables] + instance_variables
133
134
  end
@@ -571,9 +572,10 @@ module Asciidoctor
571
572
  # NOTE: section must have pdf-anchor in order to be listed in the TOC
572
573
  sect.set_attr 'pdf-anchor', (sect_anchor = derive_anchor_from_id sect.id, %(#{start_pgnum}-#{y.ceil}))
573
574
  add_dest_for_block sect, sect_anchor
574
- if type == :part
575
+ case type
576
+ when :part
575
577
  layout_part_title sect, title, align: align, level: hlevel
576
- elsif type == :chapter
578
+ when :chapter
577
579
  layout_chapter_title sect, title, align: align, level: hlevel
578
580
  else
579
581
  layout_heading title, align: align, level: hlevel, outdent: true
@@ -1333,8 +1335,14 @@ module Asciidoctor
1333
1335
  marker_gap = rendered_width_of_char 'x'
1334
1336
  font marker_style[:font_family], size: marker_style[:font_size] do
1335
1337
  marker_width = rendered_width_of_string marker
1338
+ # NOTE compensate if character_spacing is not applied to first character
1339
+ # see https://github.com/prawnpdf/prawn/commit/c61c5d48841910aa11b9e3d6f0e01b68ce435329
1340
+ character_spacing_correction = 0
1341
+ character_spacing(-0.5) do
1342
+ character_spacing_correction = 0.5 if (rendered_width_of_char 'x', character_spacing: -0.5) == marker_gap
1343
+ end
1336
1344
  marker_height = height_of_typeset_text marker, line_height: marker_style[:line_height], single_line: true
1337
- start_position = -marker_width + -marker_gap
1345
+ start_position = -marker_width + -marker_gap + character_spacing_correction
1338
1346
  float do
1339
1347
  start_new_page if @media == 'prepress' && cursor < marker_height
1340
1348
  flow_bounding_box start_position, width: marker_width do
@@ -1591,14 +1599,9 @@ module Asciidoctor
1591
1599
  when 'vimeo'
1592
1600
  video_path = %(https://vimeo.com/#{video_id = node.attr 'target'})
1593
1601
  if allow_uri_read
1594
- if cache_uri
1595
- Helpers.require_library 'open-uri/cached', 'open-uri-cached' unless defined? ::OpenURI::Cache
1596
- else
1597
- ::OpenURI
1598
- end
1599
- poster = ::OpenURI.open_uri %(http://vimeo.com/api/v2/video/#{video_id}.xml), 'r' do |f|
1600
- /<thumbnail_large>(.*?)<\/thumbnail_large>/ =~ f.read && $1
1601
- end
1602
+ poster = load_open_uri.open_uri(%(https://vimeo.com/api/oembed.xml?url=https%3A//vimeo.com/#{video_id}&width=1280), 'r') {|f| (VimeoThumbnailRx.match f.read)[1] } rescue nil
1603
+ else
1604
+ poster = nil
1602
1605
  end
1603
1606
  type = 'Vimeo video'
1604
1607
  else
@@ -1702,7 +1705,7 @@ module Asciidoctor
1702
1705
  # NOTE: highlight can return nil if something goes wrong; fallback to encoded source string if this happens
1703
1706
  result = (lexer.highlight source_string, options: lexer_opts) || (node.apply_subs source_string, [:specialcharacters])
1704
1707
  if node.attr? 'highlight', nil, false
1705
- if (highlight_lines = (node.method :resolve_lines_to_highlight).arity > 1 ?
1708
+ if (highlight_lines = (node.method :resolve_lines_to_highlight).arity.abs > 1 ?
1706
1709
  (node.resolve_lines_to_highlight source_string, (node.attr 'highlight')) :
1707
1710
  (node.resolve_lines_to_highlight node.attr 'highlight')).empty?
1708
1711
  highlight_lines = nil
@@ -1750,7 +1753,7 @@ module Asciidoctor
1750
1753
  lexer ||= ::Rouge::Lexers::PlainText
1751
1754
  source_string, conum_mapping = extract_conums source_string
1752
1755
  if node.attr? 'highlight', nil, false
1753
- unless (hl_lines = (node.method :resolve_lines_to_highlight).arity > 1 ?
1756
+ unless (hl_lines = (node.method :resolve_lines_to_highlight).arity.abs > 1 ?
1754
1757
  (node.resolve_lines_to_highlight source_string, (node.attr 'highlight')) :
1755
1758
  (node.resolve_lines_to_highlight node.attr 'highlight')).empty?
1756
1759
  formatter_opts[:highlight_lines] = hl_lines.map {|linenum| [linenum, true] }.to_h
@@ -1853,7 +1856,10 @@ module Asciidoctor
1853
1856
  line << fragment
1854
1857
  end
1855
1858
  end
1856
- conum_color = @theme.conum_font_color
1859
+ conum_font_color = @theme.conum_font_color
1860
+ if (conum_font_name = @theme.conum_font_family) == font_name
1861
+ conum_font_name = nil
1862
+ end
1857
1863
  last_line_num = lines.size - 1
1858
1864
  if linenums
1859
1865
  pad_size = (last_line_num + 1).to_s.length
@@ -1870,7 +1876,10 @@ module Asciidoctor
1870
1876
  if conum_mapping && (conums = conum_mapping.delete cur_line_num)
1871
1877
  line << { text: conums.shift } if ::String === conums[0]
1872
1878
  conum_text = conums.map {|num| conum_glyph num }.join ' '
1873
- line << (conum_color ? { text: conum_text, color: conum_color } : { text: conum_text })
1879
+ conum_fragment = { text: conum_text }
1880
+ conum_fragment[:color] = conum_font_color if conum_font_color
1881
+ conum_fragment[:font] = conum_font_name if conum_font_name
1882
+ line << conum_fragment
1874
1883
  end
1875
1884
  line << { text: LF } unless last_line
1876
1885
  line
@@ -2410,12 +2419,16 @@ module Asciidoctor
2410
2419
  end
2411
2420
 
2412
2421
  def convert_inline_callout node
2413
- if (conum_color = @theme.conum_font_color)
2414
- # NOTE CMYK value gets flattened here, but is restored by formatted text parser
2415
- %(<color rgb="#{conum_color}">#{conum_glyph node.text.to_i}</color>)
2422
+ if (conum_font_family = @theme.conum_font_family) != font_name
2423
+ result = %(<font name="#{conum_font_family}">#{conum_glyph node.text.to_i}</font>)
2416
2424
  else
2417
- conum_glyph node.text.to_i
2425
+ result = conum_glyph node.text.to_i
2418
2426
  end
2427
+ if (conum_font_color = @theme.conum_font_color)
2428
+ # NOTE CMYK value gets flattened here, but is restored by formatted text parser
2429
+ result = %(<color rgb="#{conum_font_color}">#{result}</font>)
2430
+ end
2431
+ result
2419
2432
  end
2420
2433
 
2421
2434
  def convert_inline_footnote node
@@ -2501,7 +2514,7 @@ module Asciidoctor
2501
2514
  if ::File.readable? image_path
2502
2515
  width_attr = (width = preresolve_explicit_width node.attributes) ? %( width="#{width}") : ''
2503
2516
  fit_attr = (fit = node.attr 'fit', nil, false) ? %( fit="#{fit}") : ''
2504
- img = %(<img src="#{image_path}" format="#{image_format}" alt="[#{encode_quotes node.attr 'alt'}]"#{width_attr}#{fit_attr}>)
2517
+ img = %(<img src="#{image_path}" format="#{image_format}" alt="#{encode_quotes node.attr 'alt'}"#{width_attr}#{fit_attr}>)
2505
2518
  else
2506
2519
  logger.warn %(image to embed not found or not readable: #{image_path}) unless scratch?
2507
2520
  img = %([#{node.attr 'alt'}])
@@ -2889,8 +2902,8 @@ module Asciidoctor
2889
2902
  if opts.delete :dry_run
2890
2903
  height = nil
2891
2904
  dry_run do
2892
- move_down 1 # HACK: force top margin to be applied
2893
- height = (layout_caption subject, opts) - 1
2905
+ move_down 0.001 # HACK: force top margin to be applied
2906
+ height = layout_caption subject, opts
2894
2907
  end
2895
2908
  return height
2896
2909
  end
@@ -3583,7 +3596,7 @@ module Asciidoctor
3583
3596
 
3584
3597
  def write pdf_doc, target
3585
3598
  if target.respond_to? :write
3586
- target = ::QuantifiableStdout.new STDOUT if target == STDOUT
3599
+ target = ::QuantifiableStdout.new $stdout if target == $stdout
3587
3600
  pdf_doc.render target
3588
3601
  else
3589
3602
  pdf_doc.render_file target
@@ -3694,7 +3707,7 @@ module Asciidoctor
3694
3707
  end
3695
3708
  # FIXME: due to the calculation error logged in #789, we must advance page even when content is split across pages
3696
3709
  advance_page if (opts.fetch :split_from_top, true) && block_height > cursor && !at_page_top?
3697
- caption_height = (node = opts[:caption_node]) && node.title? ? (layout_caption node, category: category) - 1 : 0
3710
+ caption_height = (node = opts[:caption_node]) && node.title? ? (layout_caption node, category: category) : 0
3698
3711
  float do
3699
3712
  remaining_height = block_height - caption_height
3700
3713
  initial_page = true
@@ -4081,24 +4094,22 @@ module Asciidoctor
4081
4094
  unlink_tmp_file tmp_image.path
4082
4095
  nil
4083
4096
  end
4084
- # handle case when image is a URI
4085
- elsif (node.is_uri? image_path) ||
4086
- (imagesdir && (node.is_uri? imagesdir) && (image_path = node.normalize_web_path image_path, imagesdir, false))
4087
- unless allow_uri_read
4097
+ # NOTE: this will catch a classloader resource path on JRuby (e.g., uri:classloader:/path/to/image)
4098
+ elsif ::File.absolute_path? image_path
4099
+ ::File.absolute_path image_path
4100
+ elsif !(is_uri = node.is_uri? image_path) && imagesdir && (::File.absolute_path? imagesdir)
4101
+ ::File.absolute_path image_path, imagesdir
4102
+ elsif is_uri || (imagesdir && (node.is_uri? imagesdir) && (image_path = node.normalize_web_path image_path, imagesdir, false))
4103
+ if !allow_uri_read
4088
4104
  logger.warn %(allow-uri-read is not enabled; cannot embed remote image: #{image_path}) unless scratch?
4089
4105
  return
4090
- end
4091
- if @tmp_files.key? image_path
4106
+ elsif @tmp_files.key? image_path
4092
4107
  return @tmp_files[image_path]
4093
- elsif cache_uri
4094
- Helpers.require_library 'open-uri/cached', 'open-uri-cached' unless defined? ::OpenURI::Cache
4095
- else
4096
- ::OpenURI
4097
4108
  end
4098
4109
  tmp_image = ::Tempfile.create ['image-', image_format && %(.#{image_format})]
4099
4110
  tmp_image.binmode if (binary = image_format != 'svg')
4100
4111
  begin
4101
- ::OpenURI.open_uri(image_path, (binary ? 'rb' : 'r')) {|fd| tmp_image.write fd.read }
4112
+ load_open_uri.open_uri(image_path, (binary ? 'rb' : 'r')) {|fd| tmp_image.write fd.read }
4102
4113
  tmp_image.close
4103
4114
  @tmp_files[image_path] = tmp_image.path
4104
4115
  rescue
@@ -4285,11 +4296,12 @@ module Asciidoctor
4285
4296
  result = {}
4286
4297
  center = nil
4287
4298
  (value.split ' ', 2).each do |keyword|
4288
- if keyword == 'left' || keyword == 'right'
4299
+ case keyword
4300
+ when 'left', 'right'
4289
4301
  result[:position] = keyword.to_sym
4290
- elsif keyword == 'top' || keyword == 'bottom'
4302
+ when 'top', 'bottom'
4291
4303
  result[:vposition] = keyword.to_sym
4292
- elsif keyword == 'center'
4304
+ when 'center'
4293
4305
  center = true
4294
4306
  end
4295
4307
  end
@@ -4348,6 +4360,14 @@ module Asciidoctor
4348
4360
  link_annotation [image_x, (image_y - image_height), (image_x + image_width), image_y], Border: [0, 0, 0], A: { Type: :Action, S: :URI, URI: uri.as_pdf }
4349
4361
  end
4350
4362
 
4363
+ def load_open_uri
4364
+ if @cache_uri && !(defined? ::OpenURI::Cache)
4365
+ # disable URI caching if library fails to load
4366
+ @cache_uri = false if (Helpers.require_library 'open-uri/cached', 'open-uri-cached', :warn).nil?
4367
+ end
4368
+ ::OpenURI
4369
+ end
4370
+
4351
4371
  def remove_tmp_files
4352
4372
  @tmp_files.reject! {|_, path| path ? (unlink_tmp_file path) : true }
4353
4373
  end
@@ -6,4 +6,3 @@ require_relative 'ext/pdf-core'
6
6
  require_relative 'ext/prawn'
7
7
  require_relative 'ext/prawn-svg'
8
8
  require_relative 'ext/prawn-table'
9
- require_relative 'ext/prawn-templates'
@@ -8,10 +8,11 @@ class Asciidoctor::Section
8
8
  if @numbered && !@caption && slevel <= (@document.attr 'sectnumlevels', 3).to_i
9
9
  @is_numbered = true
10
10
  if @document.doctype == 'book'
11
- if slevel == 0
11
+ case slevel
12
+ when 0
12
13
  @cached_numbered_title = %(#{sectnum nil, ':'} #{title})
13
14
  @cached_formal_numbered_title = %(#{@document.attr 'part-signifier', 'Part'} #{@cached_numbered_title}).lstrip
14
- elsif slevel == 1
15
+ when 1
15
16
  @cached_numbered_title = %(#{sectnum} #{title})
16
17
  @cached_formal_numbered_title = %(#{@document.attr 'chapter-signifier', (@document.attr 'chapter-label', 'Chapter')} #{@cached_numbered_title}).lstrip
17
18
  else
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class File
4
- class << self
5
- def absolute_path? path
6
- (path.start_with? '/') || (ALT_SEPARATOR && (path.start_with? (absolute_path path).slice 0, 3))
7
- end unless method_defined? :absolute_path?
8
- end
4
+ # NOTE: remove once minimum required Ruby version is at least 2.7
5
+ def self.absolute_path? path
6
+ (::Pathname.new path).absolute?
7
+ end unless respond_to? :absolute_path?
9
8
  end
@@ -1,4 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ module PDF::Core
4
+ class << self
5
+ alias _initial_real real
6
+ def real num
7
+ num.to_f.round 4
8
+ end
9
+
10
+ alias _initial_real_params real_params
11
+ def real_params array
12
+ return array.map {|it| it.to_f.round 5 }.join ' ' if (caller_locations 1, 1)[0].base_label == 'transformation_matrix'
13
+ _initial_real_params array
14
+ end
15
+ end
16
+ end
17
+
3
18
  require_relative 'pdf-core/pdf_object'
4
19
  require_relative 'pdf-core/page'
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'prawn-svg' unless defined? Prawn::SVG::Interface
4
- require_relative 'prawn-svg/interface'
5
4
  # NOTE disable system fonts since they're non-portable
6
5
  Prawn::SVG::Interface.font_path.clear
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pygments.rb'
3
+ require 'pygments.rb' # rubocop:disable Style/RedundantFileExtensionInRequire
4
4
 
5
5
  module Pygments
6
6
  module Ext
@@ -14,9 +14,10 @@ module Pygments
14
14
  if BlockSelectorRx =~ (css = ::Pygments.css '.highlight', style: key)
15
15
  ($1.strip.split ';').each do |style|
16
16
  pname, pval = (style.split ':', 2).map(&:strip)
17
- if pname == 'background' || pname == 'background-color'
17
+ case pname
18
+ when 'background', 'background-color'
18
19
  styles[:background_color] = pval.slice 1, pval.length if HexColorRx.match? pval
19
- elsif pname == 'color'
20
+ when 'color'
20
21
  styles[:font_color] = pval.slice 1, pval.length if HexColorRx.match? pval
21
22
  end
22
23
  end
@@ -2,7 +2,11 @@
2
2
 
3
3
  module Asciidoctor::PDF::FormattedText
4
4
  class FragmentPositionRenderer
5
- attr_reader :top, :right, :bottom, :left, :page_number
5
+ attr_reader :top
6
+ attr_reader :right
7
+ attr_reader :bottom
8
+ attr_reader :left
9
+ attr_reader :page_number
6
10
 
7
11
  def render_behind fragment
8
12
  @top = fragment.top
@@ -39,8 +39,14 @@ module Asciidoctor::PDF::FormattedText
39
39
  scratch = doc.scratch?
40
40
  available_w = doc.bounds.width
41
41
  available_h = doc.page.empty? ? doc.cursor : doc.bounds.height
42
+ last_fragment = {}
42
43
  raw_image_fragments.each do |fragment|
43
- drop = scratch
44
+ if fragment[:object_id] == last_fragment[:object_id]
45
+ fragments.delete fragment
46
+ next
47
+ else
48
+ drop = scratch
49
+ end
44
50
  begin
45
51
  image_path = fragment[:image_path]
46
52
 
@@ -125,6 +131,7 @@ module Asciidoctor::PDF::FormattedText
125
131
  # NOTE retain key to indicate we've visited fragment already
126
132
  fragment[:image_obj] = nil
127
133
  end
134
+ last_fragment = fragment
128
135
  end
129
136
  end
130
137
  end
@@ -172,9 +172,10 @@ module Asciidoctor
172
172
  fragment = {
173
173
  image_path: attributes[:src],
174
174
  image_format: attributes[:format],
175
- # a zero-width space in the text will cause the image to be duplicated
176
- text: (attributes[:alt].delete ZeroWidthSpace),
175
+ # NOTE: add enclosing square brackets here to avoid errors in parsing
176
+ text: %([#{attributes[:alt].delete ZeroWidthSpace}]),
177
177
  callback: [InlineImageRenderer],
178
+ object_id: node.object_id, # used to deduplicate if fragment gets split up
178
179
  }
179
180
  if inherited && (link = inherited[:link])
180
181
  fragment[:link] = link
@@ -379,9 +380,10 @@ module Asciidoctor
379
380
 
380
381
  def update_fragment fragment, props
381
382
  fragment.update props do |k, oval, nval|
382
- if k == :styles
383
+ case k
384
+ when :styles
383
385
  nval ? (oval.merge nval) : oval.clear
384
- elsif k == :callback
386
+ when :callback
385
387
  oval | nval
386
388
  else
387
389
  nval
@@ -18,7 +18,7 @@ module Asciidoctor
18
18
  creation_date = (::Time.parse doc.attr 'localdatetime') rescue (now || ::Time.now)
19
19
  end
20
20
  # FIXME: use sanitize: :plain_text once available
21
- content = <<~EOS
21
+ <<~EOS
22
22
  [ /Title #{(sanitize doc.doctitle use_fallback: true).to_pdf_object}
23
23
  /Author #{(doc.attr 'authors').to_pdf_object}
24
24
  /Subject #{(doc.attr 'subject').to_pdf_object}
@@ -29,7 +29,6 @@ module Asciidoctor
29
29
  /Producer #{(doc.attr 'publisher').to_pdf_object}
30
30
  /DOCINFO pdfmark
31
31
  EOS
32
- content
33
32
  end
34
33
 
35
34
  def generate_file pdf_file
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module PDF
5
- VERSION = '1.5.3'
5
+ VERSION = '1.5.4'
6
6
  end
7
7
  Pdf = PDF unless const_defined? :Pdf, false
8
8
  end
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.3
4
+ version: 1.5.4
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-28 00:00:00.000000000 Z
12
+ date: 2021-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asciidoctor
@@ -99,14 +99,14 @@ dependencies:
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: 0.30.0
102
+ version: 0.31.0
103
103
  type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: 0.30.0
109
+ version: 0.31.0
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: prawn-icon
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -330,12 +330,10 @@ files:
330
330
  - lib/asciidoctor/pdf/ext/pdf-core/page.rb
331
331
  - lib/asciidoctor/pdf/ext/pdf-core/pdf_object.rb
332
332
  - lib/asciidoctor/pdf/ext/prawn-svg.rb
333
- - lib/asciidoctor/pdf/ext/prawn-svg/interface.rb
334
333
  - lib/asciidoctor/pdf/ext/prawn-table.rb
335
334
  - lib/asciidoctor/pdf/ext/prawn-table/cell.rb
336
335
  - lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb
337
336
  - lib/asciidoctor/pdf/ext/prawn-table/cell/text.rb
338
- - lib/asciidoctor/pdf/ext/prawn-templates.rb
339
337
  - lib/asciidoctor/pdf/ext/prawn.rb
340
338
  - lib/asciidoctor/pdf/ext/prawn/coderay_encoder.rb
341
339
  - lib/asciidoctor/pdf/ext/prawn/extensions.rb
@@ -392,7 +390,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
392
390
  - !ruby/object:Gem::Version
393
391
  version: '0'
394
392
  requirements: []
395
- rubygems_version: 3.0.6
393
+ rubygems_version: 3.1.4
396
394
  signing_key:
397
395
  specification_version: 4
398
396
  summary: Converts AsciiDoc documents to PDF using Asciidoctor and Prawn
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Prawn
4
- module SVG
5
- class Interface
6
- def resize opts = {}
7
- sizing = document.sizing
8
- sizing.requested_width = opts[:width]
9
- sizing.requested_height = opts[:height]
10
- sizing.calculate
11
- end
12
- end
13
- end
14
- end unless Prawn::SVG::Interface.method_defined? :resize
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Prawn::Document
4
- # NOTE allows prawn-templates 0.0.4 to be used with prawn >= 2.2.0
5
- const_set :VALID_OPTIONS, (send :remove_const, :VALID_OPTIONS).dup if VALID_OPTIONS.frozen?
6
- end
7
- require 'prawn/templates'