allow setting of markdown engine with symbol
This commit is contained in:
parent
0df1a7cc28
commit
af9e4989e3
5 changed files with 54 additions and 22 deletions
7
features/markdown.feature
Normal file
7
features/markdown.feature
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
Feature: Markdown support
|
||||||
|
In order to test included Maruku support
|
||||||
|
|
||||||
|
Scenario: Rendering html
|
||||||
|
Given the Server is running at "test-app"
|
||||||
|
When I go to "/markdown.html"
|
||||||
|
Then I should see "<p>Hello World</p>"
|
|
@ -11,6 +11,7 @@ page "/target_ignore.html", :proxy => "/should_be_ignored3.html", :ignore => tru
|
||||||
end
|
end
|
||||||
|
|
||||||
with_layout false do
|
with_layout false do
|
||||||
|
page "/markdown.html"
|
||||||
page "/relative_image.html"
|
page "/relative_image.html"
|
||||||
page "/inline-css.html"
|
page "/inline-css.html"
|
||||||
page "/inline-js.html"
|
page "/inline-js.html"
|
||||||
|
|
1
fixtures/test-app/source/markdown.html.markdown
Normal file
1
fixtures/test-app/source/markdown.html.markdown
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Hello World
|
|
@ -6,23 +6,23 @@ module Middleman::CoreExtensions::FrontMatter
|
||||||
def registered(app)
|
def registered(app)
|
||||||
app.extend ClassMethods
|
app.extend ClassMethods
|
||||||
|
|
||||||
::Tilt::register RDiscountTemplate, 'markdown', 'mkd', 'md'
|
Tilt::register RDiscountTemplate, 'markdown', 'mkd', 'md'
|
||||||
::Tilt::register RedcarpetTemplate, 'markdown', 'mkd', 'md'
|
Tilt::register RedcarpetTemplate, 'markdown', 'mkd', 'md'
|
||||||
::Tilt::register MarukuTemplate, 'markdown', 'mkd', 'md'
|
Tilt::register MarukuTemplate, 'markdown', 'mkd', 'md'
|
||||||
::Tilt::register KramdownTemplate, 'markdown', 'mkd', 'md'
|
Tilt::register KramdownTemplate, 'markdown', 'mkd', 'md'
|
||||||
app.set :markdown_engine, MarukuTemplate
|
app.set :markdown_engine_prefix, Middleman::CoreExtensions::FrontMatter
|
||||||
|
|
||||||
::Tilt::register RedClothTemplate, 'textile'
|
Tilt::register RedClothTemplate, 'textile'
|
||||||
::Tilt.prefer(RedClothTemplate)
|
Tilt.prefer(RedClothTemplate)
|
||||||
|
|
||||||
::Tilt::register ERBTemplate, 'erb', 'rhtml'
|
Tilt::register ERBTemplate, 'erb', 'rhtml'
|
||||||
::Tilt.prefer(ERBTemplate)
|
Tilt.prefer(ERBTemplate)
|
||||||
|
|
||||||
::Tilt::register SlimTemplate, 'slim'
|
Tilt::register SlimTemplate, 'slim'
|
||||||
::Tilt.prefer(SlimTemplate)
|
Tilt.prefer(SlimTemplate)
|
||||||
|
|
||||||
::Tilt::register HamlTemplate, 'haml'
|
Tilt::register HamlTemplate, 'haml'
|
||||||
::Tilt.prefer(HamlTemplate)
|
Tilt.prefer(HamlTemplate)
|
||||||
|
|
||||||
app.after_configuration do
|
app.after_configuration do
|
||||||
app.before_processing do
|
app.before_processing do
|
||||||
|
@ -82,27 +82,27 @@ module Middleman::CoreExtensions::FrontMatter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class RDiscountTemplate < ::Tilt::RDiscountTemplate
|
class RDiscountTemplate < Tilt::RDiscountTemplate
|
||||||
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
||||||
end
|
end
|
||||||
class RedcarpetTemplate < ::Tilt::RedcarpetTemplate
|
class RedcarpetTemplate < Tilt::RedcarpetTemplate
|
||||||
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
||||||
end
|
end
|
||||||
class MarukuTemplate < ::Tilt::MarukuTemplate
|
class MarukuTemplate < Tilt::MarukuTemplate
|
||||||
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
||||||
end
|
end
|
||||||
class RedClothTemplate < ::Tilt::RedClothTemplate
|
class RedClothTemplate < Tilt::RedClothTemplate
|
||||||
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
||||||
end
|
end
|
||||||
class KramdownTemplate < ::Tilt::KramdownTemplate
|
class KramdownTemplate < Tilt::KramdownTemplate
|
||||||
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
||||||
end
|
end
|
||||||
|
|
||||||
class ERBTemplate < ::Tilt::ERBTemplate
|
class ERBTemplate < Tilt::ERBTemplate
|
||||||
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
||||||
end
|
end
|
||||||
|
|
||||||
class HamlTemplate < ::Tilt::HamlTemplate
|
class HamlTemplate < Tilt::HamlTemplate
|
||||||
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
include Middleman::CoreExtensions::FrontMatter::YamlAware
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,34 @@
|
||||||
|
require "tilt"
|
||||||
|
|
||||||
module Middleman::Renderers::Markdown
|
module Middleman::Renderers::Markdown
|
||||||
class << self
|
class << self
|
||||||
def registered(app)
|
def registered(app)
|
||||||
app.set :markdown_engine, ::Tilt::MarukuTemplate
|
app.extend ClassMethods
|
||||||
|
|
||||||
|
app.set :markdown_engine, :maruku
|
||||||
|
|
||||||
|
if !app.respond_to? :markdown_engine_prefix
|
||||||
|
app.set :markdown_engine_prefix, Tilt
|
||||||
|
end
|
||||||
|
|
||||||
app.after_configuration do
|
app.after_configuration do
|
||||||
::Tilt.prefer(app.settings.markdown_engine)
|
engine = app.settings.markdown_engine
|
||||||
|
|
||||||
|
if engine.is_a? Symbol
|
||||||
|
engine = app.tilt_template_from_symbol(engine)
|
||||||
|
end
|
||||||
|
|
||||||
|
Tilt.prefer(engine)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
alias :included :registered
|
alias :included :registered
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module ClassMethods
|
||||||
|
def tilt_template_from_symbol(engine)
|
||||||
|
engine = engine.to_s
|
||||||
|
engine = engine == "rdiscount" ? "RDiscount" : engine.camelize
|
||||||
|
settings.markdown_engine_prefix.const_get("#{engine}Template")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Add table
Reference in a new issue