def flush!
return false if @buffer.empty?
case
when preserve_whitespace?
strip_code_block! if mode_is_code? current_mode
case
when (current_mode == :src and @options[:skip_syntax_highlight])
@buffer = escapeHTML @buffer
when (current_mode == :src and defined? Pygments)
lang = normalize_lang @block_lang
@output << "\n" unless @new_paragraph == :start
@new_paragraph = true
begin
@buffer = Pygments.highlight(@buffer, :lexer => lang)
rescue
@buffer = Pygments.highlight(@buffer, :lexer => 'text')
end
when (current_mode == :src and defined? CodeRay)
lang = normalize_lang @block_lang
silence_warnings do
begin
@buffer = CodeRay.scan(@buffer, lang).html(:wrap => nil, :css => :style)
rescue ArgumentError
@buffer = CodeRay.scan(@buffer, 'text').html(:wrap => nil, :css => :style)
end
end
when (current_mode == :html or current_mode == :raw_text)
@buffer.gsub!(/\A\n/, "") if @new_paragraph == :start
@new_paragraph = true
else
@buffer = escapeHTML @buffer
end
@logger.debug "FLUSH CODE ==========> #{@buffer.inspect}"
@output << @buffer
when (mode_is_table? current_mode and skip_tables?)
@logger.debug "SKIP ==========> #{current_mode}"
else
@buffer.lstrip!
@new_paragraph = nil
@logger.debug "FLUSH ==========> #{current_mode}"
case current_mode
when :definition_term
d = @buffer.split(/\A(.*[ \t]+|)::(|[ \t]+.*?)$/, 4)
d[1] = d[1].strip
unless d[1].empty?
@output << inline_formatting(d[1])
else
@output << "???"
end
indent = @list_indent_stack.last
pop_mode
@new_paragraph = :start
push_mode(:definition_descr, indent)
@output << inline_formatting(d[2].strip + d[3])
@new_paragraph = nil
when :horizontal_rule
add_paragraph unless @new_paragraph == :start
@new_paragraph = true
@output << "<hr />"
else
@output << inline_formatting(@buffer)
end
end
@buffer = ""
end