summaryrefslogtreecommitdiff
path: root/docs/modules/extend/examples/pdf-converter-code-float-wrapping.rb
blob: ed1a7ebd1bcebb1e2ed23e7573382b311953425b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
class PDFConverterCodeFloatWrapping < (Asciidoctor::Converter.for 'pdf')
  register_for 'pdf'

  def supports_float_wrapping? node
    %i(paragraph listing literal).include? node.context
  end

  def convert_code node
    return super unless (float_box = @float_box ||= nil)
    indent(float_box[:left] - bounds.left, bounds.width - float_box[:right]) { super }
    @float_box = nil unless page_number == float_box[:page] && cursor > float_box[:bottom]
  end
end