3
引入nokogiri 1.5.0如何防止引入nokogiri來自編碼實體在HTML片段
我無法輸出解析後的片段與具有查詢參數的鏈路,特別是與在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?沒有幫助。
感謝您提供參考。 – aceofspades 2012-03-01 21:51:32