Fixed an issue with pygments, markdown, and newlines.

This commit is contained in:
Zachary Pinter 2009-01-11 12:03:46 -07:00
parent bdbf1b9383
commit 5cfa956448
4 changed files with 22 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -17,8 +17,12 @@ module Jekyll
end
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>"
end
end
def render_codehighlighter(context, code)
#The div is required because RDiscount blows ass

View File

@ -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)