Class: TTY::Markdown::Converter

Inherits:
Kramdown::Converter::Base
  • Object
show all
Defined in:
lib/tty/markdown/converter.rb

Overview

Converts a Kramdown::Document tree to a terminal friendly output

Constant Summary collapse

NEWLINE =
"\n"
SPACE =
" "

Instance Method Summary collapse

Constructor Details

#initialize(root, options = {}) ⇒ Converter

Returns a new instance of Converter.


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tty/markdown/converter.rb', line 18

def initialize(root, options = {})
  super
  @current_indent = 0
  @indent = options[:indent]
  @pastel = Pastel.new(enabled: options[:enabled])
  @color_opts = { mode: options[:mode],
                  color: @pastel.yellow.detach,
                  enabled: options[:enabled] }
  @width = options[:width]
  @theme = options[:theme].each_with_object({}) do |(key, val), acc|
             acc[key] = Array(val)
           end
  @symbols = options[:symbols]
  @footnote_no = 1
  @footnotes = {}
end

Instance Method Details

#convert(el, opts = { indent: 0 }) ⇒ Object

Invoke an element conversion


38
39
40
# File 'lib/tty/markdown/converter.rb', line 38

def convert(el, opts = { indent: 0 })
  send("convert_#{el.type}", el, opts)
end