summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-05-06 02:47:38 -0600
committerDan Allen <dan.j.allen@gmail.com>2022-05-06 02:47:38 -0600
commitc2f12fd773c26463a1073b527c91897dba9c4e49 (patch)
tree292e67ba6251cf5d7af9a696c5a635320e321c57
parentfee0ecf1e6c8ced4acd5ad1e2808ada90c6a6472 (diff)
rename resolve_alignment_from_role to resolve_text_align_from_role to reflect proper terminology and purpose; alias old method name
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--lib/asciidoctor/pdf/converter.rb25
2 files changed, 15 insertions, 11 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 7c32e3f9..77264602 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -10,6 +10,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/main[co
Enhancements::
* add support for `text-transform` property on first line of abstract in theme (#2141)
+* rename `resolve_alignment_from_role` to `resolve_text_align_from_role` to reflect proper terminology and purpose; alias old method name
Bug Fixes::
diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb
index 5f90c0e9..17aa6f53 100644
--- a/lib/asciidoctor/pdf/converter.rb
+++ b/lib/asciidoctor/pdf/converter.rb
@@ -755,7 +755,7 @@ module Asciidoctor
def convert_floating_title node
add_dest_for_block node if node.id
hlevel = node.level.next
- unless (align = resolve_alignment_from_role node.roles)
+ unless (align = resolve_text_align_from_role node.roles)
align = (@theme[%(heading_h#{hlevel}_text_align)] || @theme.heading_text_align || @base_text_align).to_sym
end
# QUESTION: should we decouple styles from section titles?
@@ -801,7 +801,7 @@ module Asciidoctor
if child.context == :paragraph
child.document.playback_attributes child.attributes
prose_opts[:margin_bottom] = 0 if child == last_block
- ink_prose child.content, ((align = resolve_alignment_from_role child.roles) ? (prose_opts.merge align: align) : prose_opts.dup)
+ ink_prose child.content, ((align = resolve_text_align_from_role child.roles) ? (prose_opts.merge align: align) : prose_opts.dup)
prose_opts.delete :first_line_options
prose_opts.delete :margin_bottom
else
@@ -810,7 +810,7 @@ module Asciidoctor
end
end
elsif node.content_model != :compound && (string = node.content)
- if (align = resolve_alignment_from_role node.roles)
+ if (align = resolve_text_align_from_role node.roles)
prose_opts[:align] = align
end
ink_prose string, (prose_opts.merge margin_bottom: 0)
@@ -835,9 +835,8 @@ module Asciidoctor
def convert_paragraph node
add_dest_for_block node if node.id
prose_opts = { margin_bottom: 0, hyphenate: true }
- if (align = resolve_alignment_from_role (roles = node.roles), use_theme: true)
+ if (align = resolve_text_align_from_role (roles = node.roles), query_theme: true, remove_predefined: true)
prose_opts[:align] = align
- roles -= TextAlignmentRoles
end
if (text_indent = @theme.prose_text_indent) > 0 ||
@@ -1151,7 +1150,7 @@ module Asciidoctor
last_item = node.items[-1]
item_spacing = @theme.callout_list_item_spacing || @theme.list_item_spacing
item_opts = { margin_bottom: item_spacing, normalize_line_height: true }
- if (item_align = (resolve_alignment_from_role node.roles) || @theme.list_text_align&.to_sym)
+ if (item_align = (resolve_text_align_from_role node.roles) || @theme.list_text_align&.to_sym)
item_opts[:align] = item_align
end
theme_font :callout_list do
@@ -1370,7 +1369,7 @@ module Asciidoctor
ink_caption node, category: :list, labeled: false if node.title?
opts = {}
- if (align = resolve_alignment_from_role node.roles)
+ if (align = resolve_text_align_from_role node.roles)
opts[:align] = align
elsif node.style == 'bibliography'
opts[:align] = :left
@@ -1565,7 +1564,7 @@ module Asciidoctor
alignment = (alignment = node.attr 'align') ?
((BlockAlignmentNames.include? alignment) ? alignment.to_sym : :left) :
- (resolve_alignment_from_role node.roles) || @theme.image_align&.to_sym || :left
+ (resolve_text_align_from_role node.roles) || @theme.image_align&.to_sym || :left
# TODO: support cover (aka canvas) image layout using "canvas" (or "cover") role
width = resolve_explicit_width node.attributes, bounds_width: (available_w = bounds.width), support_vw: true, use_fallback: true, constrain_to_bounds: true
# TODO: add `to_pt page_width` method to ViewportWidth type
@@ -1697,7 +1696,7 @@ module Asciidoctor
theme_font :image_alt do
alignment = (alignment = node.attr 'align') ?
((BlockAlignmentNames.include? alignment) ? alignment.to_sym : :left) :
- (resolve_alignment_from_role node.roles) || (@theme.image_align&.to_sym || :left)
+ (resolve_text_align_from_role node.roles) || (@theme.image_align&.to_sym || :left)
ink_prose alt_text_template % alt_text_vars, align: alignment, margin: 0, normalize: false, single_line: true
end
ink_caption node, category: :image, end: :bottom if node.title?
@@ -4323,10 +4322,11 @@ module Asciidoctor
end
end
- def resolve_alignment_from_role roles, use_theme: false
+ def resolve_text_align_from_role roles, query_theme: false, remove_predefined: false
if (align_role = roles.reverse.find {|r| TextAlignmentRoles.include? r })
+ roles.replace roles - TextAlignmentRoles if remove_predefined
(align_role.slice 5, align_role.length).to_sym
- elsif use_theme
+ elsif query_theme
roles.reverse.each do |role|
if (align = @theme[%(role_#{role}_text_align)])
return align.to_sym
@@ -4336,6 +4336,9 @@ module Asciidoctor
end
end
+ # Deprecated
+ alias resolve_alignment_from_role resolve_text_align_from_role
+
# QUESTION: is this method still necessary?
def resolve_imagesdir doc
if (imagesdir = doc.attr 'imagesdir').nil_or_empty? || (imagesdir = imagesdir.chomp '/') == '.'