fix error for case with broken encoding

This commit is contained in:
stereobooster 2012-07-16 12:15:32 +03:00
parent 2dbce8ca9f
commit a5a6900948
1 changed files with 5 additions and 3 deletions

View File

@ -25,14 +25,16 @@ module Jekyll
#
# Returns nothing.
def read_yaml(base, name)
self.content = File.read(File.join(base, name))
begin
self.content = File.read(File.join(base, name))
if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
self.content = $POSTMATCH
self.data = YAML.load($1)
end
rescue Exception => e
rescue => e
puts "Error reading file #{name}: #{e.message}"
rescue SyntaxError => e
puts "YAML Exception reading #{name}: #{e.message}"
end