Module: Hologram::Utils

Defined in:
lib/hologram/utils.rb

Class Method Summary collapse

Class Method Details

.get_markdown_renderer(custom_markdown = nil) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/hologram/utils.rb', line 3

def self.get_markdown_renderer(custom_markdown = nil)
  return MarkdownRenderer if custom_markdown.nil?

  load custom_markdown
  renderer_class = File.basename(custom_markdown, '.rb').split(/_/).map(&:capitalize).join
  DisplayMessage.info("Custom markdown renderer #{renderer_class} loaded.")
  Module.const_get(renderer_class)
rescue LoadError => e
  DisplayMessage.error("Could not load #{custom_markdown}.")
rescue NameError => e
  DisplayMessage.error("Class #{renderer_class} not found in #{custom_markdown}.")
end