Class: RubyRich::Markdown

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_rich/markdown.rb

Defined Under Namespace

Classes: TerminalRenderer

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Markdown

Returns a new instance of Markdown.



205
206
207
# File 'lib/ruby_rich/markdown.rb', line 205

def initialize(options = {})
  @options = options
end

Class Method Details

.render(markdown_text, options = {}) ⇒ Object



192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/ruby_rich/markdown.rb', line 192

def self.render(markdown_text, options = {})
  renderer = TerminalRenderer.new(options)
  markdown_processor = Redcarpet::Markdown.new(renderer, {
    fenced_code_blocks: true,
    tables: true,
    autolink: true,
    strikethrough: true,
    space_after_headers: true
  })

  markdown_processor.render(markdown_text)
end

Instance Method Details

#render(markdown_text) ⇒ Object



209
210
211
# File 'lib/ruby_rich/markdown.rb', line 209

def render(markdown_text)
  self.class.render(markdown_text, @options)
end