Skip to content

Commit

Permalink
Merge remote-tracking branch 'derekprior/configurable_coverter_file_e…
Browse files Browse the repository at this point in the history
…xtensions'
  • Loading branch information
mojombo committed May 30, 2011
2 parents 13f1cf5 + d2377b2 commit da99306
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 5 deletions.
3 changes: 3 additions & 0 deletions lib/jekyll.rb
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions lib/jekyll/converters/markdown.rb
Expand Up @@ -74,9 +74,10 @@ def setup
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)
Expand Down
3 changes: 2 additions & 1 deletion lib/jekyll/converters/textile.rb
Expand Up @@ -17,7 +17,8 @@ def setup
end

def matches(ext)
ext =~ /textile/i
rgx = '(' + @config['textile_ext'].gsub(',','|') +')'
ext =~ Regexp.new(rgx, Regexp::IGNORECASE)
end

def output_ext(ext)
Expand Down
7 changes: 7 additions & 0 deletions 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
Empty file.
2 changes: 1 addition & 1 deletion test/test_generated_site.rb
Expand Up @@ -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
Expand Down
43 changes: 42 additions & 1 deletion test/test_post.rb
Expand Up @@ -397,6 +397,47 @@ def do_render(post)
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

0 comments on commit da99306

Please sign in to comment.