Skip to content

Commit

Permalink
Ignore final newline in folded YAML string (#6054)
Browse files Browse the repository at this point in the history
Merge pull request 6054
  • Loading branch information
ashmaroli authored and jekyllbot committed Jul 18, 2017
1 parent 33cb629 commit 026f828
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/site_template/_config.yml
Expand Up @@ -15,7 +15,7 @@
# in the templates via {{ site.myvariable }}.
title: Your awesome title
email: your-email@example.com
description: > # this means to ignore newlines until "baseurl:"
description: >- # this means to ignore newlines until "baseurl:"
Write an awesome description for your new site here. You can edit this
line in _config.yml. It will appear in your document head meta (for
Google search results) and in your feed.xml site description.
Expand Down
8 changes: 8 additions & 0 deletions test/source/_config_folded.yml
@@ -0,0 +1,8 @@
folded_string: >
This string of text will ignore
newlines till the next key.
foo: bar
clean_folded_string: >-
This string of text will ignore
newlines till the next key.
baz: foo
32 changes: 32 additions & 0 deletions test/test_configuration.rb
Expand Up @@ -494,4 +494,36 @@ class TestConfiguration < JekyllUnitTest
})
end
end

context "folded YAML string" do
setup do
@tester = Configuration.new
end

should "ignore newlines in that string entirely from a sample file" do
config = Jekyll.configuration(
@tester.read_config_file(
source_dir("_config_folded.yml")
)
)
assert_equal(
config["folded_string"],
"This string of text will ignore newlines till the next key.\n"
)
assert_equal(
config["clean_folded_string"],
"This string of text will ignore newlines till the next key."
)
end

should "ignore newlines in that string entirely from the template file" do
config = Jekyll.configuration(
@tester.read_config_file(
File.expand_path("../lib/site_template/_config.yml", File.dirname(__FILE__))
)
)
assert_includes config["description"], "an awesome description"
refute_includes config["description"], "\n"
end
end
end

0 comments on commit 026f828

Please sign in to comment.