class Psychic::Runner::CodeHelper::Highlighter
Public Class Methods
new(opts)
click to toggle source
# File lib/psychic/runner/code_helper.rb, line 5 def initialize(opts) require 'rouge' @lexer = Rouge::Lexer.find(opts[:language]) || Rouge::Lexer.guess_by_filename(opts[:filename]) @formatter = opts[:formatter] rescue LoadError # rubocop:disable Lint/HandleExceptions # No highlighting support end
Public Instance Methods
highlight(source)
click to toggle source
# File lib/psychic/runner/code_helper.rb, line 13 def highlight(source) if defined?(Rouge) Rouge.highlight(source, @lexer, @formatter) else # No highlighting support source end end