Skip to content

Commit d787eec

Browse files
authored
fix: fix basic markdown usage (#75)
1 parent 638c940 commit d787eec

File tree

4 files changed

+12
-38
lines changed

4 files changed

+12
-38
lines changed

src/components/Chat.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function Chat() {
3131
<ChatBubble variant="sent">
3232
<ChatBubbleAvatar fallback="User" className="w-14" />
3333
<ChatBubbleMessage variant="sent" className="bg-zinc-700">
34-
<Markdown className="text-gray-300">
34+
<Markdown isInverted>
3535
{sanitizeQuestionPrompt({
3636
question: question?.message ?? "",
3737
answer: answer?.message ?? "",

src/components/Dashboard.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ const wrapObjectOutput = (input: AlertConversation["trigger_string"]) => {
2828
if (data === null) return "N/A";
2929
if (typeof data === "string") {
3030
return (
31-
<Markdown className="bg-secondary rounded-lg overflow-auto w-fit p-1">
32-
{data}
33-
</Markdown>
31+
<div className="bg-secondary rounded-lg overflow-auto w-fit p-1">
32+
<Markdown>{data}</Markdown>
33+
</div>
3434
);
3535
}
3636
if (!data.type || !data.name) return "N/A";

src/components/Help.tsx

+2-15
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function Help() {
3030
} catch (error) {
3131
console.error("Error loading help content:", error);
3232
setContent(
33-
"# Error\nFailed to load help content. Please try again later."
33+
"# Error\nFailed to load help content. Please try again later.",
3434
);
3535
}
3636
};
@@ -40,20 +40,7 @@ export function Help() {
4040

4141
return (
4242
<div className="max-w-5xl bg-white rounded-lg px-6 mx-auto">
43-
<Markdown
44-
className="prose prose-lg max-w-none
45-
prose-headings:text-gray-900
46-
prose-h1:text-3xl prose-h1:font-bold prose-h1:mb-8
47-
prose-h2:text-2xl prose-h2:font-semibold prose-h2:mt-8 prose-h2:mb-4
48-
prose-h3:text-xl prose-h3:font-medium prose-h3:mt-6 prose-h3:mb-3
49-
prose-p:text-gray-600 prose-p:leading-relaxed
50-
prose-code:text-blue-600
51-
prose-pre:bg-gray-900 prose-pre:rounded-lg prose-pre:p-4
52-
prose-pre:shadow-md
53-
"
54-
>
55-
{content}
56-
</Markdown>
43+
<Markdown>{content}</Markdown>
5744
</div>
5845
);
5946
}

src/components/Markdown.tsx

+6-19
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import remarkGfm from "remark-gfm";
22
import ReactMarkdown from "react-markdown";
33
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
44
import { oneDark } from "react-syntax-highlighter/dist/esm/styles/prism";
5-
import { cn } from "@/lib/utils";
65
import { CopyToClipboard } from "./CopyToClipboard";
76
import hljs from "highlight.js";
87

@@ -33,7 +32,7 @@ const LANGUAGES_SUBSET_DETECTION = [
3332

3433
interface Props {
3534
children: string;
36-
className?: string;
35+
isInverted?: boolean;
3736
}
3837

3938
const customStyle = {
@@ -52,9 +51,11 @@ const customStyle = {
5251
boxSizing: "border-box",
5352
},
5453
};
55-
export function Markdown({ children, className = "" }: Props) {
54+
55+
export function Markdown({ children, isInverted = false }: Props) {
5656
return (
5757
<ReactMarkdown
58+
className={`max-w-none prose prose-pre:shadow-md prose-pre:rounded-lg prose-pre:p-4 prose-p:leading-relaxed prose-h1:text-3xl prose-h1:font-bold prose-h1:mb-8 prose-h2:text-2xl prose-h2:font-semibold prose-h2:mt-8 prose-h2:mb-4 prose-h3:text-xl prose-h3:font-medium prose-h3:mt-6 prose-h3:mb-3 ${isInverted ? "prose-invert" : ""}`}
5859
components={{
5960
code({ className, children, ...props }) {
6061
if (!children) return null;
@@ -71,7 +72,7 @@ export function Markdown({ children, className = "" }: Props) {
7172
<SyntaxHighlighter
7273
style={customStyle}
7374
language={language}
74-
PreTag="div"
75+
PreTag="pre"
7576
className="rounded-lg overflow-hidden shadow-lg text-sm my-6 whitespace-normal"
7677
wrapLines
7778
{...props}
@@ -84,22 +85,9 @@ export function Markdown({ children, className = "" }: Props) {
8485
</div>
8586
);
8687
},
87-
p({ children }) {
88-
return (
89-
<p
90-
className={cn(
91-
"text-gray-600 leading-relaxed mt-6 mb-3",
92-
className,
93-
)}
94-
>
95-
{children}
96-
</p>
97-
);
98-
},
9988
pre({ children }) {
100-
return <div className="not-prose">{children}</div>;
89+
return children;
10190
},
102-
10391
a({ children, ...props }) {
10492
return (
10593
<a
@@ -116,7 +104,6 @@ export function Markdown({ children, className = "" }: Props) {
116104
},
117105
}}
118106
remarkPlugins={[remarkGfm]}
119-
className={className}
120107
>
121108
{children}
122109
</ReactMarkdown>

0 commit comments

Comments
 (0)