ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Jekyll이 항상 UTF-8 인코딩을 사용하도록하려면 어떻게해야합니까?
    카테고리 없음 2020. 8. 5. 01:39

    질문


    나는 최근에 개인 웹 사이트를 만들기 위해 Jekyll과 놀았습니다. 나는 루비 프로그래머는 아니지만 구문상의 유사성을 기반으로 충분한 파이썬을 알고 있습니다. 최근 Windows 컴퓨터에서 여러 인코딩 (특히 Windows-1252 및 UTF-8)이 Jekyll 빌드 프로세스에 들어가는 문제가 발생했습니다.

    문제 는 실제 결의없이 종료되었습니다. 또한 변경을 제안하는 또 다른 것을 발견했습니다. Windows 콘솔 인코딩 이지만 오류를 억제하는 데 아무런 도움이되지 않았으며 같은 문제가 계속 발생했습니다. 아래에서 재현 :

    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/block_body.rb:97:in `join': incompatible character encodings: Windows-1252 and UTF-8 (Encoding::CompatibilityError)

    역 추적은 문제가 Liquid 패키지의 block_body.rb 에 있으며 아래에서 재현됨을 나타냅니다 (이것은 내 코드가 아니며 Liquid 패키지에서 직접 가져온 것입니다).

    def render(context)
      output = []
        context.resource_limits.render_score += @nodelist.length
        
          idx = 0
            while node = @nodelist[idx]
                case node
                    when String
                          check_resources(context, node)
                                output << node
                                    when Variable
                                          render_node_to_output(node, output, context)
                                              when Block
                                                    render_node_to_output(node, output, context, node.blank?)
                                                          break if context.interrupt? # might have happened in a for-block
                                                              when Continue, Break
                                                                    # If we get an Interrupt that means the block must stop processing. An
                                                                          # Interrupt is any command that stops block execution such as {% break %}
                                                                                # or {% continue %}
                                                                                      context.push_interrupt(node.interrupt)
                                                                                            break
                                                                                                else # Other non-Block tags
                                                                                                      render_node_to_output(node, output, context)
                                                                                                            break if context.interrupt? # might have happened through an include
                                                                                                                end
                                                                                                                    idx += 1
                                                                                                                      end
                                                                                                                      
                                                                                                                        output.join
                                                                                                                        end
                                                                                                                        
                                                                                                                        private

    내가 오류를 해결할 수있는 유일한 방법은 (저는 오류없이 웹페이지에 Jekyll을 실행할 수있게했습니다) block_body.rb 를 직접 편집하는 것입니다. output.join 바로 앞에 다음을 추가하여 join 메서드가 작동하도록 인코딩을 동일하게 만듭니다.

       output = output.map{ |i| i.dup.force_encoding("UTF-8") }

    익숙하지 않은 외부 패키지를 수정하는 것이이 문제를 해결하는 가장 좋은 방법은 아니지만 지금까지 시도한 유일한 방법입니다. 이 인코딩 문제를 해결할 수있는 다른 작업이 있습니까 (Mac / Linux에서 빌드가 부족함)?


     

     

     

     

    출처 : https://stackoverflow.com/questions/61722976/how-can-i-force-jekyll-to-always-use-a-utf-8-encoding

    댓글

Designed by Tistory.