Skip to content

Commit

Permalink
Added remark gfm to render tables (All-Hands-AI#3423)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim O'Farrell <[email protected]>
  • Loading branch information
tofarr and Tim O'Farrell authored Aug 16, 2024
1 parent 23608be commit f8b129d
Show file tree
Hide file tree
Showing 4 changed files with 289 additions and 1 deletion.
276 changes: 276 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"react-markdown": "^9.0.1",
"react-redux": "^9.1.2",
"react-syntax-highlighter": "^15.5.0",
"remark-gfm": "^4.0.0",
"tailwind-merge": "^2.5.2",
"vite": "^5.4.1",
"web-vitals": "^3.5.2"
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/chat/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Markdown from "react-markdown";
import { FaClipboard, FaClipboardCheck } from "react-icons/fa";
import { twMerge } from "tailwind-merge";
import { useTranslation } from "react-i18next";
import remarkGfm from "remark-gfm";
import { code } from "../markdown/code";
import toast from "#/utils/toast";
import { I18nKey } from "#/i18n/declaration";
Expand Down Expand Up @@ -76,7 +77,9 @@ function ChatMessage({
{isCopy ? <FaClipboardCheck /> : <FaClipboard />}
</button>
)}
<Markdown components={{ code }}>{message.content}</Markdown>
<Markdown components={{ code }} remarkPlugins={[remarkGfm]}>
{message.content}
</Markdown>
{message.imageUrls.length > 0 && (
<div className="flex space-x-2 mt-2">
{message.imageUrls.map((url, index) => (
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,11 @@ code {
list-style-type: disc; /* Handles bullet points */
margin-left: 20px;
}

.markdown-body th {
text-align: left;
}

.markdown-body th, .markdown-body td {
padding: 0.1rem 1rem;
}

0 comments on commit f8b129d

Please sign in to comment.