Skip to content

Commit c3c66e5

Browse files
Merge branch 'master' of https://github.com/reactjs/reactjs.org into sync-b50fe64c
2 parents 16b664c + b50fe64 commit c3c66e5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/components/CodeEditor/CodeEditor.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import {LiveEditor, LiveProvider} from 'react-live';
1111
import {colors, media} from 'theme';
1212
import MetaTitle from 'templates/components/MetaTitle';
1313

14+
// Replace unicode to text for other languages
15+
const unicodeToText = text =>
16+
text.replace(/\\u([\dA-F]{4})/gi, (_, p1) =>
17+
String.fromCharCode(parseInt(p1, 16)),
18+
);
19+
1420
const compileES5 = (
1521
code, // eslint-disable-next-line no-undef
1622
) => Babel.transform(code, {presets: ['es2015', 'react']}).code;
@@ -272,7 +278,7 @@ class CodeEditor extends Component {
272278

273279
if (showJSX) {
274280
newState.code = code;
275-
newState.compiledES6 = compileES6(code);
281+
newState.compiledES6 = unicodeToText(compileES6(code));
276282
} else {
277283
newState.compiledES6 = code;
278284
}

0 commit comments

Comments
 (0)