mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
fix: wrap multi-line code blocks in pre tag (#5586)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
parent
4998b5de32
commit
50478c7d21
@ -17,19 +17,38 @@ export function code({
|
||||
const match = /language-(\w+)/.exec(className || ""); // get the language
|
||||
|
||||
if (!match) {
|
||||
const isMultiline = String(children).includes("\n");
|
||||
|
||||
if (!isMultiline) {
|
||||
return (
|
||||
<code
|
||||
className={className}
|
||||
style={{
|
||||
backgroundColor: "#2a3038",
|
||||
padding: "0.2em 0.4em",
|
||||
borderRadius: "4px",
|
||||
color: "#e6edf3",
|
||||
border: "1px solid #30363d",
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</code>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<code
|
||||
className={className}
|
||||
<pre
|
||||
style={{
|
||||
backgroundColor: "#2a3038",
|
||||
padding: "0.2em 0.4em",
|
||||
padding: "1em",
|
||||
borderRadius: "4px",
|
||||
color: "#e6edf3",
|
||||
border: "1px solid #30363d",
|
||||
overflow: "auto",
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</code>
|
||||
<code className={className}>{String(children).replace(/\n$/, "")}</code>
|
||||
</pre>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user