mathiasbynens / he

A robust HTML entity encoder/decoder written in JavaScript.
https://mths.be/he
MIT License
3.45k stars 254 forks source link

Is there an option to escape html without double escaping if the html content has already been escaped? #16

Closed philipwalton closed 10 years ago

philipwalton commented 10 years ago

Currently I'm just decoding before escaping, but I wonder if there's a faster, more elegant solution.

Thanks and great library!

mathiasbynens commented 10 years ago

Interesting. What’s the use case for that? Do you want to escape entire HTML documents?

It sounds a bit exotic to me, but if this turns out to be a common thing, I’ll happily take a closer look.

philipwalton commented 10 years ago

I suppose the use case is when the source or degree or prior processing of the HTML is unknown.

In my specific case, I noticed this issue because I'm creating a build system for my site. Some of the pages are converted from markdown using marked, which escapes ' during the conversion. So when I re-escaped them in my atom.xml feed file it was double escaping and I was ending up with '