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.

Activity

kasbah

kasbah commented on Aug 12, 2016

@kasbah

I am having a similar problem with { and } characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @kasbah@xcv58

        Issue actions

          How to handle escape character in attribute? · Issue #48 · reactjs/react-magic