asciidoctor-pdf 1.5.0.alpha.17 → 1.5.0.alpha.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +30 -2
- data/README.adoc +31 -4
- data/asciidoctor-pdf.gemspec +2 -1
- data/docs/theming-guide.adoc +126 -1
- data/lib/asciidoctor-pdf/asciidoctor_ext.rb +3 -1
- data/lib/asciidoctor-pdf/asciidoctor_ext/abstract_block.rb +5 -0
- data/lib/asciidoctor-pdf/asciidoctor_ext/document.rb +3 -0
- data/lib/asciidoctor-pdf/asciidoctor_ext/logging_shim.rb +8 -2
- data/lib/asciidoctor-pdf/asciidoctor_ext/section.rb +16 -8
- data/lib/asciidoctor-pdf/converter.rb +300 -167
- data/lib/asciidoctor-pdf/core_ext.rb +1 -0
- data/lib/asciidoctor-pdf/core_ext/regexp.rb +3 -0
- data/lib/asciidoctor-pdf/formatted_text/formatter.rb +8 -1
- data/lib/asciidoctor-pdf/index_catalog.rb +9 -3
- data/lib/asciidoctor-pdf/measurements.rb +1 -1
- data/lib/asciidoctor-pdf/prawn_ext/extensions.rb +28 -10
- data/lib/asciidoctor-pdf/roman_numeral.rb +12 -0
- data/lib/asciidoctor-pdf/theme_loader.rb +17 -5
- data/lib/asciidoctor-pdf/version.rb +1 -1
- metadata +21 -4
@@ -19,7 +19,7 @@ class Formatter
|
|
19
19
|
def format string, *args
|
20
20
|
options = args[0] || {}
|
21
21
|
string = string.tr_s(WHITESPACE, ' ') if options[:normalize]
|
22
|
-
return [text: string] unless
|
22
|
+
return [text: string] unless FormattingSnifferPattern.match? string
|
23
23
|
if (parsed = @parser.parse(string))
|
24
24
|
@transform.apply(parsed.content)
|
25
25
|
else
|
@@ -27,6 +27,13 @@ class Formatter
|
|
27
27
|
[text: string]
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
# The original purpose of this method is to split paragraphs, but our formatter only works on paragraphs that have
|
32
|
+
# been presplit. Therefore, we just need to wrap the fragments in a single-element array (representing a single
|
33
|
+
# paragraph) and return them.
|
34
|
+
def array_paragraphs fragments
|
35
|
+
[fragments]
|
36
|
+
end
|
30
37
|
end
|
31
38
|
end
|
32
39
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Asciidoctor; module PDF
|
2
2
|
class IndexCatalog
|
3
|
+
include Sanitizer
|
3
4
|
LeadingAlphaRx = /^\p{Alpha}/
|
4
5
|
|
5
6
|
attr_accessor :start_page_number
|
@@ -8,6 +9,11 @@ module Asciidoctor; module PDF
|
|
8
9
|
@categories = {}
|
9
10
|
@start_page_number = 1
|
10
11
|
@dests = {}
|
12
|
+
@sequence = 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def next_anchor_name
|
16
|
+
%(__indexterm-#{@sequence += 1})
|
11
17
|
end
|
12
18
|
|
13
19
|
def store_term names, dest = nil
|
@@ -22,7 +28,7 @@ module Asciidoctor; module PDF
|
|
22
28
|
|
23
29
|
def store_primary_term name, dest = nil
|
24
30
|
store_dest dest if dest
|
25
|
-
(init_category name.chr
|
31
|
+
(init_category uppercase_mb name.chr).store_term name, dest
|
26
32
|
end
|
27
33
|
|
28
34
|
def store_secondary_term primary_name, secondary_name, dest = nil
|
@@ -36,8 +42,8 @@ module Asciidoctor; module PDF
|
|
36
42
|
end
|
37
43
|
|
38
44
|
def init_category name
|
39
|
-
name = '@' unless LeadingAlphaRx
|
40
|
-
@categories[name] ||=
|
45
|
+
name = '@' unless LeadingAlphaRx.match? name
|
46
|
+
@categories[name] ||= IndexTermCategory.new name
|
41
47
|
end
|
42
48
|
|
43
49
|
def find_category name
|
@@ -48,7 +48,7 @@ module Asciidoctor; module PDF
|
|
48
48
|
|
49
49
|
# Resolve measurement values in the string to PDF points.
|
50
50
|
def resolve_measurement_values str
|
51
|
-
if MeasurementValueHintRx
|
51
|
+
if MeasurementValueHintRx.match? str
|
52
52
|
str.gsub(InsetMeasurementValueRx) { to_pt $1.to_f, $2 }
|
53
53
|
else
|
54
54
|
str
|
@@ -357,11 +357,19 @@ module Extensions
|
|
357
357
|
end
|
358
358
|
end
|
359
359
|
|
360
|
-
#
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
360
|
+
# NOTE override built-in draw_indented_formatted_line to insert leading before second line
|
361
|
+
def draw_indented_formatted_line string, opts
|
362
|
+
result = super
|
363
|
+
unless @no_text_printed || @all_text_printed
|
364
|
+
# as of Prawn 1.2.1, we have to handle the line gap after the first line manually
|
365
|
+
move_down opts[:leading]
|
366
|
+
end
|
367
|
+
result
|
368
|
+
end
|
369
|
+
|
370
|
+
# Performs the same work as Prawn::Text.text except that the first_line_opts are applied to the first line of text
|
371
|
+
# renderered. It's necessary to use low-level APIs in this method so we only style the first line and not the
|
372
|
+
# remaining lines (which is the default behavior in Prawn).
|
365
373
|
def text_with_formatted_first_line string, first_line_opts, opts
|
366
374
|
color = opts.delete :color
|
367
375
|
fragments = parse_text string, opts
|
@@ -378,17 +386,27 @@ module Extensions
|
|
378
386
|
first_line_opts = opts.merge(first_line_opts).merge single_line: true
|
379
387
|
box = ::Prawn::Text::Formatted::Box.new fragments, first_line_opts
|
380
388
|
# NOTE get remaining_fragments before we add color to fragments on first line
|
381
|
-
|
389
|
+
if (text_indent = opts.delete :indent_paragraphs)
|
390
|
+
remaining_fragments = indent text_indent do
|
391
|
+
box.render dry_run: true
|
392
|
+
end
|
393
|
+
else
|
394
|
+
remaining_fragments = box.render dry_run: true
|
395
|
+
end
|
382
396
|
# NOTE color must be applied per-fragment
|
383
397
|
if first_line_color
|
384
398
|
fragments.each {|fragment| fragment[:color] ||= first_line_color}
|
385
399
|
end
|
386
|
-
|
400
|
+
if text_indent
|
401
|
+
indent text_indent do
|
402
|
+
fill_formatted_text_box fragments, first_line_opts
|
403
|
+
end
|
404
|
+
else
|
405
|
+
fill_formatted_text_box fragments, first_line_opts
|
406
|
+
end
|
387
407
|
unless remaining_fragments.empty?
|
388
408
|
# NOTE color must be applied per-fragment
|
389
|
-
if color
|
390
|
-
remaining_fragments.each {|fragment| fragment[:color] ||= color }
|
391
|
-
end
|
409
|
+
remaining_fragments.each {|fragment| fragment[:color] ||= color } if color
|
392
410
|
# as of Prawn 1.2.1, we have to handle the line gap after the first line manually
|
393
411
|
move_down opts[:leading]
|
394
412
|
remaining_fragments = fill_formatted_text_box remaining_fragments, opts
|
@@ -73,6 +73,14 @@ class RomanNumeral
|
|
73
73
|
@integer_value
|
74
74
|
end
|
75
75
|
|
76
|
+
def odd?
|
77
|
+
to_i.odd?
|
78
|
+
end
|
79
|
+
|
80
|
+
def even?
|
81
|
+
to_i.even?
|
82
|
+
end
|
83
|
+
|
76
84
|
def next
|
77
85
|
RomanNumeral.new @integer_value + 1, @letter_case
|
78
86
|
end
|
@@ -86,6 +94,10 @@ class RomanNumeral
|
|
86
94
|
RomanNumeral.new @integer_value - 1, @letter_case
|
87
95
|
end
|
88
96
|
|
97
|
+
def empty?
|
98
|
+
false
|
99
|
+
end
|
100
|
+
|
89
101
|
def self.int_to_roman value
|
90
102
|
result = []
|
91
103
|
BaseDigits.keys.reverse_each do |ival|
|
@@ -70,15 +70,27 @@ class ThemeLoader
|
|
70
70
|
theme_data = load_base_theme
|
71
71
|
end
|
72
72
|
|
73
|
-
theme_file == BaseThemePath ? theme_data : (load_file theme_file, theme_data)
|
73
|
+
theme_file == BaseThemePath ? theme_data : (load_file theme_file, theme_data, theme_path)
|
74
74
|
end
|
75
75
|
|
76
|
-
def self.load_file filename, theme_data = nil
|
77
|
-
|
78
|
-
|
76
|
+
def self.load_file filename, theme_data = nil, theme_path = nil
|
77
|
+
yaml_data = ::SafeYAML.load (::File.read filename, encoding: ::Encoding::UTF_8).each_line.map {|l| l.sub HexColorEntryRx, '\k<k>: \'\k<v>\'' }.join
|
78
|
+
if ::Hash === yaml_data && (extend_files = yaml_data.delete 'extends')
|
79
|
+
[*extend_files].each do |extend_file|
|
80
|
+
if extend_file == 'default'
|
81
|
+
extend_file = resolve_theme_file extend_file, (extend_theme_path = ThemesDir)
|
82
|
+
elsif extend_file.start_with? './'
|
83
|
+
extend_file = resolve_theme_file extend_file, (extend_theme_path = (::File.dirname ::File.absolute_path filename))
|
84
|
+
else
|
85
|
+
extend_file = resolve_theme_file extend_file, (extend_theme_path = theme_path)
|
86
|
+
end
|
87
|
+
theme_data = load_file extend_file, theme_data, extend_theme_path
|
88
|
+
end
|
89
|
+
end
|
90
|
+
self.new.load yaml_data, theme_data, theme_path
|
79
91
|
end
|
80
92
|
|
81
|
-
def load hash, theme_data = nil
|
93
|
+
def load hash, theme_data = nil, theme_path = nil
|
82
94
|
theme_data ||= ::OpenStruct.new
|
83
95
|
return theme_data unless ::Hash === hash
|
84
96
|
base_code_font_family = theme_data.delete 'code_font_family'
|
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.18
|
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: 2019-
|
12
|
+
date: 2019-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: asciidoctor
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.5.
|
20
|
+
version: 1.5.3
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 3.0.0
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: 1.5.
|
30
|
+
version: 1.5.3
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 3.0.0
|
@@ -199,6 +199,20 @@ dependencies:
|
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
201
|
version: 1.3.0
|
202
|
+
- !ruby/object:Gem::Dependency
|
203
|
+
name: chunky_png
|
204
|
+
requirement: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 1.3.0
|
209
|
+
type: :development
|
210
|
+
prerelease: false
|
211
|
+
version_requirements: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: 1.3.0
|
202
216
|
description: An extension for Asciidoctor that converts AsciiDoc documents to PDF
|
203
217
|
using the Prawn PDF library.
|
204
218
|
email: dan@opendevise.com
|
@@ -230,6 +244,8 @@ files:
|
|
230
244
|
- docs/theming-guide.adoc
|
231
245
|
- lib/asciidoctor-pdf.rb
|
232
246
|
- lib/asciidoctor-pdf/asciidoctor_ext.rb
|
247
|
+
- lib/asciidoctor-pdf/asciidoctor_ext/abstract_block.rb
|
248
|
+
- lib/asciidoctor-pdf/asciidoctor_ext/document.rb
|
233
249
|
- lib/asciidoctor-pdf/asciidoctor_ext/image.rb
|
234
250
|
- lib/asciidoctor-pdf/asciidoctor_ext/list.rb
|
235
251
|
- lib/asciidoctor-pdf/asciidoctor_ext/list_item.rb
|
@@ -242,6 +258,7 @@ files:
|
|
242
258
|
- lib/asciidoctor-pdf/core_ext/object.rb
|
243
259
|
- lib/asciidoctor-pdf/core_ext/ostruct.rb
|
244
260
|
- lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
|
261
|
+
- lib/asciidoctor-pdf/core_ext/regexp.rb
|
245
262
|
- lib/asciidoctor-pdf/core_ext/string.rb
|
246
263
|
- lib/asciidoctor-pdf/formatted_text.rb
|
247
264
|
- lib/asciidoctor-pdf/formatted_text/formatter.rb
|