Class: TTY::Markdown::Converter Private

Inherits:
Kramdown::Converter::Base
  • Object
show all
Defined in:
lib/tty/markdown/converter.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 converting a Markdown document into terminal output

Instance Method Summary collapse

Constructor Details

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

Create a TTY::Markdown::Converter instance

Examples:

converter = TTY::Markdown::Converter.new(document)

Parameters:

  • root (Kramdown::Element)

    the root element

  • options (Hash) (defaults to: {})

    the root element options



115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/tty/markdown/converter.rb', line 115

def initialize(root, options = {})
  super
  pastel = Pastel.new(enabled: options[:enabled])
  @decorator = Decorator.new(pastel, options[:theme])
  @highlighter = Highlighter.new(@decorator, mode: options[:mode])
  @current_indent = 0
  @footnote_number = 1
  @footnotes = {}
  @indent = options[:indent]
  @symbols = options[:symbols]
  @width = options[:width]
end

Instance Method Details

#convert(element, options = {indent: 0}) ⇒ String

Convert an element

Examples:

converter.convert(root)

Parameters:

  • element (Kramdown::Element)

    the root element

  • options (Hash) (defaults to: {indent: 0})

    the root element options

Returns:

  • (String)


141
142
143
# File 'lib/tty/markdown/converter.rb', line 141

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