class Pry::SyntaxHighlighter
@api private @since v0.13.0
Public Class Methods
Source
# File lib/pry/syntax_highlighter.rb, line 9 def self.highlight(code, language = :ruby) tokenize(code, language).term end
Source
# File lib/pry/syntax_highlighter.rb, line 17 def self.keyword_token_color CodeRay::Encoders::Terminal::TOKEN_COLORS[:keyword] end
Source
# 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
Sets comment token to blue (black by default), so it’s more legible.
Source
# File lib/pry/syntax_highlighter.rb, line 13 def self.tokenize(code, language = :ruby) CodeRay::Scanners[language].new(code).tokens end