lib/asciidoctor/abstract_block.rb in asciidoctor-2.0.10 vs lib/asciidoctor/abstract_block.rb in asciidoctor-2.0.11
- old
+ new
@@ -139,10 +139,15 @@
# Deprecated: Legacy property to get the String or Integer numeral of this section.
def number
(Integer @numeral) rescue @numeral
end
+ # Deprecated: Legacy property to set the numeral of this section by coercing the value to a String.
+ def number= val
+ @numeral = val.to_s
+ end
+
# Public: Walk the document tree and find all block-level nodes that match the specified selector (context, style, id,
# role, and/or custom filter).
#
# If a Ruby block is given, it's applied as a supplemental filter. If the filter returns true (which implies :accept),
# the node is accepted and node traversal continues. If the filter returns false (which implies :skip), the node is
@@ -336,21 +341,21 @@
# nothing if there isn't sufficient information to generate one.
def xreftext xrefstyle = nil
if (val = reftext) && !val.empty?
val
# NOTE xrefstyle only applies to blocks with a title and a caption or number
- elsif xrefstyle && @title && @caption
+ elsif xrefstyle && @title && !@caption.nil_or_empty?
case xrefstyle
when 'full'
quoted_title = sub_placeholder (sub_quotes @document.compat_mode ? %q(``%s'') : '"`%s`"'), title
- if @numeral && (caption_attr_name = CAPTION_ATTR_NAMES[@context]) && (prefix = @document.attributes[caption_attr_name])
+ if @numeral && (caption_attr_name = CAPTION_ATTRIBUTE_NAMES[@context]) && (prefix = @document.attributes[caption_attr_name])
%(#{prefix} #{@numeral}, #{quoted_title})
else
%(#{@caption.chomp '. '}, #{quoted_title})
end
when 'short'
- if @numeral && (caption_attr_name = CAPTION_ATTR_NAMES[@context]) && (prefix = @document.attributes[caption_attr_name])
+ if @numeral && (caption_attr_name = CAPTION_ATTRIBUTE_NAMES[@context]) && (prefix = @document.attributes[caption_attr_name])
%(#{prefix} #{@numeral})
else
@caption.chomp '. '
end
else # 'basic'
@@ -378,10 +383,10 @@
# (default: @context)
#
# Returns nothing.
def assign_caption value, caption_context = @context
unless @caption || !@title || (@caption = value || @document.attributes['caption'])
- if (attr_name = CAPTION_ATTR_NAMES[caption_context]) && (prefix = @document.attributes[attr_name])
+ if (attr_name = CAPTION_ATTRIBUTE_NAMES[caption_context]) && (prefix = @document.attributes[attr_name])
@caption = %(#{prefix} #{@numeral = @document.increment_and_store_counter %(#{caption_context}-number), self}. )
nil
end
end
end