Saturday, June 8, 2013

[Rails] Re: Why Nokogiri::HTML::Document#meta_encoding returns nil ?

I think it does not recognize the html5 meta charset, since the
following works :

doc.meta_encoding="<meta http-equiv=\"Content-Type\"
content=\"text/html; charset=utf-8\">"
puts doc.meta_encoding

Love U Ruby wrote in post #1111697:
> 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
>
> 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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/98f03acf22cd628bbc5b781c41861c1c%40ruby-forum.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate