add encoding for configuration
This commit is contained in:
parent
7ccb62e524
commit
8a28d80690
|
@ -11,6 +11,7 @@ module Jekyll
|
||||||
'plugins' => '_plugins',
|
'plugins' => '_plugins',
|
||||||
'layouts' => '_layouts',
|
'layouts' => '_layouts',
|
||||||
'keep_files' => ['.git','.svn'],
|
'keep_files' => ['.git','.svn'],
|
||||||
|
'encoding' => nil,
|
||||||
|
|
||||||
'timezone' => nil, # use the local timezone
|
'timezone' => nil, # use the local timezone
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ module Jekyll
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
def read_yaml(base, name)
|
def read_yaml(base, name)
|
||||||
begin
|
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
|
if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
||||||
self.content = $POSTMATCH
|
self.content = $POSTMATCH
|
||||||
|
|
|
@ -3,7 +3,7 @@ module Jekyll
|
||||||
attr_accessor :config, :layouts, :posts, :pages, :static_files,
|
attr_accessor :config, :layouts, :posts, :pages, :static_files,
|
||||||
:categories, :exclude, :include, :source, :dest, :lsi, :pygments,
|
:categories, :exclude, :include, :source, :dest, :lsi, :pygments,
|
||||||
:permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts,
|
: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
|
attr_accessor :converters, :generators
|
||||||
|
|
||||||
|
@ -22,6 +22,11 @@ module Jekyll
|
||||||
self.plugins = plugins_path
|
self.plugins = plugins_path
|
||||||
self.permalink_style = config['permalink'].to_sym
|
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.reset
|
||||||
self.setup
|
self.setup
|
||||||
end
|
end
|
||||||
|
|
|
@ -109,7 +109,7 @@ eos
|
||||||
|
|
||||||
# This method allows to modify the file content by inheriting from the class.
|
# This method allows to modify the file content by inheriting from the class.
|
||||||
def source(file)
|
def source(file)
|
||||||
File.read(file)
|
File.read(file, context.registers[:site].file_read_opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue