Sha256: af1de9b39ad1463d35f5887fd336bee9a460ca57559bb5beeb99223c069026bf

Contents?: true

Size: 1.35 KB

Versions: 15

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

class Asciidoctor::Section
  def numbered_title opts = {}
    @cached_numbered_title ||= nil
    unless @cached_numbered_title
      if @numbered && !@caption && (slevel = @level) <= (@document.attr 'sectnumlevels', 3).to_i
        @is_numbered = true
        if @document.doctype == 'book'
          case slevel
          when 0
            @cached_numbered_title = %(#{sectnum nil, ':'} #{title})
            @cached_formal_numbered_title = %(#{@document.attr 'part-signifier', 'Part'} #{@cached_numbered_title}).lstrip
          when 1
            @cached_numbered_title = %(#{sectnum} #{title})
            @cached_formal_numbered_title = %(#{@document.attr 'chapter-signifier', 'Chapter'} #{@cached_numbered_title}).lstrip
          else
            @cached_formal_numbered_title = @cached_numbered_title = %(#{sectnum} #{title})
          end
        else
          @cached_formal_numbered_title = @cached_numbered_title = %(#{sectnum} #{title})
        end
      elsif @level == 0
        @is_numbered = false
        @cached_numbered_title = @cached_formal_numbered_title = title
      else
        @is_numbered = false
        @cached_numbered_title = @cached_formal_numbered_title = captioned_title
      end
    end
    opts[:formal] ? @cached_formal_numbered_title : @cached_numbered_title
  end unless method_defined? :numbered_title
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
asciidoctor-pdf-2.0.8 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.7 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.6 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.5 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.4 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.3 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.2 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.1 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.0 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.0.rc.1 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.0.beta.2 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.0.beta.1 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.0.alpha.3 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.0.alpha.2 lib/asciidoctor/pdf/ext/asciidoctor/section.rb
asciidoctor-pdf-2.0.0.alpha.1 lib/asciidoctor/pdf/ext/asciidoctor/section.rb