Class: Format::Markdown

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

Constant Summary collapse

FORMAT_PREFIXES =

Maintains a map to conserve the translation values of DIML lexicon to markdown prefixes.

{
  Point => "*",
  Heading => "##",
  Section => "#",
  Content => "",
  Root => ""
}.freeze

Instance Method Summary collapse

Instance Method Details

#render(elem) ⇒ Object

Returns the element with appropriate

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
# File 'lib/diml/format/markdown.rb', line 22

def render(elem)
  prefix = FORMAT_PREFIXES[elem.class]

  raise ArgumentError, "Invalid element: #{elem.class}" if prefix.nil?

  "#{prefix} #{elem.content}"
end