# File lib/brakeman/report/report_html.rb, line 114
  def with_context warning, message
    @element_id += 1
    context = context_for(@app_tree, warning)
    message = html_message(warning, message)

    code_id = "context#@element_id"
    message_id = "message#@element_id"
    full_message_id = "full_message#@element_id"
    alt = false
    output = "<div class='warning_message' onClick=\"toggle('#{code_id}');toggle('#{message_id}');toggle('#{full_message_id}')\" >" <<
    message <<
    "<table id='#{code_id}' class='context' style='display:none'>" <<
    "<caption>#{CGI.escapeHTML warning_file(warning) || ''}</caption>"

    output << "<thead style='display:none'>\n<tr>\n<th>line number</th>\n<th>line content</th>\n</tr>\n</thead>\n<tbody>\n"

    unless context.empty?
      if warning.line - 1 == 1 or warning.line + 1 == 1
        error = " near_error"
      elsif 1 == warning.line
        error = " error"
      else
        error = ""
      end

      output << "<tr class='context first\#{error}'>\n<td class='context_line'>\n<pre class='context'>\#{context.first[0]}</pre>\n</td>\n<td class='context'>\n<pre class='context'>\#{CGI.escapeHTML context.first[1].chomp}</pre>\n</td>\n</tr>\n"

      if context.length > 1
        output << context[1..-1].map do |code|
          alt = !alt
          if code[0] == warning.line - 1 or code[0] == warning.line + 1
            error = " near_error"
          elsif code[0] == warning.line
            error = " error"
          else
            error = ""
          end

          "<tr class='context\#{alt ? ' alt' : ''}\#{error}'>\n<td class='context_line'>\n<pre class='context'>\#{code[0]}</pre>\n</td>\n<td class='context'>\n<pre class='context'>\#{CGI.escapeHTML code[1].chomp}</pre>\n</td>\n</tr>\n"
        end.join
      end
    end

    output << "</tbody></table></div>"
  end