lib/asciidoctor/abstract_block.rb
# Public: Generate cross reference text (xreftext) that can be used to refer
# to this block.
#
# Use the explicit reftext for this block, if specified, retrieved from the
# {#reftext} method. Otherwise, if this is a section or captioned block (a
# block with both a title and caption), generate the xreftext according to
# the value of the xrefstyle argument (e.g., full, short). This logic may
# leverage the {Substitutors#sub_quotes} method to apply formatting to the
# text. If this is not a captioned block, return the title, if present, or
# nil otherwise.
#
# xrefstyle - An optional String that specifies the style to use to format
#             the xreftext ('full', 'short', or 'basic') (default: nil).
#
# Returns the generated [String] xreftext used to refer to this block or
# nothing if there isn't sufficient information to generate one.
Generate cross reference text (xreftext) that can be used to refer
to this block.

Use the explicit reftext for this block, if specified, retrieved from the
{#reftext} method. Otherwise, if this is a section or captioned block (a
block with both a title and caption), generate the xreftext according to
the value of the xrefstyle argument . This logic may
leverage the {Substitutors#sub_quotes} method to apply formatting to the
text. If this is not a captioned block, return the title, if present, or
nil otherwise.



Returns the generated [String] xreftext used to refer to this block or
nothing if there isn't sufficient information to generate one.
Generate cross reference text ( xreftext ) that can be used to refer to this block . Use the explicit reftext for this block if specified retrieved from the { #reftext } method . Otherwise if this is a section or captioned block ( a block with both a title and caption ) generate the xreftext according to the value of the xrefstyle argument . This logic may leverage the { Substitutors#sub_quotes } method to apply formatting to the text . If this is not a captioned block return the title if present or nil otherwise . Returns the generated [ String ] xreftext used to refer to this block or nothing if there isn ' t sufficient information to generate one .
def xreftext xrefstyle = nil
    if (val = reftext) && !val.empty?
      val
    elsif xrefstyle && @title && @caption
      case xrefstyle
      when 'full'
        quoted_title = sprintf sub_quotes(@document.compat_mode ? %q(``%s'') : '"`%s`"'), title
        if @numeral && (prefix = @document.attributes[@context == :image ? 'figure-caption' : %(#{@context}-caption)])
          %(#{prefix} #{@numeral}, #{quoted_title})
        else
          %(#{@caption.chomp '. '}, #{quoted_title})
        end
      when 'short'
        if @numeral && (prefix = @document.attributes[@context == :image ? 'figure-caption' : %(#{@context}-caption)])
          %(#{prefix} #{@numeral})
        else
          @caption.chomp '. '
        end
      else 
        title
      end
    else
      title
    end
  end
def xreftext xrefstyle = nil if ( val = reftext ) && ! val . empty? val elsif xrefstyle && @title && @caption case xrefstyle when 'full' quoted_title = sprintf sub_quotes ( @document . compat_mode ? %q(``%s'') : '"`%s`"' ) , title if @numeral && ( prefix = @document . attributes [ @context == :image ? 'figure-caption' : %(#{@context}-caption) ] ) %(#{prefix} #{@numeral}, #{quoted_title}) else %(#{@caption.chomp '. '}, #{quoted_title}) end when 'short' if @numeral && ( prefix = @document . attributes [ @context == :image ? 'figure-caption' : %(#{@context}-caption) ] ) %(#{prefix} #{@numeral}) else @caption . chomp '. ' end else title end else title end end
Public: Generate cross reference text (xreftext) that can be used to refer
to this block.
Public : Generate cross reference text ( xreftext ) that can be used to refer to this block .
# NOTE xrefstyle only applies to blocks with a title and a caption or number # 'basic'
xrefstyle
<not_specific>