Module: Ronin::CLI::Printing::SyntaxHighlighting Private

Includes:
CommandKit::Colors
Included in:
Commands::Highlight, HTTP
Defined in:
lib/ronin/cli/printing/syntax_highlighting.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Mixin that adds syntax highlighting to commands.

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#initialize(**kwargs) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the syntax highlighter.

Since:

  • 2.0.0



37
38
39
40
41
42
43
# File 'lib/ronin/cli/printing/syntax_highlighting.rb', line 37

def initialize(**kwargs)
  super(**kwargs)

  if ansi?
    @syntax_formatter = syntax_formatter
  end
end

#syntax_formatterRouge::Formatters::Terminal256

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The syntax formatter.

Since:

  • 2.0.0



93
94
95
# File 'lib/ronin/cli/printing/syntax_highlighting.rb', line 93

def syntax_formatter
  Rouge::Formatters::Terminal256.new(syntax_theme)
end

#syntax_lexer(name) ⇒ Class<Rouge::Lexer>?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Looks up the syntax lexer class.

Since:

  • 2.0.0



75
76
77
# File 'lib/ronin/cli/printing/syntax_highlighting.rb', line 75

def syntax_lexer(name)
  Rouge::Lexer.find(name)
end

#syntax_lexer_for(filename: nil, mimetype: nil, source: nil) ⇒ Rouge::Lexer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads the syntax lexer for the filename, mimetype, or source code.

Since:

  • 2.0.0



59
60
61
62
63
64
65
# File 'lib/ronin/cli/printing/syntax_highlighting.rb', line 59

def syntax_lexer_for(filename: nil, mimetype: nil, source: nil)
  Rouge::Lexer.guess(
    filename: filename,
    mimetype: mimetype,
    source:   source
  )
end

#syntax_themeRouge::Theme

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The syntax highlighter theme.

Since:

  • 2.0.0



84
85
86
# File 'lib/ronin/cli/printing/syntax_highlighting.rb', line 84

def syntax_theme
  Rouge::Themes::Molokai.new
end