Sha256: 0f6b9582de014027fbac85e19b861b92655688594b5f3b99951dfbd4516e5d24

Contents?: true

Size: 621 Bytes

Versions: 6790

Compression:

Stored size: 621 Bytes

Contents

# frozen_string_literal: true

require 'coderay'

class Pry
  # @api private
  # @since v0.13.0
  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

Version data entries

6,790 entries across 6,786 versions & 31 rubygems

Version Path
cybrid_api_id_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_bank_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_organization_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_id_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_id_ruby-0.123.110 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_bank_ruby-0.123.110 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_organization_ruby-0.123.110 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_bank_ruby-0.123.109 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_organization_ruby-0.123.109 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_id_ruby-0.123.109 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_bank_ruby-0.123.107 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_organization_ruby-0.123.107 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_id_ruby-0.123.107 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_bank_ruby-0.123.106 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_organization_ruby-0.123.106 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_id_ruby-0.123.106 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_organization_ruby-0.123.105 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_bank_ruby-0.123.105 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_id_ruby-0.123.105 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb
cybrid_api_bank_ruby-0.123.104 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/syntax_highlighter.rb