's Blog

Look at the sky, it's so beautiful

Octopress Failed to Read_yaml

| Comments

Octopress failed to read_yaml if your markdown file is GBK encoding. edit Ruby1.9.3\lib\ruby\gems\1.9.1\gems\jekyll-0.11.2\lib\jekyll\convertible.rb as follow

convertible.rb line#29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def read_yaml(base, name)
  self.content = File.read(File.join(base, name)).force_encoding('utf-8')

  if self.content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
    self.content = $POSTMATCH

    begin
      self.data = YAML.load($1)
    rescue => e
      puts "YAML Exception reading #{name}: #{e.message}"
    end
  end

  self.data ||= {}
end

force_encoding will do the trick.

Comments