Skip to content

Customize special characters to encode? #100

@jaslong

Description

@jaslong

We have a use case where we'd like to write JSON into HTML attributes, and we'd like to use html-entities to do this safely.

One problem is that encoding JSON makes it very hard to read since all quotes are encoded.

<div data-user="{&quot;name&quot;:&quot;Conan O&#39;Brien&quot;,&quot;age&quot;:99}"></div>

If we could skip decoding the double quote...

<div data-user='{"name":"Conan O&#39;Brien","age":99}'></div>

Do you think a change to customize the regexp of encoded characters makes sense? Alternatively, you could convince me that this is a bad idea :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions