From 26f9ad3d98ab6dd3f66aa84ff9e5fbda72a4d809 Mon Sep 17 00:00:00 2001 From: Nick Quaranto Date: Wed, 29 Apr 2009 08:35:27 -0400 Subject: [PATCH] Testing for RedCloth notextile issue and locking to 4.1.0, which parses the tag correctly --- Rakefile | 2 +- lib/jekyll.rb | 1 + lib/jekyll/tags/highlight.rb | 4 ++-- test/test_tags.rb | 35 ++++++++++++++++++++++++++++------- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Rakefile b/Rakefile index 57aaee59..5d86012f 100644 --- a/Rakefile +++ b/Rakefile @@ -15,7 +15,7 @@ begin s.rubyforge_project = "jekyll" s.files.exclude 'test/dest' s.test_files.exclude 'test/dest' - s.add_dependency('RedCloth', '>= 4.0.4') + s.add_dependency('RedCloth', '= 4.1.0') s.add_dependency('liquid', '>= 1.9.0') s.add_dependency('classifier', '>= 1.3.1') s.add_dependency('maruku', '>= 0.5.9') diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 03366935..fa2eb62f 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -12,6 +12,7 @@ require 'yaml' # 3rd party require 'liquid' +gem 'RedCloth', '= 4.1.0' require 'redcloth' # internal requires diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index ca087958..eb069c27 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -30,9 +30,9 @@ module Jekyll end def render_pygments(context, code) - if context["content_type"] == :markdown + if context["content_type"] == "markdown" return "\n" + Albino.new(code, @lang).to_s(@options) + "\n" - elsif context["content_type"] == :textile + elsif context["content_type"] == "textile" return "" + Albino.new(code, @lang).to_s(@options) + "" else return Albino.new(code, @lang).to_s(@options) diff --git a/test/test_tags.rb b/test/test_tags.rb index ff850143..01db31df 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -2,15 +2,26 @@ require File.dirname(__FILE__) + '/helper' class TestTags < Test::Unit::TestCase - def create_post(content, override = {}) + def create_post(content, override = {}, markdown = true) stub(Jekyll).configuration do Jekyll::DEFAULTS.merge({'pygments' => true}).merge(override) end site = Site.new(Jekyll.configuration) info = { :filters => [Jekyll::Filters], :registers => { :site => site } } - @result = Liquid::Template.parse(content).render({}, info) - @result = site.markdown(@result) + if markdown + payload = {"content_type" => "markdown"} + else + payload = {"content_type" => "textile"} + end + + @result = Liquid::Template.parse(content).render(payload, info) + + if markdown + @result = site.markdown(@result) + else + @result = site.textile(@result) + end end def fill_post(code, override = {}) @@ -69,14 +80,24 @@ puts "3..2..1.." CONTENT end + context "using Textile" do + setup do + create_post(@content, {}, false) + end + + should "not textilize highlight block" do + assert_no_match %r{3\.\.2\.\.1\.\."
}, @result + end + end + context "using Maruku" do setup do create_post(@content) end should "parse correctly" do - assert_match %{FIGHT!}, @result - assert_match %{FINISH HIM}, @result + assert_match %r{FIGHT!}, @result + assert_match %r{FINISH HIM}, @result end end @@ -86,8 +107,8 @@ CONTENT end should "parse correctly" do - assert_match %{FIGHT!}, @result - assert_match %{FINISH HIM}, @result + assert_match %r{FIGHT!}, @result + assert_match %r{FINISH HIM}, @result end end end