Sha256: df1f975fee40b07fd003940b1431710be931e3bb77af4ea24c347bda59ce5124
Contents?: true
Size: 1.26 KB
Versions: 9
Compression:
Stored size: 1.26 KB
Contents
require "github/markup/implementation" module GitHub module Markup class Markdown < Implementation MARKDOWN_GEMS = { "github/markdown" => proc { |content| GitHub::Markdown.render(content) }, "redcarpet" => proc { |content| RedcarpetCompat.new(content).to_html }, "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 }, } def initialize super(/md|mkdn?|mdwn|mdown|markdown|litcoffee/) end 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 def render(content) load @renderer.call(content) end private def try_require(file) require file true rescue LoadError false end end end end
Version data entries
9 entries across 9 versions & 1 rubygems