I think we need to make an API addition here. In attribute mode a `"` needs to be turned into `&quot;`. When not in attribute mode the `<` and `>` need to be converted. The details are at http://www.w3.org/TR/2013/CR-html5-20130806/syntax.html#escapingString.

This would mean when in attribute mode we need to use `ENT_COMPAT`. When and avoid encoding `<` and `>`.

If we going to fix this let's get it right. I'm the one the broke it so I'd like to see it right on the second go. We could either use a method for each mode or an argument. Because of escaping issues around `<` and `>` I'm inclined to add a new method.

What do you think? I'm happy to let you write it or I can tackle this problem if you like.

Sorry it took a second go of looking at this to realize this change. It was reading your tests that caused me to go back and re-read the spec. Testing FTW!