Module: Docify::Markup

Extended by:
Markup
Included in:
Markup
Defined in:
lib/docify/markup.rb

Instance Method Summary collapse

Instance Method Details

#markdown(content) ⇒ Object

Render content for Markdown



41
42
43
# File 'lib/docify/markup.rb', line 41

def markdown(content)
  Markdown.new(content).to_html
end

#rdoc(content) ⇒ Object

Render content for RDoc



25
26
27
28
# File 'lib/docify/markup.rb', line 25

def rdoc(content)
  markup = RDoc::Markup::ToHtml.new
  markup.convert(content)
end

#render(filename, content) ⇒ Object

Auto-detect format from filename and render content

Raises:

  • (ArgumentError)


16
17
18
19
20
21
# File 'lib/docify/markup.rb', line 16

def render(filename, content)
  name = File.basename(filename.to_s.strip)
  raise ArgumentError, 'Filename required!' if name.empty?
  format = detect_format(name)
  format == :text ? content : self.send(format, content)
end

#textile(content) ⇒ Object

Render content for Textile



46
47
48
# File 'lib/docify/markup.rb', line 46

def textile(content)
  RedCloth.new(content).to_html
end