Class: Patricia::Converter
- Inherits:
-
Object
- Object
- Patricia::Converter
- 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
- .converters ⇒ Object
- .gfm_to_html(path) ⇒ Object
-
.kramdown(markup) ⇒ Object
Markdown.
-
.org_ruby(markup) ⇒ Object
Org.
-
.pandoc_rst(markup) ⇒ Object
reStructuredText.
-
.redcloth(markup) ⇒ Object
Textile.
- .to_html(path) ⇒ Object
Class Method Details
.converters ⇒ Object
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 |