【发布时间】:2012-03-02 02:24:18
【问题描述】:
Nokogiri 1.5.0
我无法输出带有查询参数的链接的已解析片段,特别是在 href 中带有与号的链接。 & 符号被其 html 实体替换。
f = Nokogiri::HTML.fragment(%q{<a href="http://example.com?this=1&that=2">Testing</a>})
f.to_s # => "<a href=\"http://example.com?this=1&that=2\">Testing</a>"
f.to_html # => "<a href=\"http://example.com?this=1&that=2\">Testing</a>"
使用 to_html(encoding: 'UTF-8') 或 US-ASCII 没有帮助。
这似乎很常见,解析有效的链接格式并希望将其呈现为有效的 HTML。
How to make Nokogiri transparently return un/encoded Html entities untouched? 没有帮助。
【问题讨论】:
标签: html ruby nokogiri html-entities