Class: Patricia::Converter

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

Constant Summary collapse

@@converters =
{
  # Markdown
  'md' => :kramdown,
  'markdown' => :kramdown,
  # Org
  'org' => :org_ruby,
  # Textile
  'textile' => :redcloth,
  # reStructuredText
  'rst' => :pandoc_rst,
  'rest' => :pandoc_rst,
  'restx' => :pandoc_rst,
}

Class Method Summary collapse

Class Method Details

.convertersObject



26
27
28
# File 'lib/patricia/patricia.rb', line 26

def self.converters
  @@converters
end

.gfm_to_html(path) ⇒ Object



59
60
61
# File 'lib/patricia/patricia.rb', line 59

def self.gfm_to_html(path)
  GitHub::Markup.render(path)
end

.kramdown(markup) ⇒ Object

Markdown



32
33
34
# File 'lib/patricia/patricia.rb', line 32

def self.kramdown(markup)
  Kramdown::Document.new(markup).to_html
end

.org_ruby(markup) ⇒ Object

Org



38
39
40
# File 'lib/patricia/patricia.rb', line 38

def self.org_ruby(markup)
  Orgmode::Parser.new(markup).to_html
end

.pandoc_rst(markup) ⇒ Object

reStructuredText



50
51
52
# File 'lib/patricia/patricia.rb', line 50

def self.pandoc_rst(markup)
  PandocRuby.new(markup, :from => :rst, :to => :html).convert
end

.redcloth(markup) ⇒ Object

Textile



44
45
46
# File 'lib/patricia/patricia.rb', line 44

def self.redcloth(markup)
  RedCloth.new(markup).to_html
end

.to_html(path) ⇒ Object



54
55
56
57
# File 'lib/patricia/patricia.rb', line 54

def self.to_html(path)
  markup = File.read(path)
  self.send @@converters[File.extname(path).sub(/^\./, '')], markup
end