Rebased with mojombo. All tests pass. Some conflicts with Liquid and Maruku
This commit is contained in:
parent
4b39c44664
commit
cb13ea3000
|
@ -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
|
||||
|
||||
|
|
|
@ -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 "<notextile>" + Albino.new(code, @lang).to_s(@options) + "</notextile>"
|
||||
else
|
||||
"<notextile>" + Albino.new(code, @lang).to_s(@options) + "</notextile>"
|
||||
return Albino.new(code, @lang).to_s(@options)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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" => []}})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue