class Pry::SyntaxHighlighter

@api private @since v0.13.0

Public Class Methods

highlight(code, language = :ruby) click to toggle source
# File lib/pry/syntax_highlighter.rb, line 9
def self.highlight(code, language = :ruby)
  tokenize(code, language).term
end
keyword_token_color() click to toggle source
# File lib/pry/syntax_highlighter.rb, line 17
def self.keyword_token_color
  CodeRay::Encoders::Terminal::TOKEN_COLORS[:keyword]
end
overwrite_coderay_comment_token!() click to toggle source

Sets comment token to blue (black by default), so it's more legible.

# File lib/pry/syntax_highlighter.rb, line 22
def self.overwrite_coderay_comment_token!
  CodeRay::Encoders::Terminal::TOKEN_COLORS[:comment][:self] = "\e[1;34m"
end
tokenize(code, language = :ruby) click to toggle source
# File lib/pry/syntax_highlighter.rb, line 13
def self.tokenize(code, language = :ruby)
  CodeRay.scan(code, language)
end