Handle newlines + code blocks in answer

This commit is contained in:
Weves 2023-09-12 15:51:44 -07:00 committed by Chris Weaver
parent 9738e5e628
commit ffa24e2f09
5 changed files with 943 additions and 5 deletions

935
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,7 @@
"react-dropzone": "^14.2.3",
"react-icons": "^4.8.0",
"react-loader-spinner": "^5.4.5",
"react-markdown": "^8.0.7",
"semver": "^7.5.4",
"swr": "^2.1.5",
"tailwindcss": "^3.3.1",
@ -31,6 +32,7 @@
"yup": "^1.1.1"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.10",
"eslint": "^8.48.0",
"eslint-config-next": "^13.4.9",
"prettier": "2.8.8"

View File

@ -50,8 +50,6 @@ const buildDocumentSummaryDisplay = (
sections.push(["...", false, false]);
}
});
console.log(blurb);
console.log(sections);
let previousIsContinuation = sections[0][2];
let previousIsBold = sections[0][1];

View File

@ -1,5 +1,6 @@
import { Quote } from "@/lib/search/interfaces";
import { ResponseSection, StatusOptions } from "./ResponseSection";
import ReactMarkdown from "react-markdown";
interface AnswerSectionProps {
answer: string | null;
@ -39,7 +40,11 @@ const AnswerBody = ({ answer, error, isFetching }: AnswerSectionProps) => {
</div>
);
} else if (answer) {
return <p className="">{answer}</p>;
return (
<ReactMarkdown className="prose prose-invert text-gray-100 text-sm max-w-full">
{answer.replaceAll("\\n", "\n")}
</ReactMarkdown>
);
} else if (!isFetching) {
return <div className="text-gray-300">Information not found</div>;
}

View File

@ -15,5 +15,5 @@ module.exports = {
},
},
},
plugins: [],
plugins: [require("@tailwindcss/typography")],
};