Skip to content

Commit

Permalink
Merge commit '5cfa956448f00730'
Browse files Browse the repository at this point in the history
  • Loading branch information
mojombo committed Jan 21, 2009
2 parents f20b3dd + 5cfa956 commit 73a5478
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/jekyll.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions lib/jekyll/convertible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,34 @@ def read_yaml(base, name)
#
# 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
#
# 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

Expand Down
8 changes: 6 additions & 2 deletions lib/jekyll/tags/highlight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def render(context)
end

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

def render_codehighlighter(context, code)
Expand All @@ -34,4 +38,4 @@ def render_codehighlighter(context, code)

end

Liquid::Template.register_tag('highlight', Jekyll::HighlightBlock)
Liquid::Template.register_tag('highlight', Jekyll::HighlightBlock)
31 changes: 31 additions & 0 deletions test/test_tags.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 73a5478

Please sign in to comment.