From 69e7f4abef6343538c6e566706bc3be24b7e0983 Mon Sep 17 00:00:00 2001 From: Carl Groner Date: Thu, 3 Nov 2011 11:54:49 -0700 Subject: [PATCH] Add test cases for default values with no explicit config. for `hard_breaks`. --- lib/jekyll/converters/textile.rb | 6 +++++- test/test_redcloth.rb | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/converters/textile.rb b/lib/jekyll/converters/textile.rb index 4b507996b02..814b20809ae 100644 --- a/lib/jekyll/converters/textile.rb +++ b/lib/jekyll/converters/textile.rb @@ -28,7 +28,11 @@ def output_ext(ext) def convert(content) setup r = RedCloth.new(content) - r.hard_breaks = @config['redcloth']['hard_breaks'] + + if !@config['redcloth'].nil? and !@config['redcloth']['hard_breaks'].nil? + r.hard_breaks = @config['redcloth']['hard_breaks'] + end + r.to_html end end diff --git a/test/test_redcloth.rb b/test/test_redcloth.rb index 9fd32be1617..2b43fe247f3 100644 --- a/test/test_redcloth.rb +++ b/test/test_redcloth.rb @@ -1,6 +1,30 @@ require File.dirname(__FILE__) + '/helper' class TestRedCloth < Test::Unit::TestCase + + context "RedCloth default (no explicit config) hard_breaks enabled" do + setup do + @textile = TextileConverter.new + end + + should "preserve single line breaks in HTML output" do + assert_equal "

line1
\nline2

", @textile.convert("p. line1\nline2").strip + end + end + + context "Default hard_breaks enabled w/ redcloth section, no hard_breaks value" do + setup do + config = { + 'redcloth' => {} + } + @textile = TextileConverter.new config + end + + should "preserve single line breaks in HTML output" do + assert_equal "

line1
\nline2

", @textile.convert("p. line1\nline2").strip + end + end + context "RedCloth with hard_breaks enabled" do setup do config = {