Fix exception that causes jekyll to fail when using CRLF (0d0a) linebreaks in YAML front matter.
Signed-off-by: Nick Quaranto <nick@quaran.to>
This commit is contained in:
parent
5468548948
commit
e39810c984
|
@ -18,10 +18,10 @@ 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---\s*\n/m
|
if self.content =~ /^(---\s*\n.*?)\r?\n---\s*\n/m
|
||||||
self.content = self.content[($1.size + 5)..-1]
|
self.content = self.content[($1.size + 5)..-1]
|
||||||
|
|
||||||
self.data = YAML.load($1)
|
self.data = YAML.load($1.dup)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
layout: post
|
||||||
|
title: "Test title"
|
||||||
|
tag: "Ruby"
|
||||||
|
---
|
||||||
|
|
||||||
|
This is the content
|
|
@ -68,6 +68,19 @@ class TestPost < Test::Unit::TestCase
|
||||||
assert_equal "my_category/permalinked-post", @post.url
|
assert_equal "my_category/permalinked-post", @post.url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with CRLF linebreaks" do
|
||||||
|
setup do
|
||||||
|
@real_file = "2009-05-24-yaml-linebreak.markdown"
|
||||||
|
@source = source_dir('win/_posts')
|
||||||
|
end
|
||||||
|
should "read yaml front-matter" do
|
||||||
|
@post.read_yaml(@source, @real_file)
|
||||||
|
|
||||||
|
assert_equal({"title" => "Test title", "layout" => "post", "tag" => "Ruby"}, @post.data)
|
||||||
|
assert_equal "\r\n\r\nThis is the content", @post.content
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "with site wide permalink" do
|
context "with site wide permalink" do
|
||||||
setup do
|
setup do
|
||||||
@post.categories = []
|
@post.categories = []
|
||||||
|
|
|
@ -42,7 +42,7 @@ class TestSite < Test::Unit::TestCase
|
||||||
@site.process
|
@site.process
|
||||||
|
|
||||||
posts = Dir[source_dir("**", "_posts", "*")]
|
posts = Dir[source_dir("**", "_posts", "*")]
|
||||||
categories = %w(bar baz category foo z_category publish_test).sort
|
categories = %w(bar baz category foo z_category publish_test win).sort
|
||||||
|
|
||||||
assert_equal posts.size - 1, @site.posts.size
|
assert_equal posts.size - 1, @site.posts.size
|
||||||
assert_equal categories, @site.categories.keys.sort
|
assert_equal categories, @site.categories.keys.sort
|
||||||
|
|
Loading…
Reference in New Issue