Fixed an issue with pygments, markdown, and newlines.
This commit is contained in:
parent
bdbf1b9383
commit
5cfa956448
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,11 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_pygments(context, code)
|
def render_pygments(context, code)
|
||||||
"<notextile>" + Albino.new(code, @lang).to_s + "</notextile>"
|
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
|
end
|
||||||
|
|
||||||
def render_codehighlighter(context, code)
|
def render_codehighlighter(context, code)
|
||||||
|
@ -34,4 +38,4 @@ module Jekyll
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Liquid::Template.register_tag('highlight', Jekyll::HighlightBlock)
|
Liquid::Template.register_tag('highlight', Jekyll::HighlightBlock)
|
||||||
|
|
|
@ -21,6 +21,7 @@ CONTENT
|
||||||
|
|
||||||
def test_markdown_with_pygments_line_handling
|
def test_markdown_with_pygments_line_handling
|
||||||
Jekyll.pygments = true
|
Jekyll.pygments = true
|
||||||
|
Jekyll.content_type = :markdown
|
||||||
|
|
||||||
result = Liquid::Template.parse(@content).render({}, [Jekyll::Filters])
|
result = Liquid::Template.parse(@content).render({}, [Jekyll::Filters])
|
||||||
result = Jekyll.markdown_proc.call(result)
|
result = Jekyll.markdown_proc.call(result)
|
||||||
|
|
Loading…
Reference in New Issue