class Rouge::Formatters::BackgroundColorizer

Public Class Methods

new(opts = {}) click to toggle source
# File lib/asciidoctor/pdf/ext/rouge/formatters/prawn.rb, line 160
def initialize opts = {}
  @line_gap = opts[:line_gap] || 0
end

Public Instance Methods

render_behind(fragment) click to toggle source
# File lib/asciidoctor/pdf/ext/rouge/formatters/prawn.rb, line 164
def render_behind fragment
  pdf = fragment.document
  data = fragment.format_state
  prev_fill_color = pdf.fill_color
  pdf.fill_color data[:background_color]
  v_gap = data[:inline_block] ? @line_gap : 0
  fragment_width = data[:line_oriented] && data[:extend] ? (pdf.bounds.width - fragment.left) : fragment.width
  pdf.fill_rectangle [fragment.left, fragment.top + v_gap * 0.5], fragment_width, (fragment.height + v_gap)
  pdf.fill_color prev_fill_color
end