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

Sign up to get free protection for your applications and to get access to all the features.
@@ -81,6 +81,18 @@ module Extensions
81
81
  page.margins[:bottom]
82
82
  end
83
83
 
84
+ # Returns the total left margin (to the page edge) for the current bounds.
85
+ #
86
+ def bounds_margin_left
87
+ bounds.absolute_left
88
+ end
89
+
90
+ # Returns the total right margin (to the page edge) for the current bounds.
91
+ #
92
+ def bounds_margin_right
93
+ page.dimensions[2] - bounds.absolute_right
94
+ end
95
+
84
96
  # Returns whether the cursor is at the top of the page (i.e., margin box)
85
97
  #
86
98
  def at_page_top?
@@ -456,11 +468,13 @@ module Extensions
456
468
  #end
457
469
  end
458
470
 
459
- # Stretch the current bounds to the left and right edges of the current page.
471
+ # Stretch the current bounds to the left and right edges of the current page
472
+ # while yielding the specified block if the verdict argument is true.
473
+ # Otherwise, simply yield the specified block.
460
474
  #
461
- def use_page_width_if verdict
475
+ def span_page_width_if verdict
462
476
  if verdict
463
- indent(-bounds.absolute_left, bounds.absolute_right - page_width) do
477
+ indent -bounds_margin_left, -bounds_margin_right do
464
478
  yield
465
479
  end
466
480
  else
@@ -1,7 +1,8 @@
1
1
  module Rouge
2
2
  class CSSTheme
3
3
  # Patch style_for to return most specific style first
4
- # See https://github.com/jneen/rouge/issues/280 (fix pending)
4
+ # See https://github.com/jneen/rouge/issues/280
5
+ # Fixed as of rouge v1.10.0
5
6
  def style_for token
6
7
  token.token_chain.reverse_each do |t|
7
8
  if (s = styles[t])
@@ -11,4 +12,4 @@ class CSSTheme
11
12
  nil
12
13
  end
13
14
  end
14
- end
15
+ end if (Gem::Version.new Rouge.version) < (Gem::Version.new '1.10.0')
@@ -8,7 +8,7 @@ module Sanitizer
8
8
  }
9
9
  BuiltInEntityCharRx = /(?:#{BuiltInEntityChars.keys * '|'})/
10
10
  BuiltInEntityCharOrTagRx = /(?:#{BuiltInEntityChars.keys * '|'}|<)/
11
- NumericCharRefRx = /&#(\d{2,4});/
11
+ NumericCharRefRx = /&#(\d{2,6});/
12
12
  XmlSanitizeRx = /<[^>]+>/
13
13
  SegmentPcdataRx = /(?:(&[a-z]+;|<[^>]+>)|([^&<]+))/
14
14
 
@@ -13,10 +13,10 @@ class ThemeLoader
13
13
 
14
14
  VariableRx = /\$([a-z0-9_]+)/
15
15
  LoneVariableRx = /^\$([a-z0-9_]+)$/
16
- HexColorEntryRx = /^(?<k>[[:blank:]]*[[:graph:]]+): +(?<q>["']?)#?(?<v>\w{3,6})\k<q> *(?:#.*)?$/
17
- MeasurementValueRx = /(?<=^| |\()(\d+(?:\.\d+)?)(in|mm|cm|pt)(?=$| |\))/
18
- MultiplyDivideOpRx = /(-?\d+(?:\.\d+)?) *([*\/]) *(-?\d+(?:\.\d+)?)/
19
- AddSubtractOpRx = /(-?\d+(?:\.\d+)?) *([+\-]) *(-?\d+(?:\.\d+)?)/
16
+ HexColorEntryRx = /^(?<k>[[:blank:]]*[[:graph:]]+): +(?!null$)(?<q>["']?)#?(?<v>\w{3,6})\k<q> *(?:#.*)?$/
17
+ MeasurementValueRx = /(?<=^| |\()(-?\d+(?:\.\d+)?)(in|mm|cm|pt)(?=$| |\))/
18
+ MultiplyDivideOpRx = /(-?\d+(?:\.\d+)?) +([*\/]) +(-?\d+(?:\.\d+)?)/
19
+ AddSubtractOpRx = /(-?\d+(?:\.\d+)?) +([+\-]) +(-?\d+(?:\.\d+)?)/
20
20
  PrecisionFuncRx = /^(round|floor|ceil)\(/
21
21
 
22
22
  # TODO implement white? & black? methods
@@ -86,17 +86,23 @@ class ThemeLoader
86
86
  private
87
87
 
88
88
  def process_entry key, val, data
89
- if key.start_with? 'admonition_icon_'
89
+ if key.start_with? 'font_'
90
+ data[key] = val
91
+ elsif key.start_with? 'admonition_icon_'
90
92
  data[key] = (val || {}).map do |(key2, val2)|
91
- static_val2 = evaluate val2, data
92
- [key2.to_sym, (key2.end_with? '_color') ? to_color(static_val2) : static_val2]
93
+ [key2.to_sym, (key2.end_with? '_color') ? to_color(evaluate val2, data) : (evaluate val2, data)]
93
94
  end.to_h
94
- elsif key != 'font_catalog' && ::Hash === val
95
+ elsif ::Hash === val
95
96
  val.each do |key2, val2|
96
97
  process_entry %(#{key}_#{key2.tr '-', '_'}), val2, data
97
98
  end
99
+ elsif key.end_with? '_color'
100
+ # QUESTION do we need to evaluate_math in this case?
101
+ data[key] = to_color(evaluate val, data)
102
+ elsif %(#{key.chomp '_'}_).include? '_content_'
103
+ data[key] = expand_vars val, data
98
104
  else
99
- data[key] = (key.end_with? '_color') ? to_color(evaluate val, data) : (evaluate val, data)
105
+ data[key] = evaluate val, data
100
106
  end
101
107
  data
102
108
  end
@@ -128,25 +134,22 @@ class ThemeLoader
128
134
  def evaluate_math expr
129
135
  return expr if !(::String === expr) || ColorValue === expr
130
136
  original = expr
131
- # FIXME quick HACK to turn a single negative number into an expression
132
- expr = %(1 - #{expr[1..-1]}) if expr.start_with? '-'
133
137
  # expand measurement values (e.g., 0.5in)
138
+ # QUESTION should we round the value? perhaps leave that to the precision functions
139
+ # NOTE leave % as a string; handled by converter for now
134
140
  expr = expr.gsub(MeasurementValueRx) {
135
141
  # TODO extract to_pt method and use it here
136
142
  val = $1.to_f
137
143
  case $2
138
144
  when 'in'
139
- val = val * 72
145
+ val * 72
140
146
  when 'mm'
141
- val = val * (72 / 25.4)
147
+ val * (72 / 25.4)
142
148
  when 'cm'
143
- val = val * (720 / 25.4)
144
- #when '%'
145
- # val = val / 100.0
146
- # default is pt
149
+ val * (720 / 25.4)
150
+ else
151
+ val # default unit is pt
147
152
  end
148
- # QUESTION should we round the value?
149
- val
150
153
  }
151
154
  while true
152
155
  result = expr.gsub(MultiplyDivideOpRx) { $1.to_f.send $2.to_sym, $3.to_f }
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Pdf
3
- VERSION = '1.5.0.alpha.11'
3
+ VERSION = '1.5.0.alpha.12'
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.11
4
+ version: 1.5.0.alpha.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Allen
@@ -9,34 +9,34 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-05 00:00:00.000000000 Z
12
+ date: 2016-08-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '10.0'
20
+ version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '10.0'
27
+ version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: asciidoctor
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: 1.5.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: 1.5.0
42
42
  - !ruby/object:Gem::Dependency
@@ -93,28 +93,28 @@ dependencies:
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 0.21.0
96
+ version: 0.25.1
97
97
  type: :runtime
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 0.21.0
103
+ version: 0.25.1
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: prawn-icon
106
106
  requirement: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 1.0.0
110
+ version: 1.1.0
111
111
  type: :runtime
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 1.0.0
117
+ version: 1.1.0
118
118
  - !ruby/object:Gem::Dependency
119
119
  name: safe_yaml
120
120
  requirement: !ruby/object:Gem::Requirement
@@ -157,8 +157,10 @@ dependencies:
157
157
  - - '='
158
158
  - !ruby/object:Gem::Version
159
159
  version: 1.5.3
160
- description: |
161
- An extension for Asciidoctor that converts AsciiDoc documents to PDF using the Prawn PDF library.
160
+ description: 'An extension for Asciidoctor that converts AsciiDoc documents to PDF
161
+ using the Prawn PDF library.
162
+
163
+ '
162
164
  email: dan@opendevise.io
163
165
  executables:
164
166
  - asciidoctor-pdf
@@ -168,12 +170,13 @@ extra_rdoc_files:
168
170
  - LICENSE.adoc
169
171
  - NOTICE.adoc
170
172
  files:
173
+ - Gemfile
171
174
  - LICENSE.adoc
172
175
  - NOTICE.adoc
173
176
  - README.adoc
174
177
  - Rakefile
178
+ - asciidoctor-pdf.gemspec
175
179
  - bin/asciidoctor-pdf
176
- - bin/optimize-pdf
177
180
  - data/fonts/LICENSE-mplus-testflight-58
178
181
  - data/fonts/LICENSE-noto-2015-06-05
179
182
  - data/fonts/mplus1mn-bold-ascii.ttf
@@ -235,14 +238,17 @@ licenses:
235
238
  metadata: {}
236
239
  post_install_message:
237
240
  rdoc_options:
238
- - --charset=UTF-8 --title="Asciidoctor PDF" --main=README.adoc -ri
241
+ - "--charset=UTF-8"
242
+ - --title="Asciidoctor PDF"
243
+ - "--main=README.adoc"
244
+ - "-ri"
239
245
  require_paths:
240
246
  - lib
241
247
  required_ruby_version: !ruby/object:Gem::Requirement
242
248
  requirements:
243
249
  - - ">="
244
250
  - !ruby/object:Gem::Version
245
- version: '1.9'
251
+ version: 1.9.3
246
252
  required_rubygems_version: !ruby/object:Gem::Requirement
247
253
  requirements:
248
254
  - - ">"
@@ -250,9 +256,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
256
  version: 1.3.1
251
257
  requirements: []
252
258
  rubyforge_project:
253
- rubygems_version: 2.4.8
259
+ rubygems_version: 2.5.1
254
260
  signing_key:
255
261
  specification_version: 4
256
262
  summary: Converts AsciiDoc documents to PDF using Prawn
257
263
  test_files: []
258
- has_rdoc: true
data/bin/optimize-pdf DELETED
@@ -1,64 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Optimizes and compresses the specified PDF using Ghostscript (gs).
4
- #
5
- # [NOTE]
6
- # You need at least Ghostscript 9.10 in order for page labels defined in the
7
- # PDF to be preserved (e.g., front matter pages numbered using roman numerals).
8
-
9
- if [ -z $1 ]; then
10
- echo "Please supply a PDF file to optimize"
11
- exit 1
12
- fi
13
-
14
- if [ -z $GS ]; then
15
- GS=gs
16
- fi
17
-
18
- FILE=$1
19
- FILE_BASENAME=${FILE%.pdf}
20
- FILE_OPTIMIZED=$FILE_BASENAME-optimized.pdf
21
- FILE_PDFMARKS=
22
- if [ -f "$FILE_BASENAME.pdfmarks" ]; then
23
- FILE_PDFMARKS="$FILE_BASENAME.pdfmarks"
24
- fi
25
- DOWNSAMPLE_IMAGES=true
26
- if [ -z $IMAGE_DPI ]; then
27
- #IMAGE_DPI=150
28
- IMAGE_DPI=300
29
- fi
30
-
31
- # /prepress defaults (see http://ghostscript.com/doc/current/Ps2pdf.htm)
32
- # -d{Color,Gray,Mono}ImageDownsampleType=/Bicubic
33
- # -dAutoFilter{Color,Gray}Images=true
34
- # -dOptimize=true
35
- # -dEmbedAllFonts=true
36
- # -dSubsetFonts=true
37
- # -dColorConversionStrategy=/LeaveColorUnchanged
38
- # -dUCRandBGInfo=/Preserve
39
- # -dCompressPages=true
40
- #
41
- # other unused settings
42
- # -r72
43
- #
44
- # for info about pdfmarks, see http://milan.kupcevic.net/ghostscript-ps-pdf
45
- #
46
- # to convert to grayscale, add the following (though doesn't always work)
47
- #
48
- # -dProcessColorModel=/DeviceGray \
49
- # -dColorConversionStrategy=/Gray \
50
-
51
- "$GS" -q -dNOPAUSE -dBATCH -dSAFER -dNOOUTERSAVE \
52
- -sDEVICE=pdfwrite \
53
- -dPDFSETTINGS=/prepress \
54
- -dCannotEmbedFontPolicy=/Warning \
55
- -dDownsampleColorImages=$DOWNSAMPLE_IMAGES \
56
- -dColorImageResolution=$IMAGE_DPI \
57
- -dDownsampleGrayImages=$DOWNSAMPLE_IMAGES \
58
- -dGrayImageResolution=$IMAGE_DPI \
59
- -dDownsampleMonoImages=$DOWNSAMPLE_IMAGES \
60
- -dMonoImageResolution=$IMAGE_DPI \
61
- -sOutputFile="$FILE_OPTIMIZED" \
62
- "$FILE" $FILE_PDFMARKS
63
-
64
- exit 0