Sha256: 456a89d3b9335fadc856016f6b321f6192d682928ba55acf8845cb485e30e0d3

Contents?: true

Size: 859 Bytes

Versions: 1

Compression:

Stored size: 859 Bytes

Contents

# frozen_string_literal: true

class Asciidoctor::Document
  # promote preface block (i.e., preamble block with title in book doctype) to preface section
  # FIXME: this should be handled by core
  def promote_preface_block
    if doctype == 'book' && (blk0 = blocks[0])&.context == :preamble && blk0.title? && !blk0.title.nil_or_empty? &&
        blk0.blocks[0]&.style != 'abstract' && (blk1 = blocks[1])&.context == :section
      preface = Asciidoctor::Section.new self, blk1.level, false, attributes: { 1 => 'preface', 'style' => 'preface' }
      preface.special = true
      preface.sectname = 'preface'
      preface.title = blk0.instance_variable_get :@title
      preface.id = preface.generate_id
      preface.blocks.replace (blk0.blocks.map do |b|
        b.parent = preface
        b
      end)
      blocks[0] = preface
    end
    nil
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
asciidoctor-pdf-2.0.0.alpha.1 lib/asciidoctor/pdf/ext/asciidoctor/document.rb