mathiasbynens/he — pull request #23 by jugglinmike (2014-08-07 13:02:23+00:00)
Title: Implement `markupChars` option for `he.encode`

Hey @mathiasbynens!

I'd love to use this library in [my polyfill for the iframe `srcdoc` attribute](https://github.com/jugglinmike/srcdoc-polyfill), but I think I need an additional feature. The functionality I'm proposing here would help me to resolve [an issue that was recently filed against that project](https://github.com/jugglinmike/srcdoc-polyfill/issues/5).

Commit message:

> Although `he.escape` allows for escaping "unsafe" markup characters,
> there is currently no way to escape the inverse set--non-ASCII
> characters only. This is useful in contexts where markup is allowed, but
> non-ASCII characters might be otherwise mangled (as in the iframe
> `srcdoc` attribute, for example).
>
> Introduce a new option to `he.encode` which disables the escaping of
> unsafe markup characters. Preserve API compatability by disabling this
> behavior by default.