add encoding for configuration

This commit is contained in:
MURAOKA Taro 2013-07-30 22:21:09 +09:00 committed by Shigeya Suzuki
parent 7ccb62e524
commit 8a28d80690
4 changed files with 9 additions and 3 deletions

View File

@ -11,6 +11,7 @@ module Jekyll
'plugins' => '_plugins',
'layouts' => '_layouts',
'keep_files' => ['.git','.svn'],
'encoding' => nil,
'timezone' => nil, # use the local timezone

View File

@ -28,7 +28,7 @@ module Jekyll
# Returns nothing.
def read_yaml(base, name)
begin
self.content = File.read(File.join(base, name))
self.content = File.read(File.join(base, name), self.site.file_read_opts)
if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
self.content = $POSTMATCH

View File

@ -3,7 +3,7 @@ module Jekyll
attr_accessor :config, :layouts, :posts, :pages, :static_files,
:categories, :exclude, :include, :source, :dest, :lsi, :pygments,
:permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts,
:show_drafts, :keep_files, :baseurl
:show_drafts, :keep_files, :baseurl, :file_read_opts
attr_accessor :converters, :generators
@ -22,6 +22,11 @@ module Jekyll
self.plugins = plugins_path
self.permalink_style = config['permalink'].to_sym
self.file_read_opts = {}
if encoding = config['encoding']
self.file_read_opts[:encoding] = Encoding.find(encoding)
end
self.reset
self.setup
end

View File

@ -109,7 +109,7 @@ eos
# This method allows to modify the file content by inheriting from the class.
def source(file)
File.read(file)
File.read(file, context.registers[:site].file_read_opts)
end
end
end