如何在不使用Nokogiri的情况下替换ruby中的html标签?
我正在尝试用 HTMl 文档中的文本替换
标记。我开始使用 Nokogiri 来做到这一点。问题是我传递给 Nokogiri 的 HTML 包含类似
<[email protected] 的文本]>
nokogiri 将其视为标签。输出全部搞砸了,因为 Nokogiri 尝试通过将添加到 html 文档来更正“标签”。
有什么想法如何在 Nokogiri 中关闭此自动校正,或者是否有任何其他宝石我可以使用它来做到这一点而不用拧紧输出?
I am trying to replace a <blockquote>
tag with text in an HTMl document. I started off using Nokogiri to do this. The problem is the HTML I pass to Nokogiri contains text like <[email protected]>
which nokogiri considers as a tag. The output is all screwed because Nokogiri tries to correct the "tag" by adding </my_mail>
to the html doc.
Any ideas how to turn off this auto correction in Nokogiri or are there any other gems I can use to do this without screwing the output?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在将字符串发送到 Nokogiri 之前,您可以对邮件周围的
<
和>
进行转义。You can escape
<
and>
around mail before sending string to Nokogiri.