summaryrefslogtreecommitdiff
path: root/docs/modules/extend/examples/pdf-converter-chapter-image.rb
blob: 16c2ad4c13b8083dd14f0ad8b083f6d0b482ffe8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
class PDFConverterChapterImage < (Asciidoctor::Converter.for 'pdf')
  register_for 'pdf'

  def ink_chapter_title sect, title, opts
    if (image_path = sect.attr 'image')
      image_attrs = { 'target' => image_path, 'pdfwidth' => '1in' }
      image_block = ::Asciidoctor::Block.new sect.document, :image, content_model: :empty, attributes: image_attrs
      convert_image image_block, relative_to_imagesdir: true, pinned: true
    end
    super
  end
end