react-magic
react-magic copied to clipboard
How to handle escape character in attribute?
I have html string like this:
var html = '<div class="content" data-content="Some text. <a href="https://google.com/" target="_blank" class="external">Google!</a>">internal text</div>'
It has data-content attribute which contains <, > and ".
The output is:
<div className="content" data-content="Some text. <a href="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: https://github.com/xcv58/react-magic/commit/ed1234330f26c834fa642fd468373753ff44ad6f
But I'm not sure whether it's correct way.
I am having a similar problem with { and } characters.