don't prematurely terminate front matter on mid-line triple dashes. fixes #93

This commit is contained in:
Tom Preston-Werner 2010-01-08 18:04:36 -08:00
parent c89d8dd0f3
commit 4c1021d597
5 changed files with 22 additions and 4 deletions

View File

@ -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

View File

@ -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)

View File

@ -0,0 +1,5 @@
---
title: Foo --- Bar
---
Triple the fun!

View File

@ -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

View File

@ -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