Adds option to encode unsafe characters in text content

Thanks for this module. I like its simplicity. I have added a patch to escape invalid characters in text content. I tried to find a way to do this in some post-processing, but the only possible place is during the parsing, otherwise it would encode all the legitimate html characters in addition to any unsafe ones. Please take a look and see what you think.