Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/pandoku/lookup_table.rb

Instance Method Summary collapse

Instance Method Details

#pandoku(from, to = nil, options = {}) ⇒ Object

Translate the markup.

string.pandoku(:markdown => :html)
string.pandoku(:markdown, :html)
string.pandoku(:markdown, :html, :smart => true)

Raises:

  • (ArgumentError)


37
38
39
40
41
42
43
44
45
46
# File 'lib/pandoku/lookup_table.rb', line 37

def pandoku(from, to = nil, options = {})
  if to.nil? && from.is_a?(Hash) && from.size == 1
    to = from.values.first
    from = from.keys.first
  end
  raise ArgumentError, 'expected two arguments' if to.nil?
  decoder = Formats.lookup(from).new(options)
  encoder = Formats.lookup(to).new
  decoder.parse(self).compile(encoder)
end