Class: GitHub::Markup::Markdown
- Inherits:
-
Implementation
- Object
- Implementation
- GitHub::Markup::Markdown
- Defined in:
- lib/github/markup/markdown.rb
Constant Summary collapse
- MARKDOWN_GEMS =
{ "commonmarker" => proc { |content| CommonMarker.render_html(content, :GITHUB_PRE_LANG, [:tagfilter, :autolink, :table, :strikethrough]) }, "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(filename, content) ⇒ Object
Methods inherited from Implementation
Constructor Details
#initialize ⇒ Markdown
Returns a new instance of Markdown.
30 31 32 33 34 |
# File 'lib/github/markup/markdown.rb', line 30 def initialize super( /md|rmd|mkdn?|mdwn|mdown|markdown|litcoffee/i, ["Markdown", "RMarkdown", "Literate CoffeeScript"]) end |
Instance Method Details
#load ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/github/markup/markdown.rb', line 36 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
52 53 54 |
# File 'lib/github/markup/markdown.rb', line 52 def name "markdown" end |
#render(filename, content) ⇒ Object
47 48 49 50 |
# File 'lib/github/markup/markdown.rb', line 47 def render(filename, content) load @renderer.call(content) end |