From 139066692044ab6b59aea5058aea678acdf735c6 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Fri, 28 Apr 2017 08:00:56 +0530 Subject: [PATCH 1/3] ignore final newline in folded YAML string before: {{ site.description }} => "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./n" after: {{ site.description }} => "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." --- lib/site_template/_config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/site_template/_config.yml b/lib/site_template/_config.yml index 8cb35c70e85..eb30b445007 100644 --- a/lib/site_template/_config.yml +++ b/lib/site_template/_config.yml @@ -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. From 46849e5a7451a176f0fb8ba60868df02622fc19e Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Fri, 28 Apr 2017 09:08:09 +0530 Subject: [PATCH 2/3] test folded configuration string --- test/source/_config_folded.yml | 8 ++++++++ test/test_configuration.rb | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 test/source/_config_folded.yml diff --git a/test/source/_config_folded.yml b/test/source/_config_folded.yml new file mode 100644 index 00000000000..9b0bfa4c2c5 --- /dev/null +++ b/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 diff --git a/test/test_configuration.rb b/test/test_configuration.rb index c9988d163bc..42d1e87fce5 100644 --- a/test/test_configuration.rb +++ b/test/test_configuration.rb @@ -494,4 +494,20 @@ class TestConfiguration < JekyllUnitTest }) end end + + context "folded YAML string" do + should "ignore newlines entirely" do + tester = Configuration.new + config_file = tester.read_config_file(source_dir("_config_folded.yml")) + config = Jekyll.configuration(config_file) + 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 + end end From dd4a8ecd904ec8b9cf6f45f69636981f12c4c084 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Thu, 22 Jun 2017 08:21:50 +0530 Subject: [PATCH 3/3] test folded 'description' from template file --- test/test_configuration.rb | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/test/test_configuration.rb b/test/test_configuration.rb index 42d1e87fce5..50156926202 100644 --- a/test/test_configuration.rb +++ b/test/test_configuration.rb @@ -496,10 +496,16 @@ class TestConfiguration < JekyllUnitTest end context "folded YAML string" do - should "ignore newlines entirely" do - tester = Configuration.new - config_file = tester.read_config_file(source_dir("_config_folded.yml")) - config = Jekyll.configuration(config_file) + 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" @@ -509,5 +515,15 @@ class TestConfiguration < JekyllUnitTest "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