asciidoctor-pdf 1.5.0.alpha.15 → 1.5.0.alpha.16

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
  SHA1:
3
- metadata.gz: 33a408180f820e2def56daa216f2993e059faa37
4
- data.tar.gz: a375982bb4846383206446e61b5151c0928f2f0a
3
+ metadata.gz: f8bc83ea1a53067222edc4efed9a4e23d7b98824
4
+ data.tar.gz: 55b679cc587279f0491af7aec91878c6acca01c9
5
5
  SHA512:
6
- metadata.gz: 7fd089829761e7ba27f54cda90169aece0fa6e3f7bb564ad35ca9889b806e2685796cb26836e8ff8295bc4ec42d8aa1ea62a7fc81dad745c98dbd6d6e2dea3d4
7
- data.tar.gz: cb2ffc4ae5b0d69538583e4a992787185b5bec827c64df6d7bf15cb619355e30740a929dfb91f7feea9231670bbe07c335557552e9f0658efea454f413b63981
6
+ metadata.gz: 632d25962bc66acf9b8b015a1e76b85e69a4f7a7b516cc9ea24c411e4b4db6e5280f23145c9beae321cfcd7b835821e86f0d81f6b4fa1731847eb6fa27e90bf7
7
+ data.tar.gz: 477e19845f08bba51aee292c662e2ec6cad47d814ba683959ec23c7eaf0615e7c32a6b1ebe4b565f036d47bc88b02971f7e83c6cfcb2083c26ef148ffe838ffc
@@ -5,10 +5,37 @@
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.alpha.16 (2017-07-30) - @mojavelinux
9
+
10
+ * add support for xrefstyle attribute (#464)
11
+ * allow page side to be based on physical page number and/or be inverted (#813) (@fap-)
12
+ * fix layout error caused by nested keep together blocks (#791)
13
+ * upgrade prawn-svg to allow generic font names to be mapped in SVG (#777)
14
+ * upgrade prawn-svg to fix issue with dotted lines (#741)
15
+ * upgrade prawn-svg to enable linear gradients (#228)
16
+ * don't attempt to parse text in literal cell (#816)
17
+ * warn if theme variable cannot be resolved; don't replace (#801)
18
+ * number appendix subsections based on appendix number when doctype is book (#627)
19
+ * don't add break hints to URI when using AFM font (#795)
20
+ * add rescue check for scratch document when state is not initialized
21
+ * allow page margin to be a single number; fixes regression introduced by #749
22
+ * check for margin as array, then as numeric, then as string
23
+ * extend version range for prawn-templates (#803)
24
+ * add missing part-title attribute to theming guide (#827)
25
+ * clarify in theming guide that variables are defined in document order
26
+ * clarify that the fallback font is only used when the primary font is a TrueType font
27
+ * add more information about prawn-gmagick to README
28
+ * fix warnings and incompatibility when using Ruby 1.9.3
29
+ * document in README how to install Asciidoctor PDF on Ruby 2.0.0
30
+ * enable Travis CI; configure CI-based deployment to RubyGems.org
31
+
32
+ {uri-repo}/issues?q=milestone%3Av1.5.0.alpha.16[issues resolved] |
33
+ {uri-repo}/releases/tag/v1.5.0.alpha.16[git tag]
34
+
8
35
  == 1.5.0.alpha.15 (2017-03-27) - @mojavelinux
9
36
 
10
37
  * fix compatibility with Prawn 2.2.0 (#775)
11
- * add workaround for TTFunk bug when font table has empty data
38
+ * add workaround for TTFunk bug when font table has empty data (#619, #651)
12
39
  * take fallback font into account when calculating width of string (#651)
13
40
  * fill and stroke bounds of sidebar across all pages (#259) (@TobiasHector)
14
41
  * allow page margin to be set using pdf-page-margin attribute (#749)
@@ -36,6 +63,9 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
36
63
  * document that background images are scaled to fit bounds of page
37
64
  * add note in theming guide about using double quoted strings
38
65
 
66
+ {uri-repo}/issues?q=milestone%3Av1.5.0.alpha.15[issues resolved] |
67
+ {uri-repo}/releases/tag/v1.5.0.alpha.15[git tag]
68
+
39
69
  == 1.5.0.alpha.14 (2017-02-05) - @mojavelinux
40
70
 
41
71
  * add support for AsciiDoc table cells (including nested tables) (#6)
data/Gemfile CHANGED
@@ -1,14 +1,19 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- if (Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.0.0')
4
- gem 'addressable', '2.4.0'
5
- gem 'prawn', '1.3.0'
6
- gem 'prawn-svg', '0.21.0'
7
- end
8
-
9
3
  # Look in asciidoctor-pdf.gemspec for runtime and development dependencies
10
4
  gemspec
11
5
 
6
+ if (ruby_version = Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.1.0')
7
+ if ruby_version < (Gem::Version.new '2.0.0')
8
+ gem 'addressable', '2.4.0'
9
+ gem 'prawn', '1.3.0'
10
+ gem 'prawn-svg', '0.21.0'
11
+ else
12
+ gem 'prawn', '2.1.0'
13
+ gem 'prawn-svg', '0.26.0'
14
+ end
15
+ end
16
+
12
17
  group :examples do
13
18
  gem 'rouge', '2.0.7'
14
19
  # Add unicode (preferred) or activesupport to transform case of text containing multibyte chars on Ruby < 2.4
@@ -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.alpha.15, 2017-03-27
3
+ v1.5.0.alpha.16, 2017-07-30
4
4
  // Settings:
5
5
  :experimental:
6
6
  :idprefix:
@@ -121,19 +121,29 @@ To check if you have Ruby available, use the `ruby` command to query the version
121
121
 
122
122
  [WARNING]
123
123
  ====
124
- By default, Asciidoctor PDF selects the latest version of Prawn to install.
125
- Since version 2.0.0, Prawn requires Ruby >= 2.0.0 during installation (though it may still work with Ruby 1.9.3 if you get past installation).
126
- Therefore, to use Asciidoctor PDF with Ruby 1.9.3, you must first explicitly install the following dependencies, including Prawn 1.3.0:
124
+ By default, Asciidoctor PDF automatically installs the latest version of Prawn if you don't already have Prawn installed.
125
+ This will fail on older versions of Ruby.
126
+ To workaround, you need to install certain dependencies first.
127
127
 
128
- $ gem install prawn --version 1.3.0
129
- gem install addressable --version 2.4.0
130
- gem install prawn-svg --version 0.21.0
131
- gem install prawn-templates --version 0.0.3
128
+ Starting with Prawn 2.0.0, Prawn requires Ruby >= 2.0.0 during installation.
129
+ Therefore, to use Asciidoctor PDF with Ruby 1.9.3, you must first explicitly install the following dependencies to lock the versions:
130
+
131
+ $ gem install prawn --version 1.3.0
132
+ gem install addressable --version 2.4.0
133
+ gem install prawn-svg --version 0.21.0
134
+ gem install prawn-templates --version 0.0.3
132
135
 
133
136
  You can then proceed with installation of Asciidoctor PDF on Ruby 1.9.3.
134
137
 
138
+ Starting with Prawn 2.2.0, Prawn requires Ruby >= 2.1.0 during installation.
139
+ Therefore, to use Asciidoctor PDF with Ruby 2.0.0, you must first explicitly install the following dependencies to lock the versions:
140
+
141
+ $ gem install prawn --version 2.1.0
142
+ gem install prawn-svg --version 0.26.0
143
+ gem install prawn-templates --version 0.0.4
144
+
135
145
  For all other versions of Ruby, you can simply install the Asciidoctor PDF gem.
136
- It will transitively install all required dependencies.
146
+ It will transitively install the required dependencies.
137
147
  ====
138
148
 
139
149
  === System Encoding
@@ -454,8 +464,9 @@ To perform this work, Asciidoctor delegates to the underlying libraries.
454
464
  {uri-prawn-svg}[prawn-svg] brings support for SVG images.
455
465
  Without any additional libraries, those are the only supported image file formats.
456
466
 
457
- If you need support for additional file formats, such as GIF or TIFF, you must install the {uri-prawn-gmagick}[prawn-gmagick] Ruby gem.
458
- prawn-gmagick is an extension for Prawn based on {uri-graphicsmagick}[GraphicsMagick] and brings supports all the formats recognized by that library.
467
+ 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.
468
+ prawn-gmagick is an extension for Prawn based on {uri-graphicsmagick}[GraphicsMagick] that adds support for all the image formats recognized by that library.
469
+ prawn-gmagick has the added benefit of significantly reducing the time it takes to generate a PDF containing a lot of images.
459
470
 
460
471
  The prawn-gmagick gem uses native extensions to compile against GraphicsMagick.
461
472
  This system prerequisite limits installation to Linux and OSX.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('lib/asciidoctor-pdf/version', File.dirname(__FILE__))
2
+ require_relative 'lib/asciidoctor-pdf/version'
3
3
 
4
4
  require 'rake/clean'
5
5
 
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('lib/asciidoctor-pdf/version', File.dirname(__FILE__))
2
+ require File.expand_path '../lib/asciidoctor-pdf/version', __FILE__
3
3
  require 'open3' unless defined? Open3
4
4
 
5
5
  Gem::Specification.new do |s|
@@ -43,9 +43,9 @@ An extension for Asciidoctor that converts AsciiDoc documents to PDF using the P
43
43
  s.add_runtime_dependency 'prawn', '>= 1.3.0', '< 2.3.0'
44
44
  s.add_runtime_dependency 'prawn-table', '0.2.2'
45
45
  # prawn-templates >= 0.0.5 requires prawn >= 2.2.0, so we must cast a wider net to support Ruby 1.9.3
46
- s.add_runtime_dependency 'prawn-templates', '>= 0.0.3', '<= 0.0.5'
46
+ s.add_runtime_dependency 'prawn-templates', '>= 0.0.3', '<= 0.1.1'
47
47
  # prawn-svg >= 0.22.1 requires Ruby >= 2.0.0, so we must cast a wider net to support Ruby 1.9.3
48
- s.add_runtime_dependency 'prawn-svg', '>= 0.21.0', '< 0.27.0'
48
+ s.add_runtime_dependency 'prawn-svg', '>= 0.21.0', '< 0.28.0'
49
49
  s.add_runtime_dependency 'prawn-icon', '1.3.0'
50
50
  s.add_runtime_dependency 'safe_yaml', '~> 1.0.4'
51
51
  s.add_runtime_dependency 'thread_safe', '~> 0.3.6'
@@ -25,7 +25,7 @@ page:
25
25
  background_color: ffffff
26
26
  layout: portrait
27
27
  margin: [0.5in, 0.67in, 0.67in, 0.67in]
28
- # margin_inner and margin_outer keys are used for recto/verso print margins when media=press
28
+ # margin_inner and margin_outer keys are used for recto/verso print margins when media=prepress
29
29
  margin_inner: 0.75in
30
30
  margin_outer: 0.59in
31
31
  size: A4
@@ -201,10 +201,14 @@ Any setting from an enclosing context, such as a sidebar, is skipped.
201
201
  === Variables
202
202
 
203
203
  To save you from having to type the same value in your theme over and over, or to allow you to base one value on another, the theme language supports variables.
204
- Variables consist of the key name preceded by a dollar (`$`) (e.g., `$base_font_size`).
204
+ Variables consist of the key name preceded by a dollar sign (`$`) (e.g., `$base_font_size`).
205
205
  Any qualified key that has already been defined can be referenced in the value of another key.
206
206
  (In order words, as soon as the key is assigned, it's available to be used as a variable).
207
207
 
208
+ IMPORTANT: Variables are defined from top to bottom (i.e., in document order).
209
+ Therefore, a variable must be defined before it is referenced.
210
+ In other words, the path the variable refers to must be *above* the usage of that variable.
211
+
208
212
  For example, once the following line is processed,
209
213
 
210
214
  [source,yaml]
@@ -650,9 +654,9 @@ Asciidoctor PDF encodes the content into WINANSI when building the PDF.
650
654
  When using the built-in PDF (AFM) fonts on a block of content in your AsciiDoc document, any character that cannot be encoded to WINANSI is replaced with a logic "`not`" glyph (`&#172;`) and you'll see the following warning in your console:
651
655
 
652
656
  The following text could not be fully converted to the Windows-1252 character set:
653
- | <glyph>
657
+ | <string with unknown glyph>
654
658
 
655
- This behavior differs from the default behavior in Prawn.
659
+ This behavior differs from the default behavior in Prawn, which simply crashes.
656
660
 
657
661
  For more information about how Prawn handles character encodings for built-in fonts, see https://github.com/prawnpdf/prawn/blob/master/CHANGELOG.md#vastly-improved-handling-of-encodings-for-pdf-built-in-afm-fonts[this note in the Prawn CHANGELOG].
658
662
  ****
@@ -765,8 +769,11 @@ This will allow you to use the same font names (aka families) in both your graph
765
769
 
766
770
  === Fallback Fonts
767
771
 
768
- If one of your fonts is missing a character that is used in a document, such as special symbols, you can tell Asciidoctor PDF to retrieve the character from a fallback font.
769
- You only need to specify one fallback font...typically one that has a full set of symbols.
772
+ If a TrueType font is missing a character needed to render the document, such as a special symbol, you can have Asciidoctor PDF look for the character in a fallback font.
773
+ You only need to specify a single fallback font, typically one that provides a full set of symbols.
774
+
775
+ IMPORTANT: The fallback font is only used when the primary font is a TrueType font (i.e., TTF, DFont, TTC).
776
+ Any glyph missing from an AFM font is simply replaced with the "`not`" glyph (`&#172;`).
770
777
 
771
778
  CAUTION: Using the fallback font slows down PDF generation slightly because it has to analyze every single character.
772
779
  It's use is not recommended for large documents.
@@ -817,31 +824,43 @@ font:
817
824
 
818
825
  TIP: If you are using more than one fallback font, add additional lines to the `fallbacks` key.
819
826
 
827
+ Of course, make sure you've configured your theme to use your custom font:
828
+
829
+ [source,yaml]
830
+ ----
831
+ base:
832
+ font_family: Roboto
833
+ ----
834
+
820
835
  That's it!
821
836
  Now you're covered.
822
- You don't need to reference the fallback font anywhere else in your theme file to use it.
837
+ If your custom font is missing a glyph, Asciidoctor PDF will look in your fallback font.
838
+ You don't need to reference the fallback font anywhere else in your theme file.
823
839
 
824
840
  == Keys
825
841
 
826
842
  This section lists all the keys that are available when creating a custom theme.
827
- The keys in this section are organized by category.
843
+ The keys are organized by category.
828
844
  Each category represents a common prefix under which the keys are typically nested.
829
845
 
830
- TIP: Keys can be partioned and nested wherever an underscore (`_`) appears in the name.
831
- This nested structure is flatted when the theme is loaded.
846
+ TIP: Keys can be nested wherever an underscore (`_`) appears in the name.
847
+ This nested structure is for organizational purposes only.
848
+ All keys are flatted when the theme is loaded (e.g., `align` nested under `base` becomes `base_align`).
832
849
 
833
850
  The converter uses the values of these keys to control how most elements are arranged and styled in the PDF.
834
851
  The default values listed in this section get inherited from the https://github.com/asciidoctor/asciidoctor-pdf/blob/master/data/themes/base-theme.yml[base theme].
835
- (The https://github.com/asciidoctor/asciidoctor-pdf/blob/master/data/themes/default-theme.yml[default theme], which also inherits from the base theme, has a different set of values not shown in this guide).
852
+
853
+ IMPORTANT: The https://github.com/asciidoctor/asciidoctor-pdf/blob/master/data/themes/default-theme.yml[default theme] has a different set of values which are not shown in this guide.
836
854
 
837
855
  When creating a theme, all keys are optional.
838
856
  Required keys are provided by the base theme.
839
- Therefore, you only have to assign values to keys you want to customize.
857
+ Therefore, you only have to declare keys that you want to override.
840
858
 
841
859
  [#keys-page]
842
860
  === Page
843
861
 
844
862
  The keys in this category control the size, margins and background of each page (i.e., canvas).
863
+ We recommended that you define this category before all other categories.
845
864
 
846
865
  NOTE: The background of the title page can be styled independently.
847
866
  See <<Title Page>> for details.
@@ -909,7 +928,9 @@ These margins and used when the value `prepress` is assigned to the `media` docu
909
928
  === Base
910
929
 
911
930
  The keys in this category provide generic theme settings and are often referenced throughout the theme file as variables.
912
- It's common to define additional keys in this category (e.g., `base_border_radius`) that serve as custom variables to help keep your theme DRY.
931
+ We recommended that you define this category after the page category and before all other categories.
932
+
933
+ NOTE: While it's common to define additional keys in this category (e.g., `base_border_radius`) to keep your theme DRY, we recommend using <<Custom Variables,custom variables>> instead.
913
934
 
914
935
  [cols="3,4,5l"]
915
936
  |===
@@ -3196,6 +3217,7 @@ The keys in this category control the arrangement and style of running header an
3196
3217
  . The background color spans the width of the page, as does the border when a background color is specified.
3197
3218
  . If the height is not set, the running content at this periphery is disabled.
3198
3219
  . `<side>` can be `recto` (right-hand, odd-numbered pages) or `verso` (left-hand, even-numbered pages).
3220
+ 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`).
3199
3221
  . `<position>` can be `left`, `center` or `right`.
3200
3222
 
3201
3223
  IMPORTANT: You must define a height for the running header or footer, respectively, or it will not be shown.
@@ -3210,13 +3232,14 @@ For example, you can set the font color used for the right-hand column on recto
3210
3232
 
3211
3233
  ==== Attribute References
3212
3234
 
3213
- You can use _any_ attribute defined in your AsciiDoc document in the content of the running header and footer.
3235
+ You can use _any_ attribute defined in your AsciiDoc document (such as `doctitle`) in the content of the running header and footer.
3214
3236
  In addition, the following attributes are also available when defining the content keys in the footer:
3215
3237
 
3216
3238
  * page-count
3217
3239
  * page-number
3218
3240
  * document-title
3219
3241
  * document-subtitle
3242
+ * part-title
3220
3243
  * chapter-title
3221
3244
  * section-title
3222
3245
  * section-or-chapter-title
@@ -3404,6 +3427,10 @@ These settings override equivalent keys defined in the theme file, where applica
3404
3427
  |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]>>
3405
3428
  |:pdf-page-size: 6in x 9in
3406
3429
 
3430
+ |pdf-folio-placement
3431
+ |virtual {vbar} virtual-inverted {vbar} physical {vbar} physical-inverted
3432
+ |:pdf-folio-placement: physical
3433
+
3407
3434
  |pdfmark^[6]^
3408
3435
  |flag (default: _not set_)
3409
3436
  |:pdfmark:
@@ -3471,14 +3498,14 @@ The first page in the document is a recto page.
3471
3498
 
3472
3499
  === Automatic Facing Pages
3473
3500
 
3474
- If a document uses the book doctype, a blank page will be inserted, if necessary, to ensure the following pages are recto-facing pages:
3501
+ When converting the book doctype using the prepress media setting, a blank page will be inserted when necessary to ensure the following elements start on a recto page:
3475
3502
 
3476
3503
  * Title page
3477
3504
  * Table of contents
3478
- * First page of body content
3505
+ * First page of body
3479
3506
  * Parts and chapters
3480
3507
 
3481
- Other facing pages may be added in the future.
3508
+ Other "`facing`" pages may be added in the future.
3482
3509
 
3483
3510
  It's possible to disable the automatic facing feature for a given part or chapter.
3484
3511
  This can be done by adding the nonfacing option to the section node.
@@ -35,8 +35,8 @@ class Converter < ::Prawn::Document
35
35
  register_for 'pdf'
36
36
 
37
37
  # NOTE require_library doesn't support require_relative and we don't modify the load path for this gem
38
- CodeRayRequirePath = ::File.join (::File.dirname __FILE__), 'prawn_ext/coderay_encoder'
39
- RougeRequirePath = ::File.join (::File.dirname __FILE__), 'rouge_ext'
38
+ CodeRayRequirePath = ::File.join((::File.dirname __FILE__), 'prawn_ext/coderay_encoder')
39
+ RougeRequirePath = ::File.join((::File.dirname __FILE__), 'rouge_ext')
40
40
 
41
41
  AsciidoctorVersion = ::Gem::Version.create ::Asciidoctor::VERSION
42
42
  AdmonitionIcons = {
@@ -63,10 +63,8 @@ class Converter < ::Prawn::Document
63
63
  TabRx = /\t/
64
64
  TabIndentRx = /^\t+/
65
65
  NoBreakSpace = %(\u00a0)
66
- NarrowSpace = %(\u2009)
67
66
  NarrowNoBreakSpace = %(\u202f)
68
67
  ZeroWidthSpace = %(\u200b)
69
- HairSpace = %(\u200a)
70
68
  DummyText = %(\u0000)
71
69
  DotLeaderTextDefault = '. '
72
70
  EmDash = %(\u2014)
@@ -169,7 +167,7 @@ class Converter < ::Prawn::Document
169
167
  # NOTE on_page_create is called within a float context
170
168
  # NOTE on_page_create is not called for imported pages, front and back cover pages, and other image pages
171
169
  on_page_create do
172
- # NOTE we assume here that physical page number reflects page side
170
+ # NOTE we assume in prepress that physical page number reflects page side
173
171
  if @media == 'prepress' && (next_page_margin = @page_margin_by_side[page_side]) != page_margin
174
172
  set_page_margin next_page_margin
175
173
  end
@@ -226,7 +224,7 @@ class Converter < ::Prawn::Document
226
224
  add_outline doc, num_toc_levels, toc_page_nums, num_front_matter_pages
227
225
  # TODO allow document (or theme) to override initial view magnification
228
226
  # NOTE add 1 to page height to force initial scroll to 0; a nil value also seems to work
229
- catalog.data[:OpenAction] = dest_fit_horizontally (page_height + 1), state.pages[0] if state.pages.size > 0
227
+ catalog.data[:OpenAction] = dest_fit_horizontally((page_height + 1), state.pages[0]) if state.pages.size > 0
230
228
  catalog.data[:ViewerPreferences] = { DisplayDocTitle: true }
231
229
 
232
230
  layout_cover_page :back, doc
@@ -280,6 +278,11 @@ class Converter < ::Prawn::Document
280
278
 
281
279
  def build_pdf_options doc, theme
282
280
  case (page_margin = (doc.attr 'pdf-page-margin') || theme.page_margin)
281
+ when ::Array
282
+ page_margin = page_margin[0..3] if page_margin.length > 4
283
+ page_margin = page_margin.map {|v| ::Numeric === v ? v : (str_to_pt v.to_s) }
284
+ when ::Numeric
285
+ page_margin = [page_margin]
283
286
  when ::String
284
287
  if page_margin.empty?
285
288
  page_margin = nil
@@ -295,9 +298,6 @@ class Converter < ::Prawn::Document
295
298
  else
296
299
  page_margin = [(str_to_pt page_margin)]
297
300
  end
298
- when ::Array
299
- page_margin = page_margin[0..3] if page_margin.length > 4
300
- page_margin = page_margin.map {|v| ::Numeric === v ? v : (str_to_pt v.to_s) }
301
301
  else
302
302
  page_margin = nil
303
303
  end
@@ -386,7 +386,7 @@ class Converter < ::Prawn::Document
386
386
  end
387
387
 
388
388
  def convert_section sect, opts = {}
389
- if sect.special && sect.sectname == 'abstract'
389
+ if sect.sectname == 'abstract'
390
390
  # HACK cheat a bit to hide this section from TOC; TOC should filter these sections
391
391
  sect.context = :open
392
392
  return convert_abstract sect
@@ -423,7 +423,7 @@ class Converter < ::Prawn::Document
423
423
  end
424
424
  end
425
425
 
426
- sect.special && sect.sectname == 'index' ? (convert_index_section sect) : (convert_content_for_block sect)
426
+ sect.sectname == 'index' ? (convert_index_section sect) : (convert_content_for_block sect)
427
427
  sect.set_attr 'pdf-page-end', page_number
428
428
  end
429
429
 
@@ -1333,7 +1333,7 @@ class Converter < ::Prawn::Document
1333
1333
  bg_color_override = formatter.background_color
1334
1334
  source_string, conum_mapping = extract_conums source_string
1335
1335
  # NOTE trailing endline is added to address https://github.com/jneen/rouge/issues/279
1336
- fragments = formatter.format (lexer.lex %(#{source_string}#{LF}), lexer_opts), formatter_opts
1336
+ fragments = formatter.format((lexer.lex %(#{source_string}#{LF}), lexer_opts), formatter_opts)
1337
1337
  # NOTE cleanup trailing endline (handled in rouge_ext/formatters/prawn instead)
1338
1338
  #fragments[-1][:text] == LF ? fragments.pop : fragments[-1][:text].chop!
1339
1339
  conum_mapping ? (restore_conums fragments, conum_mapping) : fragments
@@ -1366,7 +1366,7 @@ class Converter < ::Prawn::Document
1366
1366
  remaining_height = box_height - caption_height
1367
1367
  i = 0
1368
1368
  while remaining_height > 0
1369
- start_new_page if (started_new_page = i > 0)
1369
+ advance_page if (started_new_page = i > 0)
1370
1370
  fill_height = [remaining_height, cursor].min
1371
1371
  bounding_box [0, cursor], width: bounds.width, height: fill_height do
1372
1372
  theme_fill_and_stroke_bounds :code, background_color: bg_color_override
@@ -1595,7 +1595,7 @@ class Converter < ::Prawn::Document
1595
1595
  when :literal
1596
1596
  # FIXME core should not substitute in this case
1597
1597
  cell_data[:content] = preserve_indentation((cell.instance_variable_get :@text), (node.document.attr 'tabsize'))
1598
- cell_data[:inline_format] = false
1598
+ # NOTE the absence of the inline_format option implies it's disabled
1599
1599
  # QUESTION should we use literal_font_*, code_font_*, or introduce another category?
1600
1600
  cell_data[:font] = theme.code_font_family
1601
1601
  if (val = theme.code_font_size)
@@ -1880,26 +1880,24 @@ class Converter < ::Prawn::Document
1880
1880
  end
1881
1881
  when :xref
1882
1882
  # NOTE non-nil path indicates this is an inter-document xref that's not included in current document
1883
- if (path = node.attr 'path', nil, false)
1883
+ if (path = node.attributes['path'])
1884
1884
  # NOTE we don't use local as that doesn't work on the web
1885
1885
  # NOTE for the fragment to work in most viewers, it must be #page=<N> <= document this!
1886
1886
  %(<a href="#{node.target}">#{node.text || path}</a>)
1887
- else
1888
- if (refid = node.attr 'refid', nil, false)
1889
- anchor = derive_anchor_from_id refid
1890
- # NOTE reference table is not comprehensive (we don't yet catalog all inline anchors)
1891
- if (reftext = node.document.references[:ids][refid])
1892
- %(<a anchor="#{anchor}">#{node.text || reftext}</a>)
1887
+ elsif (refid = node.attributes['refid'])
1888
+ unless (text = node.text)
1889
+ if (refs = node.document.references[:refs])
1890
+ if ::Asciidoctor::AbstractNode === (ref = refs[refid])
1891
+ text = ref.xreftext((@xrefstyle ||= (node.document.attr 'xrefstyle')))
1892
+ end
1893
1893
  else
1894
- # NOTE we don't yet catalog all inline anchors, so we can't warn here (maybe after conversion is complete)
1895
- #source = $VERBOSE ? %( in source:\n#{node.parent.lines * "\n"}) : nil
1896
- #warn %(asciidoctor: WARNING: reference '#{refid}' not found#{source})
1897
- #%[(see #{node.text || %([#{refid}])})]
1898
- %(<a anchor="#{anchor}">#{node.text || "[#{refid}]"}</a>)
1894
+ # Asciidoctor < 1.5.6
1895
+ text = node.document.references[:ids][refid]
1899
1896
  end
1900
- else
1901
- %(<a anchor="#{node.document.attr 'pdf-anchor'}">#{node.text || '[^top]'}</a>)
1902
1897
  end
1898
+ %(<a anchor="#{derive_anchor_from_id refid}">#{text || "[#{refid}]"}</a>)
1899
+ else
1900
+ %(<a anchor="#{node.document.attr 'pdf-anchor'}">#{node.text || '[^top]'}</a>)
1903
1901
  end
1904
1902
  when :ref
1905
1903
  # NOTE destination is created inside callback registered by FormattedTextTransform#build_fragment
@@ -2132,26 +2130,26 @@ class Converter < ::Prawn::Document
2132
2130
  # FIXME delegate to method to convert page % to y value
2133
2131
  @y = title_top
2134
2132
  end
2135
- move_down (@theme.title_page_title_margin_top || 0)
2133
+ move_down(@theme.title_page_title_margin_top || 0)
2136
2134
  theme_font :title_page_title do
2137
2135
  layout_heading doctitle.main,
2138
2136
  align: title_align,
2139
2137
  margin: 0,
2140
2138
  line_height: @theme.title_page_title_line_height
2141
2139
  end
2142
- move_down (@theme.title_page_title_margin_bottom || 0)
2140
+ move_down(@theme.title_page_title_margin_bottom || 0)
2143
2141
  if doctitle.subtitle
2144
- move_down (@theme.title_page_subtitle_margin_top || 0)
2142
+ move_down(@theme.title_page_subtitle_margin_top || 0)
2145
2143
  theme_font :title_page_subtitle do
2146
2144
  layout_heading doctitle.subtitle,
2147
2145
  align: title_align,
2148
2146
  margin: 0,
2149
2147
  line_height: @theme.title_page_subtitle_line_height
2150
2148
  end
2151
- move_down (@theme.title_page_subtitle_margin_bottom || 0)
2149
+ move_down(@theme.title_page_subtitle_margin_bottom || 0)
2152
2150
  end
2153
2151
  if doc.attr? 'authors'
2154
- move_down (@theme.title_page_authors_margin_top || 0)
2152
+ move_down(@theme.title_page_authors_margin_top || 0)
2155
2153
  # TODO provide an API in core to get authors as an array
2156
2154
  authors = (1..(doc.attr 'authorcount', 1).to_i).map {|idx|
2157
2155
  doc.attr(idx == 1 ? 'author' : %(author_#{idx}))
@@ -2162,11 +2160,11 @@ class Converter < ::Prawn::Document
2162
2160
  margin: 0,
2163
2161
  normalize: false
2164
2162
  end
2165
- move_down (@theme.title_page_authors_margin_bottom || 0)
2163
+ move_down(@theme.title_page_authors_margin_bottom || 0)
2166
2164
  end
2167
2165
  revision_info = [(doc.attr? 'revnumber') ? %(#{doc.attr 'version-label'} #{doc.attr 'revnumber'}) : nil, (doc.attr 'revdate')].compact
2168
2166
  unless revision_info.empty?
2169
- move_down (@theme.title_page_revision_margin_top || 0)
2167
+ move_down(@theme.title_page_revision_margin_top || 0)
2170
2168
  revision_text = revision_info * (@theme.title_page_revision_delimiter || ', ')
2171
2169
  theme_font :title_page_revision do
2172
2170
  layout_prose revision_text,
@@ -2174,7 +2172,7 @@ class Converter < ::Prawn::Document
2174
2172
  margin: 0,
2175
2173
  normalize: false
2176
2174
  end
2177
- move_down (@theme.title_page_revision_margin_bottom || 0)
2175
+ move_down(@theme.title_page_revision_margin_bottom || 0)
2178
2176
  end
2179
2177
  end
2180
2178
  end
@@ -2670,15 +2668,23 @@ class Converter < ::Prawn::Document
2670
2668
 
2671
2669
  pagenums_enabled = doc.attr? 'pagenums'
2672
2670
  attribute_missing_doc = doc.attr 'attribute-missing'
2673
- repeat (content_start_page..page_count), dynamic: true do
2671
+ case @media == 'prepress' ? 'physical' : (doc.attr 'pdf-folio-placement')
2672
+ when 'physical'
2673
+ folio_basis, invert_folio = :physical, false
2674
+ when 'physical-inverted'
2675
+ folio_basis, invert_folio = :physical, true
2676
+ when 'virtual-inverted'
2677
+ folio_basis, invert_folio = :virtual, true
2678
+ else
2679
+ folio_basis, invert_folio = :virtual, false
2680
+ end
2681
+ repeat((content_start_page..page_count), dynamic: true) do
2674
2682
  # NOTE don't write on pages which are imported / inserts (otherwise we can get a corrupt PDF)
2675
2683
  next if page.imported_page?
2676
2684
  pgnum_label = page_number - skip
2677
- # QUESTION should we respect physical page number or just look at the content page number?
2678
- side = page_side pgnum_label
2685
+ side = page_side((folio_basis == :physical ? page_number : pgnum_label), invert_folio)
2679
2686
  # FIXME we need to have a content setting for chapter pages
2680
- content_by_position = content_dict[side]
2681
- colspec_by_position = colspec_dict[side]
2687
+ content_by_position, colspec_by_position = content_dict[side], colspec_dict[side]
2682
2688
  # TODO populate chapter-number
2683
2689
  # TODO populate numbered and unnumbered chapter and section titles
2684
2690
  doc.set_attr 'page-number', pgnum_label.to_s if pagenums_enabled
@@ -2894,13 +2900,14 @@ class Converter < ::Prawn::Document
2894
2900
  # - 0 when side == :top
2895
2901
  # - @theme.vertical_spacing when side == :bottom
2896
2902
  def theme_margin category, side
2897
- margin (@theme[%(#{category}_margin_#{side})] || (side == :bottom ? @theme.vertical_spacing : 0)), side
2903
+ margin((@theme[%(#{category}_margin_#{side})] || (side == :bottom ? @theme.vertical_spacing : 0)), side)
2898
2904
  end
2899
2905
 
2900
2906
  def theme_font category, opts = {}
2901
2907
  result = nil
2902
2908
  # TODO inheriting from generic category should be an option
2903
- if (level = opts[:level])
2909
+ if opts.key? :level
2910
+ level = opts[:level]
2904
2911
  family = @theme[%(#{category}_h#{level}_font_family)] || @theme[%(#{category}_font_family)] || @theme.base_font_family
2905
2912
  size = @theme[%(#{category}_h#{level}_font_size)] || @theme[%(#{category}_font_size)] || @theme.base_font_size
2906
2913
  style = @theme[%(#{category}_h#{level}_font_style)] || @theme[%(#{category}_font_style)]
@@ -3148,10 +3155,10 @@ class Converter < ::Prawn::Document
3148
3155
 
3149
3156
  # Resolve the system path of the specified image path.
3150
3157
  #
3151
- # Resolve and normalize the absolute system path of the specified image. If
3152
- # the image_path argument is not specified, the path is read from the target
3153
- # attribute of the specified document node. Resolve the path relative to the
3154
- # imagesdir if the relative_to_imagesdir option is specified (default: true).
3158
+ # Resolve and normalize the absolute system path of the specified image,
3159
+ # taking into account the imagesdir attribute. If an image path is not
3160
+ # specified, the path is read from the target attribute of the specified
3161
+ # document node.
3155
3162
  #
3156
3163
  # If the target is a URI and the allow-uri-read attribute is set on the
3157
3164
  # document, read the file contents to a temporary file and return the path to
@@ -3305,6 +3312,7 @@ class Converter < ::Prawn::Document
3305
3312
  scheme, address = uri.split UriSchemeBoundaryRx, 2
3306
3313
  address, scheme = scheme, address unless address
3307
3314
  address = address.gsub UriBreakCharsRx, UriBreakCharRepl
3315
+ # NOTE require at least two characters after a break
3308
3316
  address.slice!(-2) if address[-2] == ZeroWidthSpace
3309
3317
  %(#{scheme}#{address})
3310
3318
  end
@@ -112,8 +112,12 @@ module Extensions
112
112
 
113
113
  # Returns the side the current page is facing, :recto or :verso.
114
114
  #
115
- def page_side pgnum = nil
116
- (recto_page? pgnum) ? :recto : :verso
115
+ def page_side pgnum = nil, invert = nil
116
+ if invert
117
+ (recto_page? pgnum) ? :verso : :recto
118
+ else
119
+ (recto_page? pgnum) ? :recto : :verso
120
+ end
117
121
  end
118
122
 
119
123
  # Returns whether the page is a recto page.
@@ -234,17 +238,17 @@ module Extensions
234
238
  super @font_size
235
239
  elsif String === points
236
240
  if points.end_with? 'rem'
237
- super (@theme.base_font_size * points.to_f)
241
+ super(@theme.base_font_size * points.to_f)
238
242
  elsif points.end_with? 'em'
239
- super (@font_size * points.to_f)
243
+ super(@font_size * points.to_f)
240
244
  elsif points.end_with? '%'
241
- super (@font_size * (points.to_f / 100.0))
245
+ super(@font_size * (points.to_f / 100.0))
242
246
  else
243
247
  super points.to_f
244
248
  end
245
249
  # FIXME HACK assume em value
246
250
  elsif points < 1
247
- super (@font_size * points)
251
+ super(@font_size * points)
248
252
  else
249
253
  super points
250
254
  end
@@ -693,14 +697,10 @@ module Extensions
693
697
  # prawn-templates sets text_rendering_mode to :unknown, which breaks running content; revert
694
698
  @text_rendering_mode = prev_text_rendering_mode
695
699
  if opts.fetch :advance, true
696
- if last_page?
697
- # NOTE set page size & layout explicitly in case imported page differs
698
- # I'm not sure it's right to start a new page here, but unfortunately there's no other
699
- # way atm to prevent the size & layout of the imported page from affecting subsequent pages
700
- start_new_page size: prev_page_size, layout: prev_page_layout
701
- else
702
- go_to_page page_number + 1
703
- end
700
+ # NOTE set page size & layout explicitly in case imported page differs
701
+ # I'm not sure it's right to start a new page here, but unfortunately there's no other
702
+ # way atm to prevent the size & layout of the imported page from affecting subsequent pages
703
+ advance_page size: prev_page_size, layout: prev_page_layout
704
704
  end
705
705
  nil
706
706
  end
@@ -739,8 +739,8 @@ module Extensions
739
739
  # This method is a smarter version of start_new_page. It calls start_new_page
740
740
  # if the current page is the last page of the document. Otherwise, it simply
741
741
  # advances to the next existing page.
742
- def advance_page
743
- last_page? ? start_new_page : (go_to_page page_number + 1)
742
+ def advance_page opts = {}
743
+ last_page? ? (start_new_page opts) : (go_to_page page_number + 1)
744
744
  end
745
745
 
746
746
  # Start a new page without triggering the on_page_create callback
@@ -783,12 +783,15 @@ module Extensions
783
783
 
784
784
  def scratch?
785
785
  (@_label ||= (state.store.info.data[:Scratch] ? :scratch : :primary)) == :scratch
786
+ rescue
787
+ false # NOTE this method may get called before the state is initialized
786
788
  end
787
789
  alias :is_scratch? :scratch?
788
790
 
789
791
  # TODO document me
790
792
  def dry_run &block
791
793
  scratch = get_scratch_document
794
+ # QUESTION should we use scratch.advance_page instead?
792
795
  scratch.start_new_page
793
796
  start_page_number = scratch.page_number
794
797
  start_y = scratch.y
@@ -819,7 +822,7 @@ module Extensions
819
822
  # NOTE technically, if we're at the page top, we don't even need to do the
820
823
  # dry run, except several uses of this method rely on the calculated height
821
824
  if total_height > available_space && !at_page_top? && total_height <= effective_page_height
822
- start_new_page
825
+ advance_page
823
826
  started_new_page = true
824
827
  else
825
828
  started_new_page = false
@@ -1,5 +1,13 @@
1
1
  class Prawn::Font::AFM
2
- undef_method :normalize_encoding
2
+ FALLBACK_CHARS = {
3
+ %(\u200b) => '',
4
+ %(\u202f) => %(\u00a0),
5
+ %(\u2009) => ' ',
6
+ %(\u25e6) => '-',
7
+ %(\u25aa) => %(\u00b7)
8
+ }
9
+
10
+ remove_method :normalize_encoding
3
11
 
4
12
  # Patch normalize_encoding method to handle conversion more gracefully.
5
13
  #
@@ -7,7 +15,7 @@ class Prawn::Font::AFM
7
15
  # replaced with the logic "not" symbol and a warning is issued identifying
8
16
  # the text that cannot be converted.
9
17
  def normalize_encoding text
10
- text.encode 'windows-1252'
18
+ text.encode 'windows-1252', fallback: FALLBACK_CHARS
11
19
  rescue ::Encoding::UndefinedConversionError
12
20
  warn 'The following text could not be fully converted to the Windows-1252 character set:'
13
21
  warn %(#{text.gsub(/^/, '| ').rstrip})
@@ -12,7 +12,7 @@ module Images
12
12
  # FIXME handle case when SVG is a File or IO object
13
13
  if ::String === file && (file.downcase.end_with? '.svg')
14
14
  opts[:fallback_font_name] ||= default_svg_font if respond_to? :default_svg_font
15
- svg (::IO.read file), opts
15
+ svg((::IO.read file), opts)
16
16
  else
17
17
  _initial_image file, opts
18
18
  end
@@ -135,9 +135,21 @@ class ThemeLoader
135
135
  def expand_vars expr, vars
136
136
  if (idx = (expr.index '$'))
137
137
  if idx == 0 && expr =~ LoneVariableRx
138
- vars[$1]
138
+ if vars.respond_to? $1
139
+ vars[$1]
140
+ else
141
+ warn %(asciidoctor: WARNING: unknown variable reference in PDF theme: $#{$1})
142
+ expr
143
+ end
139
144
  else
140
- expr.gsub(VariableRx) { vars[$1] }
145
+ expr.gsub(VariableRx) {
146
+ if vars.respond_to? $1
147
+ vars[$1]
148
+ else
149
+ warn %(asciidoctor: WARNING: unknown variable reference in PDF theme: $#{$1})
150
+ $&
151
+ end
152
+ }
141
153
  end
142
154
  else
143
155
  expr
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Pdf
3
- VERSION = '1.5.0.alpha.15'
3
+ VERSION = '1.5.0.alpha.16'
4
4
  end
5
5
  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.0.alpha.15
4
+ version: 1.5.0.alpha.16
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: 2017-03-27 00:00:00.000000000 Z
12
+ date: 2017-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -82,7 +82,7 @@ dependencies:
82
82
  version: 0.0.3
83
83
  - - "<="
84
84
  - !ruby/object:Gem::Version
85
- version: 0.0.5
85
+ version: 0.1.1
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -92,7 +92,7 @@ dependencies:
92
92
  version: 0.0.3
93
93
  - - "<="
94
94
  - !ruby/object:Gem::Version
95
- version: 0.0.5
95
+ version: 0.1.1
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: prawn-svg
98
98
  requirement: !ruby/object:Gem::Requirement
@@ -102,7 +102,7 @@ dependencies:
102
102
  version: 0.21.0
103
103
  - - "<"
104
104
  - !ruby/object:Gem::Version
105
- version: 0.27.0
105
+ version: 0.28.0
106
106
  type: :runtime
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
@@ -112,7 +112,7 @@ dependencies:
112
112
  version: 0.21.0
113
113
  - - "<"
114
114
  - !ruby/object:Gem::Version
115
- version: 0.27.0
115
+ version: 0.28.0
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: prawn-icon
118
118
  requirement: !ruby/object:Gem::Requirement
@@ -169,10 +169,8 @@ dependencies:
169
169
  - - '='
170
170
  - !ruby/object:Gem::Version
171
171
  version: 1.5.3
172
- description: 'An extension for Asciidoctor that converts AsciiDoc documents to PDF
173
- using the Prawn PDF library.
174
-
175
- '
172
+ description: |
173
+ An extension for Asciidoctor that converts AsciiDoc documents to PDF using the Prawn PDF library.
176
174
  email: dan@opendevise.com
177
175
  executables:
178
176
  - asciidoctor-pdf
@@ -280,7 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
278
  version: 1.3.1
281
279
  requirements: []
282
280
  rubyforge_project:
283
- rubygems_version: 2.6.8
281
+ rubygems_version: 2.6.11
284
282
  signing_key:
285
283
  specification_version: 4
286
284
  summary: Converts AsciiDoc documents to PDF using Prawn