Love U Ruby <[email protected]> wrote:
> require "nokogiri"
> 
> doc = Nokogiri::HTML::Document.new("<title> Save the page! </title>")
> doc.class # => Nokogiri::HTML::Document
> 
> doc = Nokogiri::HTML::Document.parse <<-eof
> <head>
> <meta name="description" content="Free Web tutorials">
> <meta name="keywords" content="HTML,CSS,XML,JavaScript">
> <meta name="author" content="Ståle Refsnes">
> <meta charset="UTF-8">
> </head>
> eof

I think the problem is that when nokogiri parses html, it assumes html
4.0 transitional, as is evidenced by the DOCTYPE.

I'm not sure how to get it to deal with HTML 5....

> doc.class # => Nokogiri::HTML::Document
> doc.meta_encoding # => nil
> puts doc.to_html
> # >> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
> "http://www.w3.org/TR/REC-html40/loose.dtd";>
> # >> <html><head>
> # >> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
> # >> <meta name="description" content="Free Web tutorials">
> # >> <meta name="keywords" content="HTML,CSS,XML,JavaScript">
> # >> <meta name="author" content="Ståle Refsnes">
> # >> <meta charset="UTF-8">
> # >> </head></html>
> 
> 
> Why  Nokogiri::HTML::Document#meta_encoding returns nil ?
> 
> -- 
> Posted via http://www.ruby-forum.com/.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/503711b356eb4cf916eede1e2ff59dba%40ruby-forum.com?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/51b3478e.a551b60a.0a1b.fffff757%40mx.google.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to