diff --git a/lib/jekyll.rb b/lib/jekyll.rb
index 829d1d4b..45ec5c2d 100644
--- a/lib/jekyll.rb
+++ b/lib/jekyll.rb
@@ -46,7 +46,7 @@ module Jekyll
VERSION = '0.3.0'
class << self
- attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc
+ attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc, :content_type
end
Jekyll.lsi = false
diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb
index d68d6039..62463209 100644
--- a/lib/jekyll/convertible.rb
+++ b/lib/jekyll/convertible.rb
@@ -24,16 +24,26 @@ module Jekyll
#
# Returns nothing
def transform
- case self.ext[1..-1]
- when /textile/i
+ case Jekyll.content_type
+ when :textile
self.ext = ".html"
self.content = RedCloth.new(self.content).to_html
- when /markdown/i, /mkdn/i, /md/i
+ when :markdown
self.ext = ".html"
self.content = Jekyll.markdown_proc.call(self.content)
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
# +layouts+ is a Hash of {"name" => "layout"}
# +site_payload+ is the site payload hash
@@ -41,6 +51,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
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 cd4121ae..685fba3f 100644
--- a/lib/jekyll/tags/highlight.rb
+++ b/lib/jekyll/tags/highlight.rb
@@ -17,7 +17,11 @@ module Jekyll
end
def render_pygments(context, code)
- "" + Albino.new(code, @lang).to_s + ""
+ if Jekyll.content_type == :markdown
+ return "\n" + Albino.new(code, @lang).to_s + "\n"
+ else
+ "" + Albino.new(code, @lang).to_s + ""
+ end
end
def render_codehighlighter(context, code)
@@ -34,4 +38,4 @@ module Jekyll
end
-Liquid::Template.register_tag('highlight', Jekyll::HighlightBlock)
\ No newline at end of file
+Liquid::Template.register_tag('highlight', Jekyll::HighlightBlock)
diff --git a/test/test_tags.rb b/test/test_tags.rb
index bdf6b858..4e6ad795 100644
--- a/test/test_tags.rb
+++ b/test/test_tags.rb
@@ -21,6 +21,7 @@ CONTENT
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)