don't prematurely terminate front matter on mid-line triple dashes. fixes #93
This commit is contained in:
parent
c89d8dd0f3
commit
4c1021d597
|
@ -1,6 +1,7 @@
|
||||||
==
|
==
|
||||||
* Bug Fixes
|
* Bug Fixes
|
||||||
* Require redcloth >= 4.2.1 in tests (#92)
|
* Require redcloth >= 4.2.1 in tests (#92)
|
||||||
|
* Don't break on triple dashes in yaml frontmatter (#93)
|
||||||
* Minor Enhancements
|
* Minor Enhancements
|
||||||
* Allow .mkd as markdown extension
|
* Allow .mkd as markdown extension
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ module Jekyll
|
||||||
def read_yaml(base, name)
|
def read_yaml(base, name)
|
||||||
self.content = File.read(File.join(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.content = self.content[($1.size + $2.size)..-1]
|
||||||
|
|
||||||
self.data = YAML.load($1)
|
self.data = YAML.load($1)
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Foo --- Bar
|
||||||
|
---
|
||||||
|
|
||||||
|
Triple the fun!
|
|
@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "ensure post count is as expected" do
|
should "ensure post count is as expected" do
|
||||||
assert_equal 17, @site.posts.size
|
assert_equal 18, @site.posts.size
|
||||||
end
|
end
|
||||||
|
|
||||||
should "insert site.posts into the index" do
|
should "insert site.posts into the index" do
|
||||||
|
|
|
@ -77,7 +77,19 @@ class TestPost < Test::Unit::TestCase
|
||||||
@post.read_yaml(@source, @real_file)
|
@post.read_yaml(@source, @real_file)
|
||||||
|
|
||||||
assert_equal({"title" => "Test title", "layout" => "post", "tag" => "Ruby"}, @post.data)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -163,7 +175,7 @@ class TestPost < Test::Unit::TestCase
|
||||||
@post.read_yaml(@source, @real_file)
|
@post.read_yaml(@source, @real_file)
|
||||||
|
|
||||||
assert_equal({"title" => "Foo Bar", "layout" => "default"}, @post.data)
|
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
|
end
|
||||||
|
|
||||||
should "transform textile" do
|
should "transform textile" do
|
||||||
|
|
Loading…
Reference in New Issue