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, options: {}| commonmarker_opts = [:GITHUB_PRE_LANG].concat(.fetch(:commonmarker_opts, [])) CommonMarker.render_html(content, commonmarker_opts, [:tagfilter, :autolink, :table, :strikethrough]) }, "github/markdown" => proc { |content, options: {}| GitHub::Markdown.render(content) }, "redcarpet" => proc { |content, options: {}| Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(content) }, "rdiscount" => proc { |content, options: {}| RDiscount.new(content).to_html }, "maruku" => proc { |content, options: {}| Maruku.new(content).to_html }, "kramdown" => proc { |content, options: {}| Kramdown::Document.new(content).to_html }, "bluecloth" => proc { |content, options: {}| 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, options: {}) ⇒ Object
Methods inherited from Implementation
Constructor Details
#initialize ⇒ Markdown
Returns a new instance of Markdown.
31 32 33 34 35 |
# File 'lib/github/markup/markdown.rb', line 31 def initialize super( /md|mkdn?|mdwn|mdown|markdown|litcoffee/i, ["Markdown", "Literate CoffeeScript"]) end |
Instance Method Details
#load ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/github/markup/markdown.rb', line 37 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
53 54 55 |
# File 'lib/github/markup/markdown.rb', line 53 def name "markdown" end |
#render(filename, content, options: {}) ⇒ Object
48 49 50 51 |
# File 'lib/github/markup/markdown.rb', line 48 def render(filename, content, options: {}) load @renderer.call(content, options: ) end |