Skip to content

Commit 896f278

Browse files
committed
Merge pull request #55 from solugebefola/deal-with-braces
Deal with braces
2 parents 66768ec + 4b621c1 commit 896f278

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/htmltojsx.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ HTMLtoJSX.prototype = {
434434
return;
435435
}
436436

437-
var text = escapeSpecialChars(node.textContent)
437+
var text = escapeSpecialChars(node.textContent);
438438

439439
if (this._inPreTag) {
440440
// If this text is contained within a <pre>, we need to ensure the JSX
@@ -446,6 +446,11 @@ HTMLtoJSX.prototype = {
446446
return '{' + JSON.stringify(whitespace) + '}';
447447
});
448448
} else {
449+
// Handle any curly braces.
450+
text = text
451+
.replace(/(\{|\})/g, function(brace) {
452+
return '{\'' + brace + '\'}';
453+
});
449454
// If there's a newline in the text, adjust the indent level
450455
if (text.indexOf('\n') > -1) {
451456
text = text.replace(/\n\s*/g, this._getIndentedNewline());

0 commit comments

Comments
 (0)