diff --git a/History.txt b/History.txt index 5e415d54..c1aaa7a0 100644 --- a/History.txt +++ b/History.txt @@ -1,6 +1,7 @@ == * Bug Fixes * Require redcloth >= 4.2.1 in tests (#92) + * Don't break on triple dashes in yaml frontmatter (#93) * Minor Enhancements * Allow .mkd as markdown extension diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index 3e733d72..fd63f57a 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -18,7 +18,7 @@ module Jekyll def read_yaml(base, name) self.content = File.read(File.join(base, name)) - if self.content =~ /^(---\s*\n.*?\n?)(---.*?\n)/m + if self.content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m self.content = self.content[($1.size + $2.size)..-1] self.data = YAML.load($1) diff --git a/test/source/_posts/2010-01-08-triple-dash.markdown b/test/source/_posts/2010-01-08-triple-dash.markdown new file mode 100644 index 00000000..cbb79e7a --- /dev/null +++ b/test/source/_posts/2010-01-08-triple-dash.markdown @@ -0,0 +1,5 @@ +--- +title: Foo --- Bar +--- + +Triple the fun! \ No newline at end of file diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index fe9878e9..357dd4db 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase end should "ensure post count is as expected" do - assert_equal 17, @site.posts.size + assert_equal 18, @site.posts.size end should "insert site.posts into the index" do diff --git a/test/test_post.rb b/test/test_post.rb index 649e2f46..b4b4502d 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -77,7 +77,19 @@ class TestPost < Test::Unit::TestCase @post.read_yaml(@source, @real_file) assert_equal({"title" => "Test title", "layout" => "post", "tag" => "Ruby"}, @post.data) - assert_equal "\r\nThis is the content", @post.content + assert_equal "This is the content", @post.content + end + end + + context "with embedded triple dash" do + setup do + @real_file = "2010-01-08-triple-dash.markdown" + end + should "consume the embedded dashes" do + @post.read_yaml(@source, @real_file) + + assert_equal({"title" => "Foo --- Bar"}, @post.data) + assert_equal "Triple the fun!", @post.content end end @@ -163,7 +175,7 @@ class TestPost < Test::Unit::TestCase @post.read_yaml(@source, @real_file) assert_equal({"title" => "Foo Bar", "layout" => "default"}, @post.data) - assert_equal "\nh1. {{ page.title }}\n\nBest *post* ever", @post.content + assert_equal "h1. {{ page.title }}\n\nBest *post* ever", @post.content end should "transform textile" do