diff --git a/features/post_excerpts.feature b/features/post_excerpts.feature index e9d048bd..c66c527b 100644 --- a/features/post_excerpts.feature +++ b/features/post_excerpts.feature @@ -47,4 +47,4 @@ Feature: Post excerpts And the _site/2007/12/31 directory should exist And the "_site/2007/12/31/entry1.html" file should exist And I should see "
content for entry1.
" in "_site/index.html" - And I should see "content for entry1.
\n\n" in "_site/2007/12/31/entry1.html" + And I should see "content for entry1.
\n" in "_site/2007/12/31/entry1.html" diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index 347be217..3d463944 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -107,7 +107,11 @@ module Jekyll def extract_excerpt(post_content) head, _, tail = post_content.to_s.partition(post.excerpt_separator) - "" << head << "\n\n" << tail.scan(/^\[[^\]]+\]:.+$/).join("\n") + if tail.empty? + head + else + "" << head << "\n\n" << tail.scan(/^\[[^\]]+\]:.+$/).join("\n") + end end end end diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb index ecd42148..a5025cda 100644 --- a/test/test_excerpt.rb +++ b/test/test_excerpt.rb @@ -124,4 +124,23 @@ class TestExcerpt < JekyllUnitTest end end end + + context "A whole-post excerpt" do + setup do + clear_dest + @site = Site.new(site_configuration) + @post = setup_post("2008-02-02-published.markdown") + @excerpt = @post.send :extract_excerpt + end + + should "be generated" do + assert_equal true, @excerpt.is_a?(Jekyll::Excerpt) + end + + context "#content" do + should "match the post content" do + assert_equal @post.content, @excerpt.content + end + end + end end