Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll says Liquid Exception: invalid byte sequence in US-ASCII in documentation.html

Tags:

utf-8

jekyll

I'm trying to run jekyll build on GitLab CI.

This is my .gitlab-ci.yml:

pages:
  script:
  - export LC_ALL=en_US.UTF-8
  - export LANG=en_US.UTF-8
  - gem install jekyll
  - jekyll build --destination public
  artifacts:
    paths:
    - public

When the task runs I get this error:

      Generating... 
  Liquid Exception: invalid byte sequence in US-ASCII in documentation.html
jekyll 3.1.2 | Error:  invalid byte sequence in US-ASCII

ERROR: Build failed with: exit code 1

More informations

documentation.html is:

---
layout: page
title: Documentation
description: Learn how to create awesome poppers
---
<!-- This page is generated by the grunt doc task of the master branch! Don't edit it! -->
{% markdown documentation.md %}

And documentation.md is a markdown document generated by grunt-jsdoc2md.

This is the markdown plugin I'm using:

=begin
  Jekyll tag to include Markdown text from _includes directory preprocessing with Liquid.
  Usage:
    {% markdown <filename> %}
  Dependency:
    - kramdown
=end
module Jekyll
  class MarkdownTag < Liquid::Tag
    def initialize(tag_name, text, tokens)
      super
      @text = text.strip
    end
    require "kramdown"
    def render(context)
      tmpl = File.read File.join Dir.pwd, "_includes", @text
      site = context.registers[:site]
      tmpl = (Liquid::Template.parse tmpl).render site.site_payload
      html = Kramdown::Document.new(tmpl).to_html
    end
  end
end
Liquid::Template.register_tag('markdown', Jekyll::MarkdownTag)

Attempts

As you see, I've already tried setting LC_ALL and LANG to en_US.UTF-8.

I've also added encoding: utf-8 to my _config.yml but it still doesn't work...

Another attempt was to use @text = text.encode("iso-8859-1").force_encoding("utf-8").strip in the markdown plugin.

Suggestions?

like image 372
Fez Vrasta Avatar asked Mar 28 '16 12:03

Fez Vrasta


2 Answers

I had the same problem and found this solution, which worked for me. https://gitlab.com/gitlab-org/gitlab-ce/issues/14983

image: ruby:2.3

before_script:
  - apt-get update >/dev/null
  - apt-get install -y locales >/dev/null
  - echo "en_US UTF-8" > /etc/locale.gen
  - locale-gen en_US.UTF-8
  - export LANG=en_US.UTF-8
  - export LANGUAGE=en_US:en
  - export LC_ALL=en_US.UTF-8
like image 99
crisscross Avatar answered Oct 30 '22 20:10

crisscross


I deleted the markdown plugin and used this:

---
layout: page
title: Documentation
description: Learn how to create awesome poppers
---
<!-- This page is generated by the grunt doc task of the master branch! Don't edit it! -->
{% capture documentation %}
{% include documentation.md %}
{% endcapture %}
{{ documentation | markdownify }}

Everything seems working fine now.

like image 33
Fez Vrasta Avatar answered Oct 30 '22 19:10

Fez Vrasta