2011-07-10 16:41:53 -04:00
|
|
|
module Middleman::Renderers::Markdown
|
|
|
|
class << self
|
|
|
|
def registered(app)
|
2011-11-17 22:56:55 -05:00
|
|
|
app.send :include, InstanceMethods
|
2011-08-31 15:22:45 -04:00
|
|
|
|
2011-11-19 17:54:03 -05:00
|
|
|
begin
|
|
|
|
require "maruku"
|
|
|
|
app.set :markdown_engine, :maruku
|
|
|
|
rescue LoadError
|
|
|
|
app.set :markdown_engine, nil
|
|
|
|
end
|
|
|
|
|
2011-11-17 22:56:55 -05:00
|
|
|
app.set :markdown_engine_prefix, ::Tilt
|
2011-08-31 15:22:45 -04:00
|
|
|
|
2011-08-04 22:30:58 -04:00
|
|
|
app.after_configuration do
|
2011-11-17 22:56:55 -05:00
|
|
|
unless markdown_engine.nil?
|
|
|
|
if markdown_engine.is_a? Symbol
|
|
|
|
markdown_engine = markdown_tilt_template_from_symbol(markdown_engine)
|
2011-11-10 18:56:04 -05:00
|
|
|
end
|
2011-08-31 15:22:45 -04:00
|
|
|
|
2011-11-17 22:56:55 -05:00
|
|
|
::Tilt.prefer(markdown_engine)
|
2011-11-10 18:56:04 -05:00
|
|
|
end
|
2011-06-27 16:10:09 -04:00
|
|
|
end
|
|
|
|
end
|
2011-07-10 16:41:53 -04:00
|
|
|
alias :included :registered
|
2011-06-27 16:10:09 -04:00
|
|
|
end
|
2011-08-31 15:22:45 -04:00
|
|
|
|
2011-11-17 22:56:55 -05:00
|
|
|
module InstanceMethods
|
2011-11-10 18:56:04 -05:00
|
|
|
def markdown_tilt_template_from_symbol(engine)
|
2011-08-31 15:22:45 -04:00
|
|
|
engine = engine.to_s
|
|
|
|
engine = engine == "rdiscount" ? "RDiscount" : engine.camelize
|
2011-11-17 22:56:55 -05:00
|
|
|
markdown_engine_prefix.const_get("#{engine}Template")
|
2011-08-31 15:22:45 -04:00
|
|
|
end
|
|
|
|
end
|
2011-06-27 16:10:09 -04:00
|
|
|
end
|