class BetterErrors::CodeFormatter::HTML

@private

Public Instance Methods

formatted_code() click to toggle source
# File lib/better_errors/code_formatter/html.rb, line 24
def formatted_code
  %{
    <div class="code_linenums">#{formatted_nums.join}</div>
    <div class="code"><div class='code-wrapper'>#{super}</div></div>
  }
end
formatted_lines() click to toggle source
# File lib/better_errors/code_formatter/html.rb, line 10
def formatted_lines
  each_line_of(highlighted_lines) { |highlight, current_line, str|
    class_name = highlight ? "highlight" : ""
    sprintf '<pre class="%s">%s</pre>', class_name, str
  }
end
formatted_nums() click to toggle source
# File lib/better_errors/code_formatter/html.rb, line 17
def formatted_nums
  each_line_of(highlighted_lines) { |highlight, current_line, str|
    class_name = highlight ? "highlight" : ""
    sprintf '<span class="%s">%5d</span>', class_name, current_line
  }
end
highlighted_lines() click to toggle source
# File lib/better_errors/code_formatter/html.rb, line 35
def highlighted_lines
  Rouge::Formatters::HTML.new.format(rouge_lexer.lex(context_lines.join)).lines
end
rouge_lexer() click to toggle source
# File lib/better_errors/code_formatter/html.rb, line 31
def rouge_lexer
  Rouge::Lexer.guess(filename: filename, source: source) { Rouge::Lexers::Ruby }
end
source_unavailable() click to toggle source
# File lib/better_errors/code_formatter/html.rb, line 6
def source_unavailable
  "<p class='unavailable'>Source is not available</p>"
end