asciidoctor-pdf 1.5.0.alpha.10 → 1.5.0.alpha.11

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: 03d9ab43813f8db41152d4b2d0004aaa5c6fdf08
4
- data.tar.gz: 85f3a33dd273be7f2a3c96e57970243d28c6c3eb
3
+ metadata.gz: d57d63736925f3f95abbe68750ee04c0011da449
4
+ data.tar.gz: 67c4ec4db9b252a03ae6baa1c3e5bebf3deb57a7
5
5
  SHA512:
6
- metadata.gz: e6fb7d474c712cc68dc57d9a7bd1e6f6c6e0804d42d53a90a4f452a4ce6da40b12f74ef50db6b88a62aa1b1649210ad6a7f7f8685235c3304765bceac4adaecb
7
- data.tar.gz: 4b8d0b17b2ab5d015b586a8f2d1754c6ca97c4f7beee7645e343667e5adad634bb3b3d66592a87ce89448861c45817c37ec4825beeef927297c3ab9cc37d1fee
6
+ metadata.gz: 06d8e5edb049cf5cd1622f04b6f91eac6b366a06dd58647dc086d33f26ddb9bc15b5b00956c8a7df06d00ead309a418fdb436795e1eb1a73353b753fdb099fda
7
+ data.tar.gz: b059d077c26efc23b45d0cbe28b0249ca4e7738021d58028a9a19e8ee7255da7357d30c95cd5878c4c93502dbf6a5617484e3eda6f740a39d78643ca20f52cf5
@@ -1,6 +1,6 @@
1
1
  .The MIT License
2
2
  ....
3
- Copyright (C) 2014-2015 OpenDevise Inc. and the Asciidoctor Project
3
+ Copyright (C) 2014-2016 OpenDevise Inc. and the Asciidoctor Project
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
1
1
  = Asciidoctor PDF
2
2
  OpenDevise Inc.; Asciidoctor Project
3
3
 
4
- Copyright (C) 2014-2015 OpenDevise Inc. and the Asciidoctor Project.
4
+ Copyright (C) 2014-2016 OpenDevise Inc. and the Asciidoctor Project.
5
5
 
6
6
  Please visit the Asciidoctor project site for more information:
7
7
 
@@ -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.10, 2015-11-01
3
+ v1.5.0.alpha.11, 2016-01-05
4
4
  // Settings:
5
5
  :compat-mode!:
6
6
  :experimental:
@@ -80,6 +80,7 @@ Picking up from there, {project-name} takes the pain out of creating PDF documen
80
80
  * Page numbering
81
81
  * Customizable running content (header and footer)
82
82
  * “Keep together” blocks (i.e., page breaks avoided in certain block content)
83
+ * Autofit verbatim blocks (as permitted by base_font_size_min setting)
83
84
  * Orphan section titles avoided
84
85
  * Table border settings honored
85
86
  * Font-based icons
@@ -103,7 +104,7 @@ If you need to use Asciidoctor PDF with Ruby 1.9.3, you must first install Prawn
103
104
  You can then proceed with installation of Asciidoctor PDF.
104
105
  ====
105
106
 
106
- To check you have Ruby available, use the `ruby` command to query the version installed:
107
+ To check if you have Ruby available, use the `ruby` command to query the version installed:
107
108
 
108
109
  $ ruby --version
109
110
 
@@ -113,10 +114,10 @@ You can get {project-name} by <<install-the-published-gem,installing the publish
113
114
 
114
115
  === Install the published gem
115
116
 
116
- {project-name} is published in pre-release on RubyGems.org.
117
+ {project-name} is published as a pre-release on RubyGems.org.
117
118
  You can install the published gem using the following command:
118
119
 
119
- $ gem install --pre asciidoctor-pdf
120
+ $ gem install asciidoctor-pdf --pre
120
121
 
121
122
  If you want to syntax highlight source listings, you'll also want to install CodeRay, Rouge or Pygments.
122
123
  Choose one (or more) of the following:
@@ -130,7 +131,7 @@ Choose one (or more) of the following:
130
131
  .Pygments
131
132
  $ gem install pygments.rb
132
133
 
133
- You then activate syntax highlighting for a given document by adding the following attribute to the document header (CodeRay shown):
134
+ You then activate syntax highlighting for a given document by adding the `source-highlighter` attribute to the document header (CodeRay shown):
134
135
 
135
136
  [source,asciidoc]
136
137
  ----
@@ -174,6 +175,9 @@ This command is just a shorthand way of running:
174
175
 
175
176
  $ asciidoctor -r asciidoctor-pdf -b pdf basic-example.adoc
176
177
 
178
+ The `asciidoctor-pdf` command just saves you from having to remember all those flags.
179
+ That's why we created it.
180
+
177
181
  When the script completes, you should see the file [file]_basic-example.pdf_ in the same directory.
178
182
  Open the [file]_basic-example.pdf_ file with a PDF viewer to see the result.
179
183
 
@@ -286,7 +290,7 @@ You can retrieve the source of {project-name} in one of two ways:
286
290
 
287
291
  ==== Option 1: Fetch using git clone
288
292
 
289
- If you want to clone the git repository, simply copy the {uri-project-repo}[GitHub repository URL] and pass it to `git clone` command:
293
+ If you want to clone the git repository, simply copy the {uri-project-repo}[GitHub repository URL] and pass it to the `git clone` command:
290
294
 
291
295
  $ git clone https://github.com/asciidoctor/asciidoctor-pdf
292
296
 
@@ -314,7 +318,7 @@ We like RVM because it keeps the dependencies required by various projects isola
314
318
  The dependencies needed to use {project-name} are defined in the [file]_Gemfile_ at the root of the project.
315
319
  We can use Bundler to install the dependencies for us.
316
320
 
317
- To check you have Bundler available, use the `bundle` command to query the version installed:
321
+ To check you have Bundler available, use the `bundle` command to query the installed version:
318
322
 
319
323
  $ bundle --version
320
324
 
@@ -352,7 +356,7 @@ For best results, be sure to always use `bundle exec` whenever invoking the `./b
352
356
 
353
357
  == Copyright
354
358
 
355
- Copyright (C) 2014-2015 OpenDevise Inc. and the Asciidoctor Project.
359
+ Copyright (C) 2014-2016 OpenDevise Inc. and the Asciidoctor Project.
356
360
  Free use of this software is granted under the terms of the MIT License.
357
361
 
358
362
  For the full text of the license, see the <<LICENSE.adoc#,LICENSE>> file.
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative '../lib/asciidoctor-pdf'
3
+ if File.exist?(asciidoctor_pdf = (File.expand_path '../../lib/asciidoctor-pdf', __FILE__))
4
+ require asciidoctor_pdf
5
+ else
6
+ require 'asciidoctor-pdf'
7
+ end
4
8
  require 'asciidoctor/cli'
5
9
 
6
10
  options = Asciidoctor::Cli::Options.new backend: 'pdf', header_footer: true
@@ -5,7 +5,7 @@ page_background_color: 'FFFFFF'
5
5
  page_layout: portrait
6
6
  # 36 is equivalent to 0.5in
7
7
  page_margin: 36
8
- page_size: LETTER
8
+ page_size: A4
9
9
  base_align: left
10
10
  #base_font_color: '333333'
11
11
  base_font_color: '000000'
@@ -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
- size: LETTER
28
+ size: A4
29
29
  base:
30
30
  align: justify
31
31
  # color as hex string (leading # is optional)
@@ -85,9 +85,9 @@ heading:
85
85
  h6_font_size: $base_font_size_small
86
86
  #line_height: 1.4
87
87
  # correct line height for Noto Serif metrics (comes with built-in line height)
88
- line_height: 1.2
89
- margin_top: $vertical_rhythm * 0.2
90
- margin_bottom: $vertical_rhythm * 0.8
88
+ line_height: 1
89
+ margin_top: $vertical_rhythm * 0.4
90
+ margin_bottom: $vertical_rhythm * 0.9
91
91
  title_page:
92
92
  align: right
93
93
  logo:
@@ -125,10 +125,16 @@ abstract:
125
125
  font_size: $lead_font_size
126
126
  line_height: $lead_line_height
127
127
  font_style: italic
128
+ first_line_font_style: bold
128
129
  admonition:
129
130
  border_color: $base_border_color
130
131
  border_width: $base_border_width
131
132
  padding: [0, $horizontal_rhythm, 0, $horizontal_rhythm]
133
+ # icon:
134
+ # tip:
135
+ # name: fa-lightbulb-o
136
+ # stroke_color: 111111
137
+ # size: 24
132
138
  blockquote:
133
139
  font_color: $base_font_color
134
140
  font_size: $base_font_size_large
@@ -213,22 +213,27 @@ You can define arbitrary key names to make custom variables.
213
213
  This is one way to group reusable values at the top of your theme file.
214
214
  If you are going to do this, it's recommended that you organize the keys under a custom namespace, such as `brand`.
215
215
 
216
- For instance, here's how you can define your (very patriotic) brand colors:
216
+ For instance, here's how you can define your brand colors:
217
217
 
218
218
  [source,yaml]
219
219
  ----
220
220
  brand:
221
- red: #E0162B
222
- white: #FFFFFF
223
- blue: #0052A5
221
+ primary: #E0162B # <1>
222
+ secondary: '#FFFFFF' # <2>
223
+ alert: '0052A5' # <3>
224
224
  ----
225
+ <1> To align with CSS, you may add a `+#+` in front of the hex color value.
226
+ A YAML preprocessor is used to ensure the value is not treated as a comment as it would normally be the case in YAML.
227
+ <2> You may put quotes around the CSS-style hex value to make it friendly to a YAML editor or validation tool.
228
+ <3> The leading `+#+` on a hex value is entirely optional.
229
+ However, we recommend that you always use either a leading `+#+` or surrounding quotes (or both) to prevent YAML from mangling the value.
225
230
 
226
231
  You can now use these custom variables later in the theme file:
227
232
 
228
233
  [source,yaml]
229
234
  ----
230
235
  base:
231
- font_color: $brand_blue
236
+ font_color: $brand_primary
232
237
  ----
233
238
 
234
239
  === Math expressions & functions
@@ -339,29 +344,37 @@ The order of elements in a measurement array is the same as it is in CSS:
339
344
 
340
345
  The theme language supports color values in three formats:
341
346
 
342
- Hex:: A string of 3 or 6 characters with an optional leading `#`.
343
- +
344
- The special value `transparent` indicates that a color should not be used.
347
+ Hex:: A string of 3 or 6 characters with an optional leading `#`, optional surrounding quotes or both.
345
348
  RGB:: An array of numeric values ranging from 0 to 255.
346
349
  CMYK:: An array of numeric values ranging from 0 to 1 or from 0% to 100%.
350
+ Transparent:: The special value `transparent` indicates that a color should not be used.
347
351
 
348
352
  ==== Hex
349
353
 
350
354
  The hex color value is likely most familiar to web developers.
351
- The value must be either 3 or 6 characters (case insensitive) with an optional leading hash (`#`).
355
+ The value must be either 3 or 6 characters (case insensitive) with an optional leading hash (`#`), optional surrounding quotes or both.
356
+
357
+ To align with CSS, you may add a `+#+` in front of the hex color value.
358
+ A YAML preprocessor is used to ensure the value is not treated as a comment as it would normally be the case in YAML.
359
+
360
+ You also may put quotes around the CSS-style hex value to make it friendly to a YAML editor or validation tool.
361
+ In this case, the leading `+#+` on a hex value is entirely optional.
362
+
363
+ Regardless, we recommend that you always use either a leading `+#+` or surrounding quotes (or both) to prevent YAML from mangling the value.
352
364
 
353
365
  The following are all equivalent values for the color red:
354
366
 
355
367
  [%autowidth,cols=4]
356
368
  |===
357
- |f00
358
369
  |#f00
359
- |ff0000
370
+ |'f00'
360
371
  |#ff0000
361
- |F00
372
+ |'ff0000'
373
+
362
374
  |#F00
363
- |FF0000
375
+ |'F00'
364
376
  |#FF0000
377
+ |'FF0000'
365
378
  |===
366
379
 
367
380
  Here's how a hex color value appears in the theme file:
@@ -372,14 +385,6 @@ base:
372
385
  font_color: #ff0000
373
386
  ----
374
387
 
375
- It's also possible to specify no color by assigning the special value `transparent` as shown here:
376
-
377
- [source,yaml]
378
- ----
379
- base:
380
- background_color: transparent
381
- ----
382
-
383
388
  ==== RGB
384
389
 
385
390
  An RGB array value must be three numbers ranging from 0 to 255.
@@ -420,6 +425,16 @@ base:
420
425
  font_color: [0, 0.99, 1, 0]
421
426
  ----
422
427
 
428
+ ==== Transparent
429
+
430
+ It's possible to specify no color by assigning the special value `transparent`, as shown here:
431
+
432
+ [source,yaml]
433
+ ----
434
+ base:
435
+ background_color: transparent
436
+ ----
437
+
423
438
  === Images
424
439
 
425
440
  An image is specified either as a bare image path or as an inline image macro as found in the AsciiDoc syntax.
@@ -670,11 +685,11 @@ TBW
670
685
  |===
671
686
  |Key |Value Type |Example
672
687
 
673
- |page_background_color
688
+ |page_background_color^[1]^
674
689
  |<<colors,color>>
675
690
  |background_color: #ffffff
676
691
 
677
- |page_background_image
692
+ |page_background_image^[1]^
678
693
  |path (absolute or relative to pdf-stylesdir)
679
694
  |+background_image: image:watermark.png[]+
680
695
 
@@ -692,6 +707,11 @@ TBW
692
707
  |size: Letter
693
708
  |===
694
709
 
710
+ ^[1]^ Page background colors and images do not currently work when using AsciidoctorJ PDF.
711
+ This limitation is due to a bug in Prawn 1.3.1.
712
+ The limitation will remain until AsciidoctorJ PDF upgrades to Prawn 2.x (an upgrade that is waiting on AsciidoctorJ to migrate to JRuby 9000).
713
+ For more details, see http://discuss.asciidoctor.org/Asciidoctor-YAML-style-file-for-PDF-and-maven-td3849.html[this thread].
714
+
695
715
  === Base
696
716
 
697
717
  [cols="3,3,5m"]
@@ -726,6 +746,10 @@ TBW
726
746
  |<<values,number>>
727
747
  |font_size_small: 9
728
748
 
749
+ |base_font_size_min
750
+ |<<values,number>>
751
+ |font_size_small: 6
752
+
729
753
  |base_font_style
730
754
  |normal, italic, bold, bold_italic
731
755
  |font_style: normal
@@ -879,11 +903,11 @@ The literal key is used for inline monospaced text in prose and table cells.
879
903
  |left, center, right, justify
880
904
  |align: right
881
905
 
882
- |title_page_background_color
906
+ |title_page_background_color^[1]^
883
907
  |<<colors,color>>
884
908
  |background_color: #eaeaea
885
909
 
886
- |title_page_background_image
910
+ |title_page_background_image^[1]^
887
911
  |path (absolute or relative to pdf-stylesdir)
888
912
  |+background_image: image:title.png[]+
889
913
 
@@ -946,6 +970,11 @@ The literal key is used for inline monospaced text in prose and table cells.
946
970
 
947
971
  TIP: The title page can be disabled from the document by setting the `notitle` attribute in the document header.
948
972
 
973
+ ^[1]^ Background colors and images do not currently work when using AsciidoctorJ PDF.
974
+ This limitation is due to a bug in Prawn 1.3.1.
975
+ The limitation will remain until AsciidoctorJ PDF upgrades to Prawn 2.x (an upgrade that is waiting on AsciidoctorJ to migrate to JRuby 9000).
976
+ For more details, see http://discuss.asciidoctor.org/Asciidoctor-YAML-style-file-for-PDF-and-maven-td3849.html[this thread].
977
+
949
978
  === Block
950
979
 
951
980
  [cols="3,3,5m"]
@@ -1578,7 +1607,9 @@ In addition, the following attributes are also available when defining the conte
1578
1607
  * section-title
1579
1608
  * section-or-chapter-title
1580
1609
 
1581
- Here's an example that shows how attributes can be used in the running footer:
1610
+ You can also built-in AsciiDoc text replacements like `+(C)+` or numeric character references like `+&#169;+`.
1611
+
1612
+ Here's an example that shows how attributes and replacements can be used in the running footer:
1582
1613
 
1583
1614
  [source,yaml]
1584
1615
  ----
@@ -1586,7 +1617,7 @@ header:
1586
1617
  height: 0.75in
1587
1618
  line_height: 1
1588
1619
  recto_content:
1589
- center: 'v{revnumber}, {docdate}'
1620
+ center: '(C) ACME -- v{revnumber}, {docdate}'
1590
1621
  verso_content:
1591
1622
  center: $header_recto_content
1592
1623
  footer:
@@ -4,7 +4,6 @@ require 'prawn'
4
4
  require 'prawn-svg'
5
5
  require 'prawn/table'
6
6
  require 'prawn/templates'
7
- require 'prawn/icon'
8
7
  require_relative 'core_ext'
9
8
  require_relative 'pdf_core_ext'
10
9
  require_relative 'temporary_path'
@@ -68,7 +67,6 @@ class Converter < ::Prawn::Document
68
67
  checked: %(\u2611),
69
68
  unchecked: %(\u2610)
70
69
  }
71
- IconSets = ['fa', 'fi', 'octicon', 'pf'].to_set
72
70
  MeasurementRxt = '\\d+(?:\\.\\d+)?(?:in|cm|mm|pt|)'
73
71
  MeasurementPartsRx = /^(\d+(?:\.\d+)?)(in|mm|cm|pt|)$/
74
72
  PageSizeRx = /^(?:\[(#{MeasurementRxt}), ?(#{MeasurementRxt})\]|(#{MeasurementRxt})(?: x |x)(#{MeasurementRxt})|\S+)$/
@@ -161,7 +159,7 @@ class Converter < ::Prawn::Document
161
159
  end
162
160
 
163
161
  num_front_matter_pages = page_number - 1
164
- font @theme.base_font_family, size: @theme.base_font_size
162
+ font @theme.base_font_family, size: @theme.base_font_size, style: @theme.base_font_style.to_sym
165
163
  convert_content_for_block doc
166
164
 
167
165
  # NOTE delete orphaned page (a page was created but there was no additional content)
@@ -194,7 +192,7 @@ class Converter < ::Prawn::Document
194
192
 
195
193
  # TODO only allow method to be called once (or we need a reset)
196
194
  def init_pdf doc
197
- theme = ThemeLoader.load_theme doc.attr('pdf-style'), (stylesdir = (doc.attr 'pdf-stylesdir'))
195
+ theme = ThemeLoader.load_theme doc.attr('pdf-style'), doc.attr('pdf-stylesdir')
198
196
  @theme = theme
199
197
  pdf_opts = (build_pdf_options doc, theme)
200
198
  # QUESTION should we preserve page options (otherwise, not readily available)
@@ -270,7 +268,7 @@ class Converter < ::Prawn::Document
270
268
  end
271
269
  end
272
270
 
273
- pdf_opts[:page_size] = (page_size || 'LETTER')
271
+ pdf_opts[:page_size] = (page_size || 'A4')
274
272
 
275
273
  pdf_opts[:text_formatter] ||= FormattedText::Formatter.new theme: theme
276
274
  pdf_opts
@@ -296,7 +294,7 @@ class Converter < ::Prawn::Document
296
294
  info[:Creator] = str2pdfval %(Asciidoctor PDF #{::Asciidoctor::Pdf::VERSION}, based on Prawn #{::Prawn::VERSION})
297
295
  info[:Producer] ||= (info[:Author] || info[:Creator])
298
296
  # FIXME use docdate attribute
299
- info[:ModDate] = info[:CreationDate] = ::Time.now
297
+ info[:ModDate] = info[:CreationDate] = ::Time.now unless doc.attr? 'reproducible'
300
298
  info
301
299
  end
302
300
 
@@ -338,8 +336,11 @@ class Converter < ::Prawn::Document
338
336
  add_dest_for_block node if node.id
339
337
  pad_box @theme.abstract_padding do
340
338
  theme_font :abstract do
341
- # FIXME control first_line_options using theme
342
- prose_opts = { line_height: @theme.abstract_line_height, first_line_options: { styles: [font_style, :bold] } }
339
+ prose_opts = { line_height: @theme.abstract_line_height }
340
+ # FIXME control more first_line_options using theme
341
+ if (line1_font_style = @theme.abstract_first_line_font_style) && line1_font_style.to_sym != font_style
342
+ prose_opts[:first_line_options] = { styles: [font_style, line1_font_style.to_sym] }
343
+ end
343
344
  # FIXME make this cleaner!!
344
345
  if node.blocks?
345
346
  node.blocks.each do |child|
@@ -815,14 +816,14 @@ class Converter < ::Prawn::Document
815
816
  when 'svg'
816
817
  begin
817
818
  svg_data = ::IO.read image_path
818
- svg_obj = ::Prawn::Svg::Interface.new svg_data, self, position: position, width: width
819
+ svg_obj = ::Prawn::Svg::Interface.new svg_data, self, position: position, width: width, fallback_font_name: default_svg_font
819
820
  svg_size = svg_obj.document.sizing
820
821
  rendered_w = svg_size.output_width
821
822
  if !width && (svg_obj.document.root.attributes.key? 'width')
822
823
  # NOTE scale native width & height by 75% to convert px to pt; restrict width to bounds.width
823
824
  if (adjusted_w = [bounds.width, rendered_w * 0.75].min) != rendered_w
824
825
  # FIXME would be nice to have a resize/recalculate method; instead, just reconstruct
825
- svg_obj = ::Prawn::Svg::Interface.new svg_data, self, position: position, width: (rendered_w = adjusted_w)
826
+ svg_obj = ::Prawn::Svg::Interface.new svg_data, self, position: position, width: (rendered_w = adjusted_w), fallback_font_name: default_svg_font
826
827
  svg_size = svg_obj.document.sizing
827
828
  end
828
829
  end
@@ -1238,6 +1239,10 @@ class Converter < ::Prawn::Document
1238
1239
  table_width = bounds.width * ((node.attr 'tablepcwidth') / 100.0)
1239
1240
  even_column_pct = 100.0 / node.columns.size
1240
1241
  column_widths = node.columns.map {|col| ((col.attr 'colpcwidth', even_column_pct) * table_width) / 100.0 }
1242
+ # NOTE Asciidoctor core doesn't always add colpcwidth values up to 100%
1243
+ unless column_widths.empty? || (width_delta = table_width - column_widths.reduce(:+)).zero?
1244
+ column_widths[-1] += width_delta
1245
+ end
1241
1246
  end
1242
1247
 
1243
1248
  if ((position = node.attr 'align') && (AlignmentNames.include? position)) ||
@@ -1413,10 +1418,9 @@ class Converter < ::Prawn::Document
1413
1418
  else
1414
1419
  size_attr = nil
1415
1420
  end
1416
- @icon_font_data ||= ::Prawn::Icon::FontData.load self, icon_set
1417
1421
  begin
1418
1422
  # TODO support rotate and flip attributes; support fw (full-width) size
1419
- img = %(<font name="#{icon_set}"#{size_attr}>#{@icon_font_data.unicode icon_name}</font>)
1423
+ img = %(<font name="#{icon_set}"#{size_attr}>#{::Prawn::Icon::FontData.load(self, icon_set).unicode icon_name}</font>)
1420
1424
  rescue
1421
1425
  warn %(asciidoctor: WARNING: #{icon_name} is not a valid icon name in the #{icon_set} icon set)
1422
1426
  end
@@ -1783,7 +1787,7 @@ class Converter < ::Prawn::Document
1783
1787
 
1784
1788
  def admonition_icon_data key
1785
1789
  if (icon_data = @theme[%(admonition_icon_#{key})])
1786
- AdmonitionIcons[key].merge icon_data
1790
+ (AdmonitionIcons[key] || {}).merge icon_data
1787
1791
  else
1788
1792
  AdmonitionIcons[key]
1789
1793
  end
@@ -2092,6 +2096,10 @@ class Converter < ::Prawn::Document
2092
2096
  ::File.absolute_path font_file, fonts_dir
2093
2097
  end
2094
2098
 
2099
+ def default_svg_font
2100
+ @theme.svg_font_family || @theme.base_font_family
2101
+ end
2102
+
2095
2103
  # QUESTION should we pass a category as an argument?
2096
2104
  # QUESTION should we make this a method on the theme ostruct? (e.g., @theme.resolve_color key, fallback)
2097
2105
  def resolve_theme_color key, fallback_color = nil
@@ -2346,9 +2354,10 @@ class Converter < ::Prawn::Document
2346
2354
 
2347
2355
  # QUESTION is this method still necessary?
2348
2356
  def resolve_imagesdir doc
2349
- @imagesdir ||= begin
2350
- imagesdir = (doc.attr 'imagesdir', '.').chomp '/'
2351
- imagesdir = imagesdir == '.' ? nil : %(#{imagesdir}/)
2357
+ if (imagesdir = doc.attr 'imagesdir').nil_or_empty? || (imagesdir = imagesdir.chomp '/') == '.'
2358
+ nil
2359
+ else
2360
+ %(#{imagesdir}/)
2352
2361
  end
2353
2362
  end
2354
2363
 
@@ -2453,8 +2462,9 @@ class Converter < ::Prawn::Document
2453
2462
  # QUESTION is there a better way to do this?
2454
2463
  # I suppose we could have @tmp_files as an instance variable on converter instead
2455
2464
  # It might be sufficient to delete temporary files once per conversion
2465
+ # NOTE Ruby 1.9 will sometimes delete a tmp file before the process exits
2456
2466
  def unlink_tmp_file path
2457
- path.unlink if TemporaryPath === path
2467
+ path.unlink if TemporaryPath === path && path.exist?
2458
2468
  end
2459
2469
 
2460
2470
  # QUESTION move to prawn/extensions.rb?
@@ -58,7 +58,7 @@ module InlineImageArranger
58
58
 
59
59
  # TODO make helper method to calculate width and height of image
60
60
  if fragment[:image_type] == 'svg'
61
- svg_obj = ::Prawn::Svg::Interface.new (::IO.read image_path), doc, at: doc.bounds.top_left, width: image_w
61
+ svg_obj = ::Prawn::Svg::Interface.new (::IO.read image_path), doc, at: doc.bounds.top_left, width: image_w, fallback_font_name: doc.default_svg_font
62
62
  if image_w
63
63
  fragment[:image_width] = svg_obj.document.sizing.output_width
64
64
  fragment[:image_height] = svg_obj.document.sizing.output_height
@@ -1,5 +1,7 @@
1
1
  Prawn::Font::AFM.instance_variable_set :@hide_m17n_warning, true
2
2
 
3
+ require 'prawn/icon'
4
+
3
5
  module Asciidoctor
4
6
  module Prawn
5
7
  module Extensions
@@ -7,6 +9,7 @@ module Extensions
7
9
  include ::Asciidoctor::Pdf::Sanitizer
8
10
  include ::Asciidoctor::PdfCore::PdfObject
9
11
 
12
+ IconSets = ['fa', 'fi', 'octicon', 'pf'].to_set
10
13
  MeasurementValueRx = /(\d+|\d*\.\d+)(in|mm|cm|px|pt)?$/
11
14
 
12
15
  # - :height is the height of a line
@@ -171,11 +174,13 @@ module Extensions
171
174
  end
172
175
 
173
176
  # Enhances the built-in font method to allow the font
174
- # size to be specified as the second option.
177
+ # size to be specified as the second option and to
178
+ # lazily load font-based icons.
175
179
  #
176
180
  def font name = nil, options = {}
177
- if name && ::Numeric === options
178
- options = { size: options }
181
+ if name
182
+ ::Prawn::Icon::FontData.load self, name if IconSets.include? name
183
+ options = { size: options } if ::Numeric === options
179
184
  end
180
185
  super name, options
181
186
  end
@@ -12,6 +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[:at] ||= bounds.top_left
15
+ opts[:fallback_font_name] ||= default_svg_font if respond_to? :default_svg_font
15
16
  svg (::IO.read file), opts
16
17
  else
17
18
  _initial_image file, opts
@@ -4,6 +4,10 @@ module TemporaryPath
4
4
  def unlink
5
5
  ::File.unlink self
6
6
  end
7
+
8
+ def exist?
9
+ ::File.file? self
10
+ end
7
11
  end
8
12
  end
9
13
  end
@@ -13,7 +13,7 @@ class ThemeLoader
13
13
 
14
14
  VariableRx = /\$([a-z0-9_]+)/
15
15
  LoneVariableRx = /^\$([a-z0-9_]+)$/
16
- HexColorValueRx = /[_-]color: (?<quote>"|'|)#?(?<value>[A-Za-z0-9]{3,6})\k<quote>$/
16
+ HexColorEntryRx = /^(?<k>[[:blank:]]*[[:graph:]]+): +(?<q>["']?)#?(?<v>\w{3,6})\k<q> *(?:#.*)?$/
17
17
  MeasurementValueRx = /(?<=^| |\()(\d+(?:\.\d+)?)(in|mm|cm|pt)(?=$| |\))/
18
18
  MultiplyDivideOpRx = /(-?\d+(?:\.\d+)?) *([*\/]) *(-?\d+(?:\.\d+)?)/
19
19
  AddSubtractOpRx = /(-?\d+(?:\.\d+)?) *([+\-]) *(-?\d+(?:\.\d+)?)/
@@ -74,7 +74,7 @@ class ThemeLoader
74
74
  end
75
75
 
76
76
  def self.load_file filename, theme_data = nil
77
- raw_data = (::IO.read filename).each_line.map {|l| l.sub HexColorValueRx, '_color: \'\k<value>\'' }.join
77
+ raw_data = (::IO.read filename).each_line.map {|l| l.sub HexColorEntryRx, '\k<k>: \'\k<v>\'' }.join
78
78
  self.new.load((::SafeYAML.load raw_data), theme_data)
79
79
  end
80
80
 
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Pdf
3
- VERSION = '1.5.0.alpha.10'
3
+ VERSION = '1.5.0.alpha.11'
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.10
4
+ version: 1.5.0.alpha.11
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: 2015-11-02 00:00:00.000000000 Z
12
+ date: 2016-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake