Jekyll 说 Liquid 异常:documentation.html 中 US-ASCII 中的无效字节序列

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

我正在尝试 运行 jekyll build 在 GitLab CI.

这是我的 .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

当任务 运行s 我得到这个错误:

      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

更多信息

documentation.html 是:

---
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 %}

documentation.mdgrunt-jsdoc2md生成的markdown文档。

这是我正在使用的 markdown 插件:

=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)

尝试次数

如您所见,我已经尝试将 LC_ALLLANG 设置为 en_US.UTF-8

我也将 encoding: utf-8 添加到我的 _config.yml 但它仍然不起作用...

另一种尝试是在 markdown 插件中使用 @text = text.encode("iso-8859-1").force_encoding("utf-8").strip

建议?

我删除了 markdown 插件并使用了这个:

---
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 }}

现在一切正常。

我遇到了同样的问题并找到了适合我的解决方案。 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