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.



335
336
337
# File 'lib/ruby_rich/markdown.rb', line 335

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

Class Method Details

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



322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/ruby_rich/markdown.rb', line 322

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



339
340
341
# File 'lib/ruby_rich/markdown.rb', line 339

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