Class: TTY::Markdown::Formatter Private
- Inherits:
-
Object
- Object
- TTY::Markdown::Formatter
- Defined in:
- lib/tty/markdown/formatter.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Responsible for formatting code snippets with standard terminal colors
Instance Method Summary collapse
-
#format(tokens) ⇒ String
Format the Rouge lexer tokens.
-
#initialize(decorator) ⇒ Formatter
constructor
Create a Formatter instance.
Constructor Details
#initialize(decorator) ⇒ Formatter
Create a TTY::Markdown::Formatter instance
18 19 20 |
# File 'lib/tty/markdown/formatter.rb', line 18 def initialize(decorator) @decorator = decorator end |
Instance Method Details
#format(tokens) ⇒ String
Format the Rouge lexer tokens
33 34 35 36 |
# File 'lib/tty/markdown/formatter.rb', line 33 def format(tokens) code = tokens.map { |_token, value| value }.join @decorator.decorate_each_line(code, :code) end |