Merge pull request #4004 from kevinoid/excerpt-match-post-content
This commit is contained in:
commit
20303de60d
|
@ -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 "<p>content for entry1.</p>" in "_site/index.html"
|
||||
And I should see "<html><head></head><body><p>content for entry1.</p>\n\n</body></html>" in "_site/2007/12/31/entry1.html"
|
||||
And I should see "<html><head></head><body><p>content for entry1.</p>\n</body></html>" in "_site/2007/12/31/entry1.html"
|
||||
|
|
|
@ -107,7 +107,11 @@ module Jekyll
|
|||
def extract_excerpt(post_content)
|
||||
head, _, tail = post_content.to_s.partition(post.excerpt_separator)
|
||||
|
||||
if tail.empty?
|
||||
head
|
||||
else
|
||||
"" << head << "\n\n" << tail.scan(/^\[[^\]]+\]:.+$/).join("\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue