Skip to content

Commit

Permalink
don't prematurely terminate front matter on mid-line triple dashes. f…
Browse files Browse the repository at this point in the history
…ixes jekyll#93
  • Loading branch information
mojombo committed Jan 9, 2010
1 parent c89d8dd commit 4c1021d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions History.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/convertible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def to_s
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)
Expand Down
5 changes: 5 additions & 0 deletions test/source/_posts/2010-01-08-triple-dash.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Foo --- Bar
---

Triple the fun!
2 changes: 1 addition & 1 deletion test/test_generated_site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions test/test_post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,19 @@ def do_render(post)
@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

Expand Down Expand Up @@ -163,7 +175,7 @@ def do_render(post)
@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
Expand Down

0 comments on commit 4c1021d

Please sign in to comment.