asciidoctor-pdf 2.1.3 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +37 -0
- data/README.adoc +1 -1
- data/bin/asciidoctor-pdf +3 -3
- data/lib/asciidoctor/pdf/converter.rb +31 -21
- data/lib/asciidoctor/pdf/ext/prawn/extensions.rb +0 -23
- data/lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb +5 -2
- data/lib/asciidoctor/pdf/ext/prawn-table/cell/text.rb +3 -1
- data/lib/asciidoctor/pdf/ext/prawn-table/cell.rb +2 -0
- data/lib/asciidoctor/pdf/formatted_text/transform.rb +33 -2
- data/lib/asciidoctor/pdf/index_catalog.rb +1 -1
- data/lib/asciidoctor/pdf/text_transformer.rb +23 -0
- data/lib/asciidoctor/pdf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 626c05cc96837efcf9f6fd0b96f0f31e8791188f27db387609a6a2d6a1345e94
|
4
|
+
data.tar.gz: 311afcb050d8063c6878166b8ce89e2e7bd1986af9b212ee9ee9202d87ba3a53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a82a51068e74bf9ea3bdb89c11a8075a27e58c49fdc84bfdce9066030e7f6688a99a6956bbbd8a1739aa5d2de3eaf5943a9e6ec234ecfce0bc5bc938d0ffc91a
|
7
|
+
data.tar.gz: bad6ea4168ef017bec92534f657ec54208851cb224ae2c4e2c37fe329946192bab9d0e5519c8d2d19cf3c1184185664402523fe7175b4fb496465a3ebed41b01
|
data/CHANGELOG.adoc
CHANGED
@@ -5,6 +5,43 @@
|
|
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 {url-repo}/commits/main[commit history] on GitHub.
|
7
7
|
|
8
|
+
== 2.1.6 (2022-07-19) - @mojavelinux
|
9
|
+
|
10
|
+
Bug Fixes::
|
11
|
+
|
12
|
+
* resolve font size for monospaced cell when font size value on `codespan` key in theme is relative (#2281)
|
13
|
+
|
14
|
+
=== Details
|
15
|
+
|
16
|
+
{url-repo}/releases/tag/v2.1.6[git tag] | {url-repo}/compare/v2.1.5\...v2.1.6[full diff]
|
17
|
+
|
18
|
+
== 2.1.5 (2022-07-10) - @mojavelinux
|
19
|
+
|
20
|
+
Bug Fixes::
|
21
|
+
|
22
|
+
* fix position of background color on caption with outside margin (#2271)
|
23
|
+
* don't allow font scale to compound when entering nested table (#2276)
|
24
|
+
|
25
|
+
=== Details
|
26
|
+
|
27
|
+
{url-repo}/releases/tag/v2.1.5[git tag] | {url-repo}/compare/v2.1.4\...v2.1.5[full diff]
|
28
|
+
|
29
|
+
== 2.1.4 (2022-06-26) - @mojavelinux
|
30
|
+
|
31
|
+
Improvements::
|
32
|
+
|
33
|
+
* include source location in warning message for truncated table cell if sourcemap is enabled (#2261)
|
34
|
+
|
35
|
+
Bug Fixes::
|
36
|
+
|
37
|
+
* allow alt text for block image, video, and audio to wrap to next line on same page (#2258)
|
38
|
+
* apply `text-transform` from custom role on phrase after attributes have been resolved (#2263)
|
39
|
+
* make URL check more strict so image target containing a colon is not mistaken as a URL
|
40
|
+
|
41
|
+
=== Details
|
42
|
+
|
43
|
+
{url-repo}/releases/tag/v2.1.4[git tag] | {url-repo}/compare/v2.1.3\...v2.1.4[full diff]
|
44
|
+
|
8
45
|
== 2.1.3 (2022-06-23) - @mojavelinux
|
9
46
|
|
10
47
|
Bug Fixes::
|
data/README.adoc
CHANGED
@@ -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
|
-
v2.1.
|
3
|
+
v2.1.6, 2022-07-19
|
4
4
|
// Settings:
|
5
5
|
:experimental:
|
6
6
|
:idprefix:
|
data/bin/asciidoctor-pdf
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
if File.file?(asciidoctor_pdf = (File.
|
4
|
+
if File.file? (asciidoctor_pdf = File.join (File.dirname __dir__), 'lib/asciidoctor/pdf.rb')
|
5
5
|
require asciidoctor_pdf
|
6
6
|
else
|
7
7
|
require 'asciidoctor/pdf'
|
@@ -10,14 +10,14 @@ require 'asciidoctor/cli'
|
|
10
10
|
|
11
11
|
options = Asciidoctor::Cli::Options.new backend: 'pdf', header_footer: true
|
12
12
|
|
13
|
-
# FIXME provide an API in Asciidoctor for sub-components to print version information
|
13
|
+
# FIXME: provide an API in Asciidoctor for sub-components to print version information
|
14
14
|
unless ARGV != ['-v'] && (ARGV & ['-V', '--version']).empty?
|
15
15
|
$stdout.write %(Asciidoctor PDF #{Asciidoctor::PDF::VERSION} using )
|
16
16
|
options.print_version
|
17
17
|
exit 0
|
18
18
|
end
|
19
19
|
|
20
|
-
# FIXME This is a really bizarre API. Please make me simpler.
|
20
|
+
# FIXME: This is a really bizarre API. Please make me simpler.
|
21
21
|
case (result = options.parse! ARGV)
|
22
22
|
when Integer
|
23
23
|
exit result
|
@@ -27,8 +27,6 @@ module Asciidoctor
|
|
27
27
|
|
28
28
|
attr_accessor :font_scale
|
29
29
|
|
30
|
-
attr_reader :root_font_size
|
31
|
-
|
32
30
|
attr_reader :index
|
33
31
|
|
34
32
|
attr_reader :theme
|
@@ -114,6 +112,7 @@ module Asciidoctor
|
|
114
112
|
UriBreakCharsRx = %r((?:/|\?|&|#)(?!$))
|
115
113
|
UriBreakCharRepl = %(\\&#{ZeroWidthSpace})
|
116
114
|
UriSchemeBoundaryRx = %r((?<=://))
|
115
|
+
UrlSniffRx = %r(^\p{Alpha}[\p{Alnum}+.-]*://)
|
117
116
|
LineScanRx = /\n|.+/
|
118
117
|
BlankLineRx = /\n{2,}/
|
119
118
|
CjkLineBreakRx = /(?=[\u3000\u30a0-\u30ff\u3040-\u309f\p{Han}\uff00-\uffef])/
|
@@ -1886,7 +1885,7 @@ module Asciidoctor
|
|
1886
1885
|
add_dest_for_block node if node.id
|
1887
1886
|
audio_path = node.media_uri node.attr 'target'
|
1888
1887
|
play_symbol = (node.document.attr? 'icons', 'font') ? %(<font name="fas">#{(icon_font_data 'fas').unicode 'play'}</font>) : RightPointer
|
1889
|
-
ink_prose %(#{play_symbol}#{NoBreakSpace}<a href="#{audio_path}">#{audio_path}</a> <em>(audio)</em>), normalize: false, margin: 0
|
1888
|
+
ink_prose %(#{play_symbol}#{NoBreakSpace}<a href="#{audio_path}">#{audio_path}</a> <em>(audio)</em>), normalize: false, margin: 0
|
1890
1889
|
ink_caption node, labeled: false, end: :bottom if node.title?
|
1891
1890
|
theme_margin :block, :bottom, (next_enclosed_block node)
|
1892
1891
|
end
|
@@ -1914,7 +1913,7 @@ module Asciidoctor
|
|
1914
1913
|
if poster.nil_or_empty?
|
1915
1914
|
add_dest_for_block node if node.id
|
1916
1915
|
play_symbol = (node.document.attr? 'icons', 'font') ? %(<font name="fas">#{(icon_font_data 'fas').unicode 'play'}</font>) : RightPointer
|
1917
|
-
ink_prose %(#{play_symbol}#{NoBreakSpace}<a href="#{video_path}">#{video_path}</a> <em>(#{type})</em>), normalize: false, margin: 0
|
1916
|
+
ink_prose %(#{play_symbol}#{NoBreakSpace}<a href="#{video_path}">#{video_path}</a> <em>(#{type})</em>), normalize: false, margin: 0
|
1918
1917
|
ink_caption node, labeled: false, end: :bottom if node.title?
|
1919
1918
|
theme_margin :block, :bottom, (next_enclosed_block node)
|
1920
1919
|
else
|
@@ -1995,6 +1994,7 @@ module Asciidoctor
|
|
1995
1994
|
num_cols = node.columns.size
|
1996
1995
|
table_header_size = false
|
1997
1996
|
theme = @theme
|
1997
|
+
prev_font_scale, @font_scale = @font_scale, 1 if node.document.nested?
|
1998
1998
|
|
1999
1999
|
tbl_bg_color = resolve_theme_color :table_background_color
|
2000
2000
|
# QUESTION: should we fallback to page background color? (which is never transparent)
|
@@ -2053,7 +2053,8 @@ module Asciidoctor
|
|
2053
2053
|
content: cell_text,
|
2054
2054
|
colspan: cell.colspan || 1,
|
2055
2055
|
align: (cell.attr 'halign').to_sym,
|
2056
|
-
valign: (val = cell.attr 'valign') == 'middle' ? :center : val.to_sym
|
2056
|
+
valign: (val = cell.attr 'valign') == 'middle' ? :center : val.to_sym,
|
2057
|
+
source_location: cell.source_location
|
2057
2058
|
end)
|
2058
2059
|
end
|
2059
2060
|
end unless head_rows.empty?
|
@@ -2072,7 +2073,8 @@ module Asciidoctor
|
|
2072
2073
|
colspan: cell.colspan || 1,
|
2073
2074
|
rowspan: cell.rowspan || 1,
|
2074
2075
|
align: (cell.attr 'halign').to_sym,
|
2075
|
-
valign: (val = cell.attr 'valign') == 'middle' ? :center : val.to_sym
|
2076
|
+
valign: (val = cell.attr 'valign') == 'middle' ? :center : val.to_sym,
|
2077
|
+
source_location: cell.source_location
|
2076
2078
|
cell_line_metrics = body_cell_line_metrics
|
2077
2079
|
case cell.style
|
2078
2080
|
when :emphasis
|
@@ -2102,10 +2104,15 @@ module Asciidoctor
|
|
2102
2104
|
when :monospaced
|
2103
2105
|
cell_data.delete :font_style
|
2104
2106
|
cell_line_height = @base_line_height
|
2107
|
+
current_font_size = @font_size
|
2105
2108
|
theme_font :codespan do
|
2106
2109
|
mono_cell_font_info = font_info
|
2107
2110
|
cell_data[:font] = mono_cell_font_info[:family]
|
2108
|
-
|
2111
|
+
if ::String === @font_size || @font_size < 1
|
2112
|
+
@font_size = current_font_size
|
2113
|
+
font_size mono_cell_font_info[:size]
|
2114
|
+
end
|
2115
|
+
cell_data[:size] = @font_size
|
2109
2116
|
cell_data[:text_color] = @font_color
|
2110
2117
|
cell_line_metrics = calc_line_metrics cell_line_height
|
2111
2118
|
end
|
@@ -2132,8 +2139,8 @@ module Asciidoctor
|
|
2132
2139
|
end
|
2133
2140
|
# NOTE: line metrics get applied when AsciiDoc content is converted
|
2134
2141
|
cell_line_metrics = nil
|
2135
|
-
asciidoc_cell = ::Prawn::Table::Cell::AsciiDoc.new self, (cell_data.merge content: cell.inner_document, padding: body_cell_padding)
|
2136
|
-
cell_data = { content: asciidoc_cell }
|
2142
|
+
asciidoc_cell = ::Prawn::Table::Cell::AsciiDoc.new self, (cell_data.merge content: cell.inner_document, padding: body_cell_padding, root_font_size: @root_font_size)
|
2143
|
+
cell_data = { content: asciidoc_cell, source_location: cell.source_location }
|
2137
2144
|
end
|
2138
2145
|
if cell_line_metrics
|
2139
2146
|
cell_padding = body_cell_padding.dup
|
@@ -2336,6 +2343,8 @@ module Asciidoctor
|
|
2336
2343
|
theme_margin :block, :bottom, (next_enclosed_block node)
|
2337
2344
|
rescue ::Prawn::Errors::CannotFit
|
2338
2345
|
log :error, (message_with_context 'cannot fit contents of table cell into specified column width', source_location: node.source_location)
|
2346
|
+
ensure
|
2347
|
+
@font_scale = prev_font_scale if prev_font_scale
|
2339
2348
|
end
|
2340
2349
|
|
2341
2350
|
def convert_thematic_break node
|
@@ -2685,13 +2694,7 @@ module Asciidoctor
|
|
2685
2694
|
end
|
2686
2695
|
|
2687
2696
|
if (roles = node.role)
|
2688
|
-
|
2689
|
-
roles.split.each do |role|
|
2690
|
-
if (text_transform = theme[%(role_#{role}_text_transform)])
|
2691
|
-
inner_text = transform_text inner_text, text_transform
|
2692
|
-
end
|
2693
|
-
inner_text = inner_text.gsub DoubleSpaceRx, ' ' + ZeroWidthSpace if role == 'pre-wrap' && (inner_text.include? DoubleSpace)
|
2694
|
-
end
|
2697
|
+
inner_text = inner_text.gsub DoubleSpaceRx, ' ' + ZeroWidthSpace if (node.has_role? 'pre-wrap') && (inner_text.include? DoubleSpace)
|
2695
2698
|
quoted_text = is_tag ? %(#{open.chop} class="#{roles}">#{inner_text}#{close}) : %(<span class="#{roles}">#{open}#{inner_text}#{close}</span>)
|
2696
2699
|
else
|
2697
2700
|
quoted_text = %(#{open}#{inner_text}#{close})
|
@@ -3106,7 +3109,8 @@ module Asciidoctor
|
|
3106
3109
|
end
|
3107
3110
|
unless scratch? || !(bg_color = @theme[%(#{category_caption}_background_color)] || @theme.caption_background_color)
|
3108
3111
|
caption_height = height_of_typeset_text string
|
3109
|
-
fill_at = [bounds.left, cursor
|
3112
|
+
fill_at = [bounds.left, cursor]
|
3113
|
+
fill_at[1] -= (margin[:top] || 0) unless at_page_top?
|
3110
3114
|
float { bounding_box(fill_at, width: container_width, height: caption_height) { fill_bounds bg_color } }
|
3111
3115
|
end
|
3112
3116
|
indent(*indent_by) do
|
@@ -3241,7 +3245,8 @@ module Asciidoctor
|
|
3241
3245
|
end
|
3242
3246
|
end
|
3243
3247
|
|
3244
|
-
# NOTE: inline_format is true by default
|
3248
|
+
# NOTE: inline_format option is true by default
|
3249
|
+
# NOTE: single_line option is not compatible with this method
|
3245
3250
|
def ink_prose string, opts = {}
|
3246
3251
|
top_margin = (margin = (opts.delete :margin)) || (opts.delete :margin_top) || 0
|
3247
3252
|
bot_margin = margin || (opts.delete :margin_bottom) || @theme.prose_margin_bottom
|
@@ -4255,10 +4260,10 @@ module Asciidoctor
|
|
4255
4260
|
# NOTE: this will catch a classloader resource path on JRuby (e.g., uri:classloader:/path/to/image)
|
4256
4261
|
elsif ::File.absolute_path? image_path
|
4257
4262
|
::File.absolute_path image_path
|
4258
|
-
elsif !(
|
4263
|
+
elsif !(is_url = url? image_path) && imagesdir && (::File.absolute_path? imagesdir)
|
4259
4264
|
::File.absolute_path image_path, imagesdir
|
4260
4265
|
# handle case when image is a URI
|
4261
|
-
elsif
|
4266
|
+
elsif is_url || (imagesdir && (url? imagesdir) && (image_path = node.normalize_web_path image_path, imagesdir, false))
|
4262
4267
|
if !allow_uri_read
|
4263
4268
|
log :warn, %(cannot embed remote image: #{image_path} (allow-uri-read attribute not enabled))
|
4264
4269
|
return
|
@@ -4496,6 +4501,7 @@ module Asciidoctor
|
|
4496
4501
|
end
|
4497
4502
|
|
4498
4503
|
# TODO: document me, esp the first line formatting functionality
|
4504
|
+
# NOTE: single_line option should only be used if height option is specified
|
4499
4505
|
def typeset_text string, line_metrics, opts = {}
|
4500
4506
|
opts = { leading: line_metrics.leading, final_gap: line_metrics.final_gap }.merge opts
|
4501
4507
|
string = string.gsub CjkLineBreakRx, ZeroWidthSpace if @cjk_line_breaks
|
@@ -4950,7 +4956,7 @@ module Asciidoctor
|
|
4950
4956
|
alt_text_vars[:'/link'] = ''
|
4951
4957
|
end
|
4952
4958
|
theme_font :image_alt do
|
4953
|
-
ink_prose alt_text_template % alt_text_vars, align: opts[:align], margin: 0, normalize: false
|
4959
|
+
ink_prose alt_text_template % alt_text_vars, align: opts[:align], margin: 0, normalize: false
|
4954
4960
|
end
|
4955
4961
|
ink_caption node, category: :image, end: :bottom if node.title?
|
4956
4962
|
theme_margin :block, :bottom, (next_enclosed_block node) unless opts[:pinned]
|
@@ -5045,6 +5051,10 @@ module Asciidoctor
|
|
5045
5051
|
false
|
5046
5052
|
end
|
5047
5053
|
|
5054
|
+
def url? str
|
5055
|
+
(str.include? ':/') && (UrlSniffRx.match? str)
|
5056
|
+
end
|
5057
|
+
|
5048
5058
|
# Calculate the width that is needed to print all the
|
5049
5059
|
# fragments without wrapping any lines.
|
5050
5060
|
#
|
@@ -528,29 +528,6 @@ module Asciidoctor
|
|
528
528
|
end
|
529
529
|
end
|
530
530
|
|
531
|
-
# Apply the text transform to the specified text.
|
532
|
-
#
|
533
|
-
# Supported transform values are "uppercase", "lowercase", or "none" (passed
|
534
|
-
# as either a String or a Symbol). When the uppercase transform is applied to
|
535
|
-
# the text, it correctly uppercases visible text while leaving markup and
|
536
|
-
# named character entities unchanged. The none transform returns the text
|
537
|
-
# unmodified.
|
538
|
-
#
|
539
|
-
def transform_text text, transform
|
540
|
-
case transform
|
541
|
-
when :uppercase, 'uppercase'
|
542
|
-
uppercase_pcdata text
|
543
|
-
when :lowercase, 'lowercase'
|
544
|
-
lowercase_pcdata text
|
545
|
-
when :capitalize, 'capitalize'
|
546
|
-
capitalize_words_pcdata text
|
547
|
-
when :smallcaps, 'smallcaps'
|
548
|
-
smallcaps_pcdata text
|
549
|
-
else
|
550
|
-
text
|
551
|
-
end
|
552
|
-
end
|
553
|
-
|
554
531
|
def hyphenate_text text, hyphenator
|
555
532
|
hyphenate_words_pcdata text, hyphenator
|
556
533
|
end
|
@@ -7,6 +7,7 @@ module Prawn
|
|
7
7
|
include ::Asciidoctor::Logging
|
8
8
|
|
9
9
|
attr_accessor :align
|
10
|
+
attr_accessor :root_font_size
|
10
11
|
attr_accessor :valign
|
11
12
|
|
12
13
|
def initialize pdf, opts = {}
|
@@ -91,7 +92,9 @@ module Prawn
|
|
91
92
|
# TODO: apply horizontal alignment; currently it is necessary to specify alignment on content blocks
|
92
93
|
apply_font_properties { pdf.traverse content }
|
93
94
|
if (extra_pages = pdf.page_number - start_page) > 0
|
94
|
-
|
95
|
+
unless extra_pages == 1 && pdf.page.empty?
|
96
|
+
logger.error message_with_context %(the table cell on page #{start_page} has been truncated; Asciidoctor PDF does not support table cell content that exceeds the height of a single page), source_location: @source_location
|
97
|
+
end
|
95
98
|
extra_pages.times { pdf.delete_current_page }
|
96
99
|
end
|
97
100
|
nil
|
@@ -107,7 +110,7 @@ module Prawn
|
|
107
110
|
prev_font_color, pdf.font_color = pdf.font_color, font_color if font_color
|
108
111
|
font_family ||= font_info[:family]
|
109
112
|
if font_size
|
110
|
-
prev_font_scale, pdf.font_scale = pdf.font_scale, (font_size.to_f / @
|
113
|
+
prev_font_scale, pdf.font_scale = pdf.font_scale, (font_size.to_f / @root_font_size)
|
111
114
|
else
|
112
115
|
font_size = font_info[:size]
|
113
116
|
end
|
@@ -16,7 +16,9 @@ class Prawn::Table::Cell::Text
|
|
16
16
|
height: spanned_content_height + FPTolerance,
|
17
17
|
at: [0, @pdf.cursor]).render
|
18
18
|
end
|
19
|
-
|
19
|
+
unless remaining_text.empty? || @pdf.scratch?
|
20
|
+
logger.error message_with_context %(the table cell on page #{@pdf.page_number} has been truncated; Asciidoctor PDF does not support table cell content that exceeds the height of a single page), source_location: @source_location
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -4,6 +4,8 @@ module Asciidoctor
|
|
4
4
|
module PDF
|
5
5
|
module FormattedText
|
6
6
|
class Transform
|
7
|
+
include TextTransformer
|
8
|
+
|
7
9
|
LF = ?\n
|
8
10
|
ZeroWidthSpace = ?\u200b
|
9
11
|
CharEntityTable = { amp: '&', apos: ?', gt: '>', lt: '<', nbsp: ?\u00a0, quot: '"' }
|
@@ -21,8 +23,8 @@ module Asciidoctor
|
|
21
23
|
'font_size' => :size,
|
22
24
|
'text_decoration_color' => :text_decoration_color,
|
23
25
|
'text_decoration_width' => :text_decoration_width,
|
26
|
+
'text_transform' => :text_transform,
|
24
27
|
}
|
25
|
-
#DummyText = ?\u0000
|
26
28
|
|
27
29
|
def initialize options = {}
|
28
30
|
@merge_adjacent_text_nodes = options[:merge_adjacent_text_nodes]
|
@@ -172,6 +174,11 @@ module Asciidoctor
|
|
172
174
|
previous_fragment_is_text && ((previous_fragment_text = fragments[-1][:text]).end_with? ' ')
|
173
175
|
fragments[-1][:text] = previous_fragment_text.chop
|
174
176
|
end
|
177
|
+
if (text_transform = fragment.delete :text_transform)
|
178
|
+
text = (text_chunks = extract_text pcdata).join
|
179
|
+
text_io = StringIO.new transform_text text, text_transform
|
180
|
+
restore_text pcdata, text_chunks.each_with_object([]) {|chunk, accum| accum << (text_io.read chunk.length) }
|
181
|
+
end
|
175
182
|
# NOTE: decorate child fragments with inherited properties from this element
|
176
183
|
apply pcdata, fragments, fragment
|
177
184
|
previous_fragment_is_text = false
|
@@ -251,6 +258,8 @@ module Asciidoctor
|
|
251
258
|
fragments
|
252
259
|
end
|
253
260
|
|
261
|
+
private
|
262
|
+
|
254
263
|
def build_fragment fragment, tag_name, attrs
|
255
264
|
styles = (fragment[:styles] ||= ::Set.new)
|
256
265
|
case tag_name
|
@@ -324,7 +333,6 @@ module Asciidoctor
|
|
324
333
|
# NOTE: spaces in style value are superfluous for our purpose; split drops record after trailing ;
|
325
334
|
attrs[:style].tr(' ', '').split(';').each do |style|
|
326
335
|
pname, pvalue = style.split ':', 2
|
327
|
-
# TODO: text-transform
|
328
336
|
case pname
|
329
337
|
when 'color' # color needed to support syntax highlighters
|
330
338
|
fragment[:color] = pvalue.length == 7 ? (pvalue.slice 1, 6) : (pvalue.slice 1, 3).each_char.map {|c| c * 2 }.join if (pvalue.start_with? '#') && (HexColorRx.match? pvalue)
|
@@ -409,6 +417,29 @@ module Asciidoctor
|
|
409
417
|
end
|
410
418
|
end
|
411
419
|
end
|
420
|
+
|
421
|
+
def extract_text pcdata
|
422
|
+
pcdata.reduce [] do |accum, it|
|
423
|
+
case it[:type]
|
424
|
+
when :text
|
425
|
+
accum << it[:value]
|
426
|
+
when :element
|
427
|
+
accum += (extract_text it[:pcdata]) if it.key? :pcdata
|
428
|
+
end
|
429
|
+
accum
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
def restore_text pcdata, text_chunks
|
434
|
+
pcdata.each do |it|
|
435
|
+
case it[:type]
|
436
|
+
when :text
|
437
|
+
it[:value] = text_chunks.shift
|
438
|
+
when :element
|
439
|
+
restore_text it[:pcdata], text_chunks if it.key? :pcdata
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|
412
443
|
end
|
413
444
|
end
|
414
445
|
end
|
@@ -64,6 +64,29 @@ module Asciidoctor
|
|
64
64
|
string.tr LowerAlphaChars, SmallCapsChars
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
# Apply the text transform to the specified text.
|
69
|
+
#
|
70
|
+
# Supported transform values are "uppercase", "lowercase", or "none" (passed
|
71
|
+
# as either a String or a Symbol). When the uppercase transform is applied to
|
72
|
+
# the text, it correctly uppercases visible text while leaving markup and
|
73
|
+
# named character entities unchanged. The none transform returns the text
|
74
|
+
# unmodified.
|
75
|
+
#
|
76
|
+
def transform_text text, transform
|
77
|
+
case transform
|
78
|
+
when :uppercase, 'uppercase'
|
79
|
+
uppercase_pcdata text
|
80
|
+
when :lowercase, 'lowercase'
|
81
|
+
lowercase_pcdata text
|
82
|
+
when :capitalize, 'capitalize'
|
83
|
+
capitalize_words_pcdata text
|
84
|
+
when :smallcaps, 'smallcaps'
|
85
|
+
smallcaps_pcdata text
|
86
|
+
else
|
87
|
+
text
|
88
|
+
end
|
89
|
+
end
|
67
90
|
end
|
68
91
|
end
|
69
92
|
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: 2.1.
|
4
|
+
version: 2.1.6
|
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: 2022-
|
12
|
+
date: 2022-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: asciidoctor
|