diff --git a/lib/jekyll.rb b/lib/jekyll.rb index f2a27a0f..36642a26 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -65,6 +65,9 @@ module Jekyll 'pygments' => false, 'markdown' => 'maruku', 'permalink' => 'date', + + 'markdown_ext' => 'markdown,mkd,mkdn,md', + 'textile_ext' => 'textile', 'maruku' => { 'use_tex' => false, diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 2721f02c..b5655476 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -74,9 +74,10 @@ module Jekyll end @setup = true end - + def matches(ext) - ext =~ /(markdown|mkdn?|md)/i + rgx = '(' + @config['markdown_ext'].gsub(',','|') +')' + ext =~ Regexp.new(rgx, Regexp::IGNORECASE) end def output_ext(ext) diff --git a/lib/jekyll/converters/textile.rb b/lib/jekyll/converters/textile.rb index 072e393a..da823d35 100644 --- a/lib/jekyll/converters/textile.rb +++ b/lib/jekyll/converters/textile.rb @@ -17,7 +17,8 @@ module Jekyll end def matches(ext) - ext =~ /textile/i + rgx = '(' + @config['textile_ext'].gsub(',','|') +')' + ext =~ Regexp.new(rgx, Regexp::IGNORECASE) end def output_ext(ext) diff --git a/test/source/_posts/2011-04-12-md-extension.md b/test/source/_posts/2011-04-12-md-extension.md new file mode 100644 index 00000000..163e9133 --- /dev/null +++ b/test/source/_posts/2011-04-12-md-extension.md @@ -0,0 +1,7 @@ +--- +date: 2011-04-12 13:07:09 +--- + +under default configuration, this post should get processed by the identity converter. By changing +textile extension or markdown extension configuration parameters, you should be able to associate +it with either of those converters \ No newline at end of file diff --git a/test/source/_posts/2011-04-12-text-extension.text b/test/source/_posts/2011-04-12-text-extension.text new file mode 100644 index 00000000..e69de29b diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index c7087031..9fb7a409 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase end should "ensure post count is as expected" do - assert_equal 26, @site.posts.size + assert_equal 28, @site.posts.size end should "insert site.posts into the index" do diff --git a/test/test_post.rb b/test/test_post.rb index 323ab7dc..1c3ea641 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -397,6 +397,47 @@ class TestPost < Test::Unit::TestCase post = Post.new(@site, File.join(File.dirname(__FILE__), *%w[source]), 'foo', 'bar/2008-12-12-topical-post.textile') assert_equal ['foo'], post.categories end - end + + context "converter file extension settings" do + setup do + stub(Jekyll).configuration { Jekyll::DEFAULTS } + @site = Site.new(Jekyll.configuration) + end + + should "process .md as markdown under default configuration" do + post = setup_post '2011-04-12-md-extension.md' + conv = post.converter + assert conv.kind_of? Jekyll::MarkdownConverter + end + + should "process .text as indentity under default configuration" do + post = setup_post '2011-04-12-text-extension.text' + conv = post.converter + assert conv.kind_of? Jekyll::IdentityConverter + end + + should "process .text as markdown under alternate configuration" do + @site.config['markdown_ext'] = 'markdown,mdw,mdwn,md,text' + post = setup_post '2011-04-12-text-extension.text' + conv = post.converter + assert conv.kind_of? Jekyll::MarkdownConverter + end + + should "process .md as markdown under alternate configuration" do + @site.config['markdown_ext'] = 'markdown,mkd,mkdn,md,text' + post = setup_post '2011-04-12-text-extension.text' + conv = post.converter + assert conv.kind_of? Jekyll::MarkdownConverter + end + + should "process .text as textile under alternate configuration" do + @site.config['textile_ext'] = 'textile,text' + post = setup_post '2011-04-12-text-extension.text' + conv = post.converter + assert conv.kind_of? Jekyll::TextileConverter + end + + end + end