Module: Marquery::Helpers

Extended by:
Helpers
Included in:
Helpers
Defined in:
lib/marquery/helpers.rb

Instance Method Summary collapse

Instance Method Details

#markdown(content, renderer: Marquery::Renderer) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/marquery/helpers.rb', line 10

def markdown(content, renderer: Marquery::Renderer)
  case content
  when nil
    ""
  when Marquery::Renderable
    content.to_html
  when String
    renderer.new.markdown_to_html(content)
  else
    raise(
      ArgumentError,
      "markdown expects a String, nil, or Marquery::Renderable, got #{content.class}"
    )
  end
end