Sha256: e575b18d3ccdf96ca682c4c0b8c30f662fa452381e0fc5cac7144310da5a8113

Contents?: true

Size: 472 Bytes

Versions: 3

Compression:

Stored size: 472 Bytes

Contents

# frozen_string_literal: true

module Asciidoctor
  class AbstractNode
    # See https://asciidoctor.org/docs/user-manual/#book-parts-and-chapters
    # @return [Boolean]
    def chapter?
      return is_a?(Asciidoctor::Document) if document.doctype != 'book'

      return true if context == :preamble && level.zero?

      chapter_level = [document.attr('epub-chapter-level', 1).to_i, 1].max
      is_a?(Asciidoctor::Section) && level <= chapter_level
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
asciidoctor-epub3-2.1.0 lib/asciidoctor-epub3/ext/asciidoctor/abstract_node.rb
asciidoctor-epub3-2.0.1 lib/asciidoctor-epub3/ext/asciidoctor/abstract_node.rb
asciidoctor-epub3-2.0.0 lib/asciidoctor-epub3/ext/asciidoctor/abstract_node.rb