Htmltools and (un)escaped entities

require 'html/stparser’
require ‘html/element’

class MyParser < HTML::StackingParser
def handle_cdata(data)
puts data
end
end

p = MyParser.new
p.feed(“John & Mary”)

The snippet above outputs this:

John
&
Mary

Is there a way to keep the ampersand (or entities in general)
unescaped, so that it will still print a ‘&’?

Massimiliano

require ‘html/stparser’
require ‘html/element’

class MyParser < HTML::StackingParser
def handle_cdata(data)
print data
end
def handle_entityref(name)
print “&#{name};”
end
end

p = MyParser.new
p.feed(“John & Mary”)

$ ruby test.rb
John & Mary$

···

On Saturday 29 June 2002 10:21 am, Massimiliano Mirra wrote:

The snippet above outputs this:

John
&
Mary

Is there a way to keep the ampersand (or entities in general)
unescaped, so that it will still print a ‘&’?


Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE