sparklemotion/nokogiri — pull request #1017 by spraints (2013-12-10 14:59:58+00:00)
Title: Add `replace_entities` to the XML PushParser

795cc5a resolved #76 for `Nokogiri::XML::SAX::Parser`. This branch adds the same option to `Nokogiri::XML::SAX::PushParser`.

For example:

```ruby
require 'nokogiri'
include Nokogiri::XML

def main
before
after
end

def before
puts '-'*40, 'before:'
parser = SAX::PushParser.new(Dest.new)
parser << doc
parser.finish
end

def after
puts '-'*40, 'after:'
parser = SAX::PushParser.new(Dest.new)
parser.replace_entities = true
parser << doc
parser.finish
end

def doc
'p & q'
end

class Dest < SAX::Document
def start_element(name, attrs)
p attrs
end
def characters(text)
p text
end
end

main
```

Output:

```
----------------------------------------
before:
[["a", "x & y"]]
"p "
"&"
" q"
----------------------------------------
after:
[["a", "x & y"]]
"p "
"&"
" q"
```