asciidoctor-pdf 1.5.0.alpha.14 → 1.5.0.alpha.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +35 -4
- data/Gemfile +1 -1
- data/README.adoc +33 -3
- data/asciidoctor-pdf.gemspec +6 -5
- data/data/themes/base-theme.yml +3 -1
- data/data/themes/default-theme.yml +5 -5
- data/docs/theming-guide.adoc +86 -37
- data/lib/asciidoctor-pdf.rb +1 -1
- data/lib/asciidoctor-pdf/converter.rb +265 -109
- data/lib/asciidoctor-pdf/core_ext/object.rb +1 -1
- data/lib/asciidoctor-pdf/core_ext/string.rb +1 -1
- data/lib/asciidoctor-pdf/formatted_text/inline_destination_marker.rb +1 -1
- data/lib/asciidoctor-pdf/formatted_text/transform.rb +12 -3
- data/lib/asciidoctor-pdf/pdf-core_ext.rb +1 -0
- data/lib/asciidoctor-pdf/pdf-core_ext/page.rb +8 -1
- data/lib/asciidoctor-pdf/pdf-core_ext/pdf_object.rb +6 -0
- data/lib/asciidoctor-pdf/prawn-table_ext/cell/text.rb +1 -0
- data/lib/asciidoctor-pdf/prawn-templates_ext.rb +5 -0
- data/lib/asciidoctor-pdf/prawn_ext/coderay_encoder.rb +1 -1
- data/lib/asciidoctor-pdf/prawn_ext/extensions.rb +6 -7
- data/lib/asciidoctor-pdf/rouge_ext/formatters/prawn.rb +8 -5
- data/lib/asciidoctor-pdf/theme_loader.rb +3 -4
- data/lib/asciidoctor-pdf/ttfunk_ext.rb +8 -0
- data/lib/asciidoctor-pdf/version.rb +1 -1
- metadata +17 -8
@@ -11,7 +11,7 @@ module InlineDestinationMarker
|
|
11
11
|
end
|
12
12
|
# get precise position of the reference (x, y)
|
13
13
|
dest_rect = fragment.absolute_bounding_box
|
14
|
-
pdf.add_dest name, (pdf.dest_xyz dest_rect
|
14
|
+
pdf.add_dest name, (pdf.dest_xyz dest_rect[0], dest_rect[-1])
|
15
15
|
# prevent any text from being written
|
16
16
|
fragment.conceal
|
17
17
|
end
|
@@ -199,10 +199,19 @@ class Transform
|
|
199
199
|
pname, pvalue = style.split(':', 2)
|
200
200
|
case pname
|
201
201
|
when 'color'
|
202
|
+
# QUESTION should we check whether the value is a valid hex color?
|
202
203
|
unless fragment[:color]
|
203
|
-
|
204
|
-
|
205
|
-
|
204
|
+
case pvalue.length
|
205
|
+
when 6
|
206
|
+
fragment[:color] = pvalue
|
207
|
+
when 7
|
208
|
+
fragment[:color] = pvalue.slice(1, 6) if pvalue.start_with?('#')
|
209
|
+
# QUESTION should we support the 3 character form?
|
210
|
+
#when 3
|
211
|
+
# fragment[:color] = pvalue.each_char.map {|c| c * 2 }.join
|
212
|
+
#when 4
|
213
|
+
# fragment[:color] = pvalue.slice(1, 3).each_char.map {|c| c * 2 }.join if pvalue.start_with?('#')
|
214
|
+
end
|
206
215
|
end
|
207
216
|
when 'font-weight'
|
208
217
|
if pvalue == 'bold'
|
@@ -13,6 +13,13 @@ class PDF::Core::Page
|
|
13
13
|
end
|
14
14
|
@content = document.ref Hash.new
|
15
15
|
dictionary.data[:Contents] << document.state.store[@content]
|
16
|
-
document.
|
16
|
+
document.open_graphics_state
|
17
17
|
end unless method_defined? :new_content_stream
|
18
|
+
|
19
|
+
# Restore the imported_page? method from PDF::Core::Page
|
20
|
+
#
|
21
|
+
# see https://github.com/prawnpdf/pdf-core/commit/0e326a838e142061be8e062168190fae6b3b1dcf
|
22
|
+
def imported_page?
|
23
|
+
@imported_page
|
24
|
+
end unless method_defined? :imported_page?
|
18
25
|
end
|
@@ -97,7 +97,7 @@ class CodeRayEncoder < ::CodeRay::Encoders::Encoder
|
|
97
97
|
@out << { text: text }
|
98
98
|
else
|
99
99
|
# QUESTION should we default to no color?
|
100
|
-
@out << { text: text, color: (COLORS[kind] || COLORS[@open
|
100
|
+
@out << { text: text, color: (COLORS[kind] || COLORS[@open[-1]] || COLORS[:default]) }
|
101
101
|
end
|
102
102
|
@start_of_line = text.end_with? LF
|
103
103
|
end
|
@@ -736,13 +736,12 @@ module Extensions
|
|
736
736
|
end
|
737
737
|
end
|
738
738
|
|
739
|
-
#
|
740
|
-
#
|
741
|
-
#
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
#end
|
739
|
+
# This method is a smarter version of start_new_page. It calls start_new_page
|
740
|
+
# if the current page is the last page of the document. Otherwise, it simply
|
741
|
+
# advances to the next existing page.
|
742
|
+
def advance_page
|
743
|
+
last_page? ? start_new_page : (go_to_page page_number + 1)
|
744
|
+
end
|
746
745
|
|
747
746
|
# Start a new page without triggering the on_page_create callback
|
748
747
|
#
|
@@ -42,8 +42,11 @@ class Prawn < Formatter
|
|
42
42
|
|
43
43
|
def stream tokens, opts = {}
|
44
44
|
if opts[:line_numbers]
|
45
|
-
|
46
|
-
|
45
|
+
if (linenum = opts[:start_line]) > 0
|
46
|
+
linenum -= 1
|
47
|
+
else
|
48
|
+
linenum = 0
|
49
|
+
end
|
47
50
|
fragments = []
|
48
51
|
fragments << (create_linenum_fragment linenum += 1)
|
49
52
|
tokens.each do |tok, val|
|
@@ -66,7 +69,7 @@ class Prawn < Formatter
|
|
66
69
|
# NOTE drop orphaned linenum fragment (due to trailing endline in source)
|
67
70
|
fragments.pop if (last_fragment = fragments[-1]) && last_fragment[:linenum]
|
68
71
|
# NOTE pad numbers that have less digits than the largest line number
|
69
|
-
if (linenum_w = linenum.to_s.
|
72
|
+
if (linenum_w = linenum.to_s.length) > 1
|
70
73
|
# NOTE extra column is the trailing space after the line number
|
71
74
|
linenum_w += 1
|
72
75
|
fragments.each do |fragment|
|
@@ -116,7 +119,7 @@ class Prawn < Formatter
|
|
116
119
|
end
|
117
120
|
if style_rules[:underline]
|
118
121
|
if fragment.key? :styles
|
119
|
-
fragment[:styles] << UnderlineStyle
|
122
|
+
fragment[:styles] << UnderlineStyle[0]
|
120
123
|
else
|
121
124
|
fragment[:styles] = UnderlineStyle.dup
|
122
125
|
end
|
@@ -135,7 +138,7 @@ class Prawn < Formatter
|
|
135
138
|
normalized
|
136
139
|
else
|
137
140
|
normalized = (raw.start_with? '#') ? raw[1..-1] : raw
|
138
|
-
normalized = normalized.each_char.map {|c| c * 2 }.join if normalized.
|
141
|
+
normalized = normalized.each_char.map {|c| c * 2 }.join if normalized.length == 3
|
139
142
|
@normalized_colors[raw] = normalized
|
140
143
|
end
|
141
144
|
end
|
@@ -17,7 +17,6 @@ class ThemeLoader
|
|
17
17
|
VariableRx = /\$([a-z0-9_]+)/
|
18
18
|
LoneVariableRx = /^\$([a-z0-9_]+)$/
|
19
19
|
HexColorEntryRx = /^(?<k>[[:blank:]]*[[:graph:]]+): +(?!null$)(?<q>["']?)#?(?<v>\w{3,6})\k<q> *(?:#.*)?$/
|
20
|
-
MeasurementValueRx = /(?<=^| |\()(-?\d+(?:\.\d+)?)(in|mm|cm|p[txc])(?=$| |\))/
|
21
20
|
MultiplyDivideOpRx = /(-?\d+(?:\.\d+)?) +([*\/]) +(-?\d+(?:\.\d+)?)/
|
22
21
|
AddSubtractOpRx = /(-?\d+(?:\.\d+)?) +([+\-]) +(-?\d+(?:\.\d+)?)/
|
23
22
|
PrecisionFuncRx = /^(round|floor|ceil)\(/
|
@@ -184,11 +183,11 @@ class ThemeLoader
|
|
184
183
|
if value == 'transparent'
|
185
184
|
# FIXME should we have a TransparentColorValue class?
|
186
185
|
return HexColorValue.new value
|
187
|
-
elsif value.
|
186
|
+
elsif value.length == 6
|
188
187
|
return HexColorValue.new value.upcase
|
189
188
|
end
|
190
189
|
when ::Array
|
191
|
-
case value.
|
190
|
+
case value.length
|
192
191
|
# CMYK value
|
193
192
|
when 4
|
194
193
|
value = value.map do |e|
|
@@ -219,7 +218,7 @@ class ThemeLoader
|
|
219
218
|
# Unknown type; coerce to a string
|
220
219
|
value = value.to_s
|
221
220
|
end
|
222
|
-
value = case value.
|
221
|
+
value = case value.length
|
223
222
|
when 6
|
224
223
|
value
|
225
224
|
when 3
|
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.
|
4
|
+
version: 1.5.0.alpha.15
|
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-
|
12
|
+
date: 2017-03-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
version: 1.3.0
|
49
49
|
- - "<"
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: 3.0
|
51
|
+
version: 2.3.0
|
52
52
|
type: :runtime
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
version: 1.3.0
|
59
59
|
- - "<"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.0
|
61
|
+
version: 2.3.0
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: prawn-table
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,16 +77,22 @@ dependencies:
|
|
77
77
|
name: prawn-templates
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.0.3
|
83
|
+
- - "<="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.0.5
|
83
86
|
type: :runtime
|
84
87
|
prerelease: false
|
85
88
|
version_requirements: !ruby/object:Gem::Requirement
|
86
89
|
requirements:
|
87
|
-
- -
|
90
|
+
- - ">="
|
88
91
|
- !ruby/object:Gem::Version
|
89
92
|
version: 0.0.3
|
93
|
+
- - "<="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.0.5
|
90
96
|
- !ruby/object:Gem::Dependency
|
91
97
|
name: prawn-svg
|
92
98
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,14 +147,14 @@ dependencies:
|
|
141
147
|
requirements:
|
142
148
|
- - "~>"
|
143
149
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0.3.
|
150
|
+
version: 0.3.6
|
145
151
|
type: :runtime
|
146
152
|
prerelease: false
|
147
153
|
version_requirements: !ruby/object:Gem::Requirement
|
148
154
|
requirements:
|
149
155
|
- - "~>"
|
150
156
|
- !ruby/object:Gem::Version
|
151
|
-
version: 0.3.
|
157
|
+
version: 0.3.6
|
152
158
|
- !ruby/object:Gem::Dependency
|
153
159
|
name: treetop
|
154
160
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,12 +232,14 @@ files:
|
|
226
232
|
- lib/asciidoctor-pdf/measurements.rb
|
227
233
|
- lib/asciidoctor-pdf/pdf-core_ext.rb
|
228
234
|
- lib/asciidoctor-pdf/pdf-core_ext/page.rb
|
235
|
+
- lib/asciidoctor-pdf/pdf-core_ext/pdf_object.rb
|
229
236
|
- lib/asciidoctor-pdf/pdfmark.rb
|
230
237
|
- lib/asciidoctor-pdf/prawn-svg_ext.rb
|
231
238
|
- lib/asciidoctor-pdf/prawn-svg_ext/interface.rb
|
232
239
|
- lib/asciidoctor-pdf/prawn-table_ext.rb
|
233
240
|
- lib/asciidoctor-pdf/prawn-table_ext/cell/asciidoc.rb
|
234
241
|
- lib/asciidoctor-pdf/prawn-table_ext/cell/text.rb
|
242
|
+
- lib/asciidoctor-pdf/prawn-templates_ext.rb
|
235
243
|
- lib/asciidoctor-pdf/prawn_ext.rb
|
236
244
|
- lib/asciidoctor-pdf/prawn_ext/coderay_encoder.rb
|
237
245
|
- lib/asciidoctor-pdf/prawn_ext/extensions.rb
|
@@ -246,6 +254,7 @@ files:
|
|
246
254
|
- lib/asciidoctor-pdf/sanitizer.rb
|
247
255
|
- lib/asciidoctor-pdf/temporary_path.rb
|
248
256
|
- lib/asciidoctor-pdf/theme_loader.rb
|
257
|
+
- lib/asciidoctor-pdf/ttfunk_ext.rb
|
249
258
|
- lib/asciidoctor-pdf/version.rb
|
250
259
|
homepage: https://github.com/asciidoctor/asciidoctor-pdf
|
251
260
|
licenses:
|