Sha256: 81870e53f2a298ddfd0342952b2ac776e19f2f615ab9d2411768e52da469a590

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require "asciidoctor"

module Asciidoctor
  class Section < AbstractBlock
    def xreftext xrefstyle = nil
      if (val = reftext) && !val.empty?
        val
      elsif xrefstyle
        if @numbered
          case xrefstyle
          when 'custom'
            fmt = @document.attributes["xrefcustomformat"]
            fmt.gsub( "[$SECT_NUMS$]", sectnum.gsub( /[\.\,]$/, "" ) ).gsub( "[$TITLE$]", title )
          when 'full'
            if (type = @sectname) == 'chapter' || type == 'appendix'
              quoted_title = sub_placeholder (sub_quotes '_%s_'), title
            else
              quoted_title = sub_placeholder (sub_quotes @document.compat_mode ? %q(``%s'') : '"`%s`"'), title
            end
            if (signifier = @document.attributes[%(#{type}-refsig)])
              %(#{signifier} #{sectnum '.', ','} #{quoted_title})
            else
              %(#{sectnum '.', ','} #{quoted_title})
            end
          when 'short'
            if (signifier = @document.attributes[%(#{@sectname}-refsig)])
              %(#{signifier} #{sectnum '.', ''})
            else
              sectnum '.', ''
            end
          else # 'basic'
            (type = @sectname) == 'chapter' || type == 'appendix' ? (sub_placeholder (sub_quotes '_%s_'), title) : title
          end
        else # apply basic styling
          (type = @sectname) == 'chapter' || type == 'appendix' ? (sub_placeholder (sub_quotes '_%s_'), title) : title
        end
      else
        title
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
asciidoctor-nabetani-0.1.4 lib/asciidoctor/nabetani/abstractblock-xreftext.rb
asciidoctor-nabetani-0.1.3 lib/asciidoctor/nabetani/abstractblock-xreftext.rb
asciidoctor-nabetani-0.1.2 lib/asciidoctor/nabetani/abstractblock-xreftext.rb
asciidoctor-nabetani-0.1.1 lib/asciidoctor/nabetani/abstractblock-xreftext.rb
asciidoctor-nabetani-0.1.0 lib/asciidoctor/nabetani/abstractblock-xreftext.rb