diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 6d3eb1d..ace366c 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -14,6 +14,7 @@ "date-fns": "^3.6.0", "dompurify": "^3.1.5", "lodash": "^4.17.21", + "markdown": "^0.5.0", "next": "^14.2.3", "next-auth": "^5.0.0-beta.19", "next-themes": "^0.3.0", @@ -2693,6 +2694,11 @@ "license": "Apache-2.0", "peer": true }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, "node_modules/acorn": { "version": "8.12.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", @@ -5958,6 +5964,20 @@ "@jridgewell/sourcemap-codec": "^1.4.15" } }, + "node_modules/markdown": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/markdown/-/markdown-0.5.0.tgz", + "integrity": "sha512-ctGPIcuqsYoJ493sCtFK7H4UEgMWAUdXeBhPbdsg1W0LsV9yJELAHRsMmWfTgao6nH0/x5gf9FmsbxiXnrgaIQ==", + "dependencies": { + "nopt": "~2.1.1" + }, + "bin": { + "md2html": "bin/md2html.js" + }, + "engines": { + "node": "*" + } + }, "node_modules/markdown-table": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.3.tgz", @@ -7051,6 +7071,17 @@ "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", "license": "MIT" }, + "node_modules/nopt": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-2.1.2.tgz", + "integrity": "sha512-x8vXm7BZ2jE1Txrxh/hO74HTuYZQEbo8edoRcANgdZ4+PCV+pbjd/xdummkmjjC7LU5EjPzlu8zEq/oxWylnKA==", + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index 9c4c008..be3ff24 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -16,6 +16,7 @@ "date-fns": "^3.6.0", "dompurify": "^3.1.5", "lodash": "^4.17.21", + "markdown": "^0.5.0", "next": "^14.2.3", "next-auth": "^5.0.0-beta.19", "next-themes": "^0.3.0", diff --git a/frontend/src/components/search/search-response.tsx b/frontend/src/components/search/search-response.tsx index aa31f2a..e209363 100644 --- a/frontend/src/components/search/search-response.tsx +++ b/frontend/src/components/search/search-response.tsx @@ -1,24 +1,34 @@ -import { HTMLAttributes } from 'react' +import { HTMLAttributes, OlHTMLAttributes } from 'react' import Markdown from 'react-markdown' -import remarkGfm from 'remark-gfm' import { twMerge } from 'tailwind-merge' type SearchResponseProps = HTMLAttributes & { response: string } +const components = { + ol(props: OlHTMLAttributes) { + return ( +
    + {props.children} +
+ ) + }, + ul(props: HTMLAttributes) { + return
    {props.children}
+ }, + h3(props: HTMLAttributes) { + return

{props.children}

+ }, +} + export default function SearchResponse(props: SearchResponseProps) { return (
{props.response.split('\\n').map((paragraph, index) => ( -
- - {paragraph} - -
+ + {paragraph.replaceAll(' -', ' -')} + ))}
)