Skip to content

Commit 0d227f8

Browse files
authored
Prevent translation of code blocks by wrapping them in <code> tag (#1274)
1 parent 742f43b commit 0d227f8

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/components/Prism/index.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@ const Basic = ({ code, language }: Props) => (
1616
Prism={Prism}
1717
>
1818
{({ className, tokens, getLineProps, getTokenProps }: any) => (
19-
<pre className={"prism " + className}>
20-
{tokens.map((line, i) => {
21-
if (line.length === 1 && line[0].content === "") {
22-
line[0].content = " "
23-
}
24-
return (
25-
<div {...getLineProps({ line, key: i })} style={{}}>
26-
{line.map((token, key) => (
27-
<span {...getTokenProps({ token, key })} style={{}} />
28-
))}
29-
</div>
30-
)
31-
})}
32-
</pre>
19+
<code>
20+
<pre className={"prism " + className}>
21+
{tokens.map((line, i) => {
22+
if (line.length === 1 && line[0].content === "") {
23+
line[0].content = " "
24+
}
25+
return (
26+
<div {...getLineProps({ line, key: i })} style={{}}>
27+
{line.map((token, key) => (
28+
<span {...getTokenProps({ token, key })} style={{}} />
29+
))}
30+
</div>
31+
)
32+
})}
33+
</pre>
34+
</code>
3335
)}
3436
</Highlight>
3537
)

0 commit comments

Comments
 (0)