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_exts = .fetch(:commonmarker_exts, [:tagfilter, :autolink, :table, :strikethrough]) CommonMarker.render_html(content, commonmarker_opts, commonmarker_exts) }, "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.
32 33 34 35 36 |
# File 'lib/github/markup/markdown.rb', line 32 def initialize super( /md|mkdn?|mdwn|mdown|markdown|mdx|litcoffee/i, ["Markdown", "MDX", "Literate CoffeeScript"]) end |
Instance Method Details
#load ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/github/markup/markdown.rb', line 38 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
54 55 56 |
# File 'lib/github/markup/markdown.rb', line 54 def name "markdown" end |
#render(filename, content, options: {}) ⇒ Object
49 50 51 52 |
# File 'lib/github/markup/markdown.rb', line 49 def render(filename, content, options: {}) load @renderer.call(content, options: ) end |