Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

YAML inferring different encodings for categories in the same Front Matter #226

Closed
spectra opened this Issue · 3 comments

2 participants

@spectra

Categories extracted from the Front Matter of the same post file should always be inferred by YAML as having the same encoding. All my post files are UTF-8, but some categories are read by YAML as ASCII-8BIT, and this crashes site generation.

This is the error:

Configuration from /home/spectra/work/nardol_blog/_config.yml
Building site: . -> ./_site
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/jekyll-0.7.0/lib/jekyll/post.rb:129:in `join': incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding::CompatibilityError)
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/jekyll-0.7.0/lib/jekyll/post.rb:129:in `url'
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/jekyll-0.7.0/lib/jekyll/post.rb:207:in `to_liquid'
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/jekyll-0.7.0/lib/jekyll/post.rb:175:in `render'
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/jekyll-0.7.0/lib/jekyll/site.rb:135:in `block in render'
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/jekyll-0.7.0/lib/jekyll/site.rb:134:in `each'
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/jekyll-0.7.0/lib/jekyll/site.rb:134:in `render'
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/jekyll-0.7.0/lib/jekyll/site.rb:77:in `process'
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/jekyll-0.7.0/bin/jekyll:150:in `'
        from /usr/local/rvm/gems/ruby-1.9.2-p0/bin/jekyll:19:in `load'
        from /usr/local/rvm/gems/ruby-1.9.2-p0/bin/jekyll:19:in `'

It seems to have a common root with issue 188, but that issue deals with encoding problems in the content. Here I am talking about the Front Matter... I also think this stackoverflow question points to the same issue.

I tried:

  • giving post files a "# encoding: utf-8" line;
  • using "Encoding.default_internal" in jekyll libraries;
  • saving each post file again, with an utf-8 editor (I batched it, don't worry).

Nothing changed. I ended-up patching convertible.rb before the end of funcion read_yaml as a work-around:

      if self.data.has_key?('categories')
        data['categories'].each do |category|
          category.force_encoding('utf-8')
        end
      end

... really ugly, I know. For now it works. It should be fixed in Ruby's YAML, IMHO.

@parkr
Owner

Hey @spectra, did you ever get this fixed up?

@spectra

@parkr, As I wrote back then, I used force_encoding. Anyway, after some time, I ended up not using jekyll at all, so I never went beyond that ugly fix.

@parkr
Owner

This'll be fixed in YAML and I can't reproduce the error.

@parkr parkr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.