Nokogiri在Heroku上的解析过程中添加了字符 [英] Nokogiri adds characters during parsing on Heroku

查看:76
本文介绍了Nokogiri在Heroku上的解析过程中添加了字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Nokogiri似乎对nbsp字符的UTF-8转换有问题.我已经收集到这是一个与LibXML2相关的问题. Nokogiri建议将LibXML2升级到2.7.7,而不是在Heroku上运行的2.7.6.

It seems like Nokogiri has a problem with UTF-8 conversion of the nbsp character. I've gathered this is an issue related to LibXML2. Nokogiri recommends upgrading LibXML2 to 2.7.7 instead of 2.7.6 that's running on Heroku.

任何人都知道如何在Heroku上使用LibXML2 2.7.7(或更高版本)吗?

Anyone know how I can use LibXML2 2.7.7 (or higher) on Heroku?

问题如下-

doc = Nokogiri::HTML("<html><p>Hi Hello</p></html>")
doc.inner_html
=> "<html><body><p>Hi Hello</p></body></html>"

doc.inner_html = "<p>Hello&nbsp;World</p>"
=> "<p>Hello&nbsp;World</p>"

doc.inner_html
=> "<p>Hello World</p>"

看起来与以下内容有关: https://github.com/sparklemotion/nokogiri/issues/306

Looks like this is related: https://github.com/sparklemotion/nokogiri/issues/306

这不是在我的本地计算机上发生的. Rails将'utf-8'设置为config.encoding,并且呈现的页面具有utf-8字符集元标记.

This doesn't happen on my local machine. Rails has 'utf-8' set as the config.encoding and the page that's rendered has a utf-8 charset meta tag.

在本地计算机上,我使用limxml2 2.8.0运行Nokogiri 1.6,在Heroku上,我在libxml2 2.7.6运行Nokogiri 1.6.

On my local machine I'm running Nokogiri 1.6 with limxml2 2.8.0 and on Heroku I'm running Nokogiri 1.6 with libxml2 2.7.6.

谢谢.

推荐答案

不幸的是,Heroku不支持在堆栈中安装其他库或二进制文件.最好的解决方法是将它们供应到您的项目中.您需要使用64位Linux版本才能使其在Heroku上运行.静态编译还可以帮助确保包含所需的任何依赖项.同样,对于依赖于外部库的gem,我们建议静态编译gem并将其出售到您的项目中.

Unfortunately Heroku doesn't support installing additional libraries or binaries to stacks. The best workaround is to vendor these into your project. You'll need to use 64-bit Linux versions to make them work on Heroku; compiling statically can also help ensure that any dependencies needed are included. Similarly, for gems that depend on external libraries, we recommend compiling the gem statically and vendoring it into your project.

如果您希望尝试出售二进制文件,库或gem,则可以将Heroku用作构建环境. Herokus的一位工程师创建了一个构建服务器,该服务器可让您上载源代码,运行编译步骤,然后下载生成的二进制文件.您可以在Github上以"Vulcan"的名称找到该项目.

If you do wish to try to vendor your binary, library, or gem, you can use Heroku as your build environment. One of Herokus engineers created a build server that allows you to upload source code, run the compilation step, and then download the resulting binary. You can find this project on Github under the name "Vulcan".

此处提供了更多说明的链接... https://devcenter.heroku.com/articles/buildpack-binaries

Heres a link for more instructions... https://devcenter.heroku.com/articles/buildpack-binaries

这篇关于Nokogiri在Heroku上的解析过程中添加了字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆