not converting HTML entities?

45 views
Skip to first unread message

shalott

unread,
Nov 22, 2009, 1:45:29 PM11/22/09
to nokogiri-talk
Hi all,

Is there some way to make Nokogiri NOT convert HTML entities and just
leave them alone? Here's the situation:

>> text = "<html><body>foo&mdash;bar</body></html>";
>> @doc = Nokogiri.parse(text)
=> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>foo—bar</body></html>

I'd like this to leave the em-dash as &mdash; and can't seem to find
anything in the documentation about how to make Nokogiri do so.

Mike Dalessio

unread,
Nov 23, 2009, 10:01:50 AM11/23/09
to nokogi...@googlegroups.com
Howdy.

On Sun, Nov 22, 2009 at 10:45 AM, shalott <sha...@gmail.com> wrote:

>> text = "<html><body>foo&mdash;bar</body></html>";
>> @doc = Nokogiri.parse(text)
=> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>foo—bar</body></html>

I'd like this to leave the em-dash as &mdash; and can't seem to find
anything in the documentation about how to make Nokogiri do so.

I'm guessing that you're running on libxml 2.6.x. Try upgrading to libxml 2.7.2 or later.

Cheers,
-mike

Reply all
Reply to author
Forward
0 new messages