diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb
index e7d17789..8ea9d6c4 100644
--- a/lib/jekyll/convertible.rb
+++ b/lib/jekyll/convertible.rb
@@ -24,24 +24,28 @@ module Jekyll
#
# Returns nothing
def transform
- case Jekyll.content_type
- when :textile
+ case self.content_type
+ when 'textile'
self.ext = ".html"
self.content = Jekyll.textile(self.content)
- when :markdown
+ when 'markdown'
self.ext = ".html"
self.content = Jekyll.markdown(self.content)
end
end
- def determine_content_type
+ # Determine which formatting engine to use based on this convertible's
+ # extension
+ #
+ # Returns one of :textile, :markdown or :unknown
+ def content_type
case self.ext[1..-1]
when /textile/i
- return :textile
+ return 'textile'
when /markdown/i, /mkdn/i, /md/i
- return :markdown
+ return 'markdown'
end
- return :unknown
+ return 'unknown'
end
# Add any necessary layouts to this convertible document
@@ -51,7 +55,7 @@ module Jekyll
# Returns nothing
def do_layout(payload, layouts)
# render and transform content (this becomes the final content of the object)
- Jekyll.content_type = self.determine_content_type
+ payload["content_type"] = self.content_type
self.content = Liquid::Template.parse(self.content).render(payload, [Jekyll::Filters])
self.transform
diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb
index db0a9619..07069923 100644
--- a/lib/jekyll/tags/highlight.rb
+++ b/lib/jekyll/tags/highlight.rb
@@ -29,10 +29,12 @@ module Jekyll
end
def render_pygments(context, code)
- if Jekyll.content_type == :markdown
+ if context["content_type"] == :markdown
return "\n" + Albino.new(code, @lang).to_s(@options) + "\n"
+ elsif content["content_type"] == :textile
+ return "" + Albino.new(code, @lang).to_s(@options) + ""
else
- "" + Albino.new(code, @lang).to_s(@options) + ""
+ return Albino.new(code, @lang).to_s(@options)
end
end
diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb
index 567335fc..4486eb9c 100644
--- a/test/test_generated_site.rb
+++ b/test/test_generated_site.rb
@@ -3,11 +3,11 @@ require File.dirname(__FILE__) + '/helper'
class TestGeneratedSite < Test::Unit::TestCase
def setup
clear_dest
- config = Jekyll::DEFAULTS.clone
- config['source'] = File.join(File.dirname(__FILE__), *%w[source])
- config['destination'] = dest_dir
- Jekyll.configure(config)
- @s = Site.new(config)
+ @config = Jekyll::DEFAULTS.clone
+ @config['source'] = File.join(File.dirname(__FILE__), *%w[source])
+ @config['destination'] = dest_dir
+ Jekyll.configure(@config)
+ @s = Site.new(@config)
@s.process
@index = File.read(File.join(dest_dir, 'index.html'))
end
@@ -19,9 +19,8 @@ class TestGeneratedSite < Test::Unit::TestCase
def test_post_content_in_index
# confirm that the {{ post.content }} is rendered OK
- latest_post = Dir[File.join(@source, '_posts/*')].last
- post = Post.new(@source, '', File.basename(latest_post))
- Jekyll.content_type = post.determine_content_type
+ latest_post = Dir[File.join(@config['source'], '_posts/*')].last
+ post = Post.new(@config['source'], '', File.basename(latest_post))
post.transform
assert @index.include?(post.content)
end
diff --git a/test/test_post.rb b/test/test_post.rb
index 1af7df6d..c9c268d8 100644
--- a/test/test_post.rb
+++ b/test/test_post.rb
@@ -131,7 +131,10 @@ class TestPost < Test::Unit::TestCase
end
def test_include
- Jekyll.source = File.join(File.dirname(__FILE__), *%w[source])
+ config = Jekyll::DEFAULTS.clone
+ config['source'] = File.join(File.dirname(__FILE__), *%w[source])
+ Jekyll.configure(config)
+
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2008-12-13-include.markdown")
layouts = {"default" => Layout.new(File.join(File.dirname(__FILE__), *%w[source _layouts]), "simple.html")}
p.render(layouts, {"site" => {"posts" => []}})
diff --git a/test/test_site.rb b/test/test_site.rb
index df4e0e2d..447a8d7c 100644
--- a/test/test_site.rb
+++ b/test/test_site.rb
@@ -2,11 +2,11 @@ require File.dirname(__FILE__) + '/helper'
class TestSite < Test::Unit::TestCase
def setup
- config = {
- 'source' => File.join(File.dirname(__FILE__), *%w[source]),
- 'destination' => dest_dir
- }
- @s = Site.new(config)
+ @config = Jekyll::DEFAULTS.clone
+ @config['source'] = File.join(File.dirname(__FILE__), *%w[source])
+ @config['destination'] = dest_dir
+ Jekyll.configure(@config)
+ @s = Site.new(@config)
end
def test_site_init
@@ -21,7 +21,7 @@ class TestSite < Test::Unit::TestCase
def test_read_posts
@s.read_posts('')
- posts = Dir[File.join(@source, '_posts/*')]
+ posts = Dir[File.join(@config['source'], '_posts/*')]
assert_equal posts.size - 1, @s.posts.size
end
@@ -29,7 +29,7 @@ class TestSite < Test::Unit::TestCase
clear_dest
@s.process
- posts = Dir[File.join(@source, "**", "_posts/*")]
+ posts = Dir[File.join(@config['source'], "**", "_posts/*")]
categories = %w(bar baz category foo z_category publish_test).sort
assert_equal posts.size - 1, @s.posts.size
diff --git a/test/test_tags.rb b/test/test_tags.rb
index 4e6ad795..d2a4c87c 100644
--- a/test/test_tags.rb
+++ b/test/test_tags.rb
@@ -21,10 +21,10 @@ CONTENT
def test_markdown_with_pygments_line_handling
Jekyll.pygments = true
- Jekyll.content_type = :markdown
+ context = {"content_type" => 'markdown'}
- result = Liquid::Template.parse(@content).render({}, [Jekyll::Filters])
- result = Jekyll.markdown_proc.call(result)
+ result = Liquid::Template.parse(@content).render(context, [Jekyll::Filters])
+ result = Jekyll.markdown(result)
assert_no_match(/markdown\-html\-error/,result)
end