Class: GitHub::Markup::Markdown
- Inherits:
-
Implementation
- Object
- Implementation
- GitHub::Markup::Markdown
- Defined in:
- lib/github/markup/markdown.rb
Constant Summary collapse
- MARKDOWN_GEMS =
{ "github/markdown" => proc { |content| GitHub::Markdown.render(content) }, "redcarpet" => proc { |content| Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(content) }, "rdiscount" => proc { |content| RDiscount.new(content).to_html }, "maruku" => proc { |content| Maruku.new(content).to_html }, "kramdown" => proc { |content| Kramdown::Document.new(content).to_html }, "bluecloth" => proc { |content| BlueCloth.new(content).to_html }, }
Instance Attribute Summary
Attributes inherited from Implementation
Instance Method Summary collapse
-
#initialize ⇒ Markdown
constructor
A new instance of Markdown.
- #load ⇒ Object
- #name ⇒ Object
- #render(content) ⇒ Object
Methods inherited from Implementation
Constructor Details
#initialize ⇒ Markdown
Returns a new instance of Markdown.
27 28 29 |
# File 'lib/github/markup/markdown.rb', line 27 def initialize super(/md|rmd|mkdn?|mdwn|mdown|markdown|litcoffee/i) end |
Instance Method Details
#load ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/github/markup/markdown.rb', line 31 def load return if @renderer MARKDOWN_GEMS.each do |gem_name, renderer| if try_require(gem_name) @renderer = renderer return end end raise LoadError, "no suitable markdown gem found" end |
#name ⇒ Object
47 48 49 |
# File 'lib/github/markup/markdown.rb', line 47 def name "markdown" end |
#render(content) ⇒ Object
42 43 44 45 |
# File 'lib/github/markup/markdown.rb', line 42 def render(content) load @renderer.call(content) end |