Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Add 10px bottom padding to paragraph tags in markdown rendering (#8440)

Robert Brennan0b897ff3dcec
diff --git a/frontend/src/components/features/chat/chat-message.tsx b/frontend/src/components/features/chat/chat-message.tsx
index 26a9cc2bf5..f2d52c4c2c 100644
--- a/frontend/src/components/features/chat/chat-message.tsx
+++ b/frontend/src/components/features/chat/chat-message.tsx
@@ -6,6 +6,7 @@ import { cn } from "#/utils/utils";
import { ul, ol } from "../markdown/list";
import { CopyToClipboardButton } from "#/components/shared/buttons/copy-to-clipboard-button";
import { anchor } from "../markdown/anchor";
+import { paragraph } from "../markdown/paragraph";
interface ChatMessageProps {
type: "user" | "assistant";
@@ -64,6 +65,7 @@ export function ChatMessage({
ul,
ol,
a: anchor,
+ p: paragraph,
}}
remarkPlugins={[remarkGfm]}
>
diff --git a/frontend/src/components/features/chat/expandable-message.tsx b/frontend/src/components/features/chat/expandable-message.tsx
index 5fe974b073..3416080130 100644
--- a/frontend/src/components/features/chat/expandable-message.tsx
+++ b/frontend/src/components/features/chat/expandable-message.tsx
@@ -15,6 +15,7 @@ import { OpenHandsObservation } from "#/types/core/observations";
import { cn } from "#/utils/utils";
import { code } from "../markdown/code";
import { ol, ul } from "../markdown/list";
+import { paragraph } from "../markdown/paragraph";
import { MonoComponent } from "./mono-component";
import { PathComponent } from "./path-component";
@@ -196,6 +197,7 @@ export function ExpandableMessage({
code,
ul,
ol,
+ p: paragraph,
}}
remarkPlugins={[remarkGfm]}
>
diff --git a/frontend/src/components/features/jupyter/jupyter-cell-output.tsx b/frontend/src/components/features/jupyter/jupyter-cell-output.tsx
index 359c519588..7fd7f0c3fd 100644
--- a/frontend/src/components/features/jupyter/jupyter-cell-output.tsx
+++ b/frontend/src/components/features/jupyter/jupyter-cell-output.tsx
@@ -4,6 +4,7 @@ import { atomOneDark } from "react-syntax-highlighter/dist/esm/styles/hljs";
import { useTranslation } from "react-i18next";
import { I18nKey } from "#/i18n/declaration";
import { JupyterLine } from "#/utils/parse-cell-content";
+import { paragraph } from "../markdown/paragraph";
interface JupyterCellOutputProps {
lines: JupyterLine[];
@@ -25,7 +26,12 @@ export function JupyterCellOutput({ lines }: JupyterCellOutputProps) {
if (line.type === "image") {
return (
<div key={index}>
- <Markdown urlTransform={(value: string) => value}>
+ <Markdown
+ components={{
+ p: paragraph,
+ }}
+ urlTransform={(value: string) => value}
+ >
{line.content}
</Markdown>
</div>
diff --git a/frontend/src/components/features/markdown/paragraph.tsx b/frontend/src/components/features/markdown/paragraph.tsx
new file mode 100644
index 0000000000..8b2cb55dda
--- /dev/null
+++ b/frontend/src/components/features/markdown/paragraph.tsx
@@ -0,0 +1,11 @@
+import React from "react";
+import { ExtraProps } from "react-markdown";
+
+// Custom component to render <p> in markdown with bottom padding
+export function paragraph({
+ children,
+}: React.ClassAttributes<HTMLParagraphElement> &
+ React.HTMLAttributes<HTMLParagraphElement> &
+ ExtraProps) {
+ return <p className="pb-[10px]">{children}</p>;
+}