Skip to content

How to handle escape character in attribute? #48

Open
@xcv58

Description

@xcv58

I have html string like this:

var html = '<div class="content" data-content="Some text. &lt;a href=&quot;https://google.com/&quot; target=&quot;_blank&quot; class=&quot;external&quot;&gt;Google!&lt;/a&gt;">internal text</div>'

It has data-content attribute which contains &lt;, &gt; and &quot;.

The output is:

<div className="content" data-content="Some text. <a href=&quot;https://google.com/" target="_blank" class="external">Google!</a>">internal text</div>

But it's not a valid jsx code.

I uses this fork to handle such case:
xcv58@ed12343

But I'm not sure whether it's correct way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions