Add support for Github Flavored Markdown

This commit is contained in:
Weves 2024-03-26 11:05:04 -07:00 committed by Chris Weaver
parent f135ba9c0c
commit efc7d6e098
4 changed files with 848 additions and 359 deletions

1189
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,7 @@
"autoprefixer": "^10.4.14",
"formik": "^2.2.9",
"js-cookie": "^3.0.5",
"mdast-util-find-and-replace": "^3.0.1",
"next": "^14.1.0",
"postcss": "^8.4.31",
"react": "^18.2.0",
@ -28,7 +29,8 @@
"react-dropzone": "^14.2.3",
"react-icons": "^4.8.0",
"react-loader-spinner": "^5.4.5",
"react-markdown": "^8.0.7",
"react-markdown": "^9.0.1",
"remark-gfm": "^4.0.0",
"semver": "^7.5.4",
"sharp": "^0.32.6",
"swr": "^2.1.5",

View File

@ -14,6 +14,7 @@ import { SearchSummary, ShowHideDocsButton } from "./SearchSummary";
import { SourceIcon } from "@/components/SourceIcon";
import { ThreeDots } from "react-loader-spinner";
import { SkippedSearch } from "./SkippedSearch";
import remarkGfm from "remark-gfm";
export const Hoverable: React.FC<{
children: JSX.Element;
@ -132,6 +133,7 @@ export const AIMessage = ({
/>
),
}}
remarkPlugins={[remarkGfm]}
>
{content}
</ReactMarkdown>
@ -255,6 +257,7 @@ export const HumanMessage = ({
/>
),
}}
remarkPlugins={[remarkGfm]}
>
{content}
</ReactMarkdown>

View File

@ -1,6 +1,7 @@
import { Quote } from "@/lib/search/interfaces";
import { ResponseSection, StatusOptions } from "./ResponseSection";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
const TEMP_STRING = "__$%^TEMP$%^__";
@ -40,7 +41,10 @@ export const AnswerSection = (props: AnswerSectionProps) => {
header = <>AI answer</>;
if (props.answer) {
body = (
<ReactMarkdown className="prose text-sm max-w-full">
<ReactMarkdown
className="prose text-sm max-w-full"
remarkPlugins={[remarkGfm]}
>
{replaceNewlines(props.answer)}
</ReactMarkdown>
);
@ -62,7 +66,10 @@ export const AnswerSection = (props: AnswerSectionProps) => {
status = "success";
header = <>AI answer</>;
body = (
<ReactMarkdown className="prose text-sm max-w-full">
<ReactMarkdown
className="prose text-sm max-w-full"
remarkPlugins={[remarkGfm]}
>
{replaceNewlines(props.answer)}
</ReactMarkdown>
);