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.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ Object
private
Initializes the syntax highlighter.
-
#syntax_formatter ⇒ Rouge::Formatters::Terminal256
private
The syntax formatter.
-
#syntax_lexer(name) ⇒ Class<Rouge::Lexer>?
private
Looks up the syntax lexer class.
-
#syntax_lexer_for(filename: nil, mimetype: nil, source: nil) ⇒ Rouge::Lexer
private
Loads the syntax lexer for the filename, mimetype, or source code.
-
#syntax_theme ⇒ Rouge::Theme
private
The syntax highlighter theme.
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.
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_formatter ⇒ Rouge::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.
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.
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.
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_theme ⇒ Rouge::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.
84 85 86 |
# File 'lib/ronin/cli/printing/syntax_highlighting.rb', line 84 def syntax_theme Rouge::Themes::Molokai.new end |