Merge commit '5cfa956448f00730'

This commit is contained in:
Tom Preston-Werner 2009-01-21 15:04:57 -08:00
commit 73a5478664
4 changed files with 52 additions and 6 deletions

View File

@ -46,7 +46,7 @@ module Jekyll
VERSION = '0.3.0' VERSION = '0.3.0'
class << self class << self
attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc, :content_type
end end
Jekyll.lsi = false Jekyll.lsi = false

View File

@ -24,16 +24,26 @@ module Jekyll
# #
# Returns nothing # Returns nothing
def transform def transform
case self.ext[1..-1] case Jekyll.content_type
when /textile/i when :textile
self.ext = ".html" self.ext = ".html"
self.content = RedCloth.new(self.content).to_html self.content = RedCloth.new(self.content).to_html
when /markdown/i, /mkdn/i, /md/i when :markdown
self.ext = ".html" self.ext = ".html"
self.content = Jekyll.markdown_proc.call(self.content) self.content = Jekyll.markdown_proc.call(self.content)
end end
end end
def determine_content_type
case self.ext[1..-1]
when /textile/i
return :textile
when /markdown/i, /mkdn/i, /md/i
return :markdown
end
return :unknown
end
# Add any necessary layouts to this convertible document # Add any necessary layouts to this convertible document
# +layouts+ is a Hash of {"name" => "layout"} # +layouts+ is a Hash of {"name" => "layout"}
# +site_payload+ is the site payload hash # +site_payload+ is the site payload hash
@ -41,6 +51,7 @@ module Jekyll
# Returns nothing # Returns nothing
def do_layout(payload, layouts) def do_layout(payload, layouts)
# render and transform content (this becomes the final content of the object) # render and transform content (this becomes the final content of the object)
Jekyll.content_type = self.determine_content_type
self.content = Liquid::Template.parse(self.content).render(payload, [Jekyll::Filters]) self.content = Liquid::Template.parse(self.content).render(payload, [Jekyll::Filters])
self.transform self.transform

View File

@ -17,8 +17,12 @@ module Jekyll
end end
def render_pygments(context, code) def render_pygments(context, code)
if Jekyll.content_type == :markdown
return "\n" + Albino.new(code, @lang).to_s + "\n"
else
"<notextile>" + Albino.new(code, @lang).to_s + "</notextile>" "<notextile>" + Albino.new(code, @lang).to_s + "</notextile>"
end end
end
def render_codehighlighter(context, code) def render_codehighlighter(context, code)
#The div is required because RDiscount blows ass #The div is required because RDiscount blows ass

31
test/test_tags.rb Normal file
View File

@ -0,0 +1,31 @@
require File.dirname(__FILE__) + '/helper'
class TestTags < Test::Unit::TestCase
def setup
@content = <<CONTENT
---
layout: post
title: This is a test
---
This document results in a markdown error with maruku
{% highlight ruby %}
puts "hi"
puts "bye"
{% endhighlight %}
CONTENT
end
def test_markdown_with_pygments_line_handling
Jekyll.pygments = true
Jekyll.content_type = :markdown
result = Liquid::Template.parse(@content).render({}, [Jekyll::Filters])
result = Jekyll.markdown_proc.call(result)
assert_no_match(/markdown\-html\-error/,result)
end
end