ace*_*des 4 html ruby html-entities 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>"
Run Code Online (Sandbox Code Playgroud)
没有帮助使用to_html(encoding: 'UTF-8')或US-ASCII。
这看起来很普遍,解析有效的链接格式,并希望将其呈现为有效的HTML。