From 45a347c0227696959a5bbf289a5b16836ac9f528 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 10 Aug 2014 16:16:41 -0400 Subject: [PATCH 1/3] Read in every Document's content as UTF-8 --- lib/jekyll/document.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 9b0e9c9f..9832c0f4 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -198,7 +198,7 @@ module Jekyll unless defaults.empty? @data = defaults end - @content = File.open(path, "rb") { |f| f.read } + @content = File.open(path, "rb:UTF-8") { |f| f.read } if content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m @content = $POSTMATCH data_file = SafeYAML.load($1) From 68fb130fd0b4038b5b107112627011e855cef7ab Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 10 Aug 2014 16:16:48 -0400 Subject: [PATCH 2/3] Add magic comments for UTF-8 --- lib/jekyll/document.rb | 4 +++- lib/jekyll/renderer.rb | 2 ++ lib/jekyll/site.rb | 2 ++ lib/jekyll/tags/include.rb | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 9832c0f4..0410875d 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + module Jekyll class Document include Comparable @@ -82,7 +84,7 @@ module Jekyll end # Determine whether the document has a YAML header. - # + # # Returns true if the file starts with three dashes def has_yaml_header? @has_yaml_header unless @has_yaml_header.nil? diff --git a/lib/jekyll/renderer.rb b/lib/jekyll/renderer.rb index 25a1552c..f5d30133 100644 --- a/lib/jekyll/renderer.rb +++ b/lib/jekyll/renderer.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + module Jekyll class Renderer diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 87b84f0e..a656b088 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + module Jekyll class Site attr_accessor :config, :layouts, :posts, :pages, :static_files, diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index 97e5c754..f90f8e8a 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + module Jekyll module Tags class IncludeTagError < StandardError From 9b3ccee3dda927480c9ab1cb4a0926fc7e22d8c4 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 10 Aug 2014 16:23:29 -0400 Subject: [PATCH 3/3] Pass in options to File.open in Document. --- lib/jekyll/document.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 0410875d..3840375c 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -200,7 +200,7 @@ module Jekyll unless defaults.empty? @data = defaults end - @content = File.open(path, "rb:UTF-8") { |f| f.read } + @content = File.open(path, "rb", merged_file_read_opts(opts)) { |f| f.read } if content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m @content = $POSTMATCH data_file = SafeYAML.load($1)