Module: Nokogiri::HTML
- Defined in:
- lib/rusty/nokogiri_ext.rb
Class Method Summary collapse
-
.with_meta_encoding(data) ⇒ Object
loads a document from a data.
Class Method Details
.with_meta_encoding(data) ⇒ Object
loads a document from a data. If the encoding as determined by Nokogiri does not match the meta_encoding, tries to reload the data with that encoding.
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rusty/nokogiri_ext.rb', line 87 def self.(data) doc = Nokogiri.HTML(data) = doc. return doc unless && doc.encoding != # try to reread with meta_encoding doc2 = Nokogiri.HTML(data, nil, ) return doc2 if doc2.encoding == # rereading failed, return original document doc end |