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.



213
214
215
# File 'lib/ruby_rich/markdown.rb', line 213

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

Class Method Details

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



200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/ruby_rich/markdown.rb', line 200

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



217
218
219
# File 'lib/ruby_rich/markdown.rb', line 217

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