Class: TTY::Markdown::Parser

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(root, **options) ⇒ Parser

Returns a new instance of Parser.



15
16
17
18
19
20
21
22
23
24
# File 'lib/tty/markdown/parser.rb', line 15

def initialize(root, **options)
  super
  @stack = []
  @current_indent = 0
  @indent = options.fetch(:indent, 2)
  @pastel = Pastel.new
  @color_opts = {mode: options[:colors]}
  @width = options.fetch(:width) { TTY::Screen.width }
  @theme = options.fetch(:theme) { TTY::Markdown::THEME }
end

Instance Method Details

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

Invoke an element conversion



29
30
31
# File 'lib/tty/markdown/parser.rb', line 29

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