blob: f7f3375bbcc34ae9557cc09372fb168a20276b69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# frozen_string_literal: true
require 'coderay'
class Pry
# @api private
# @since ?.?.?
class SyntaxHighlighter
def self.highlight(code, language = :ruby)
tokenize(code, language).term
end
def self.tokenize(code, language = :ruby)
CodeRay.scan(code, language)
end
def self.keyword_token_color
CodeRay::Encoders::Terminal::TOKEN_COLORS[:keyword]
end
# Sets comment token to blue (black by default), so it's more legible.
def self.overwrite_coderay_comment_token!
CodeRay::Encoders::Terminal::TOKEN_COLORS[:comment][:self] = "\e[1;34m"
end
end
end
|