mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Add GitHub-flavored Markdown support
This commit is contained in:
parent
45bf2a0230
commit
347c69ebe6
4 changed files with 1019 additions and 31 deletions
1016
webview-ui/package-lock.json
generated
1016
webview-ui/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -42,6 +42,7 @@
|
|||
"react-use": "^17.5.1",
|
||||
"react-virtuoso": "^4.7.13",
|
||||
"rehype-highlight": "^7.0.0",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"shell-quote": "^1.8.2",
|
||||
"styled-components": "^6.1.13",
|
||||
"tailwind-merge": "^2.6.0",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { FC, memo } from "react"
|
||||
import ReactMarkdown, { Options } from "react-markdown"
|
||||
import remarkGfm from "remark-gfm"
|
||||
|
||||
import { Separator } from "@/components/ui"
|
||||
|
||||
import { CodeBlock } from "./CodeBlock"
|
||||
import { SourceNumberButton } from "./SourceNumberButton"
|
||||
import { Blockquote } from "./Blockquote"
|
||||
|
||||
const MemoizedReactMarkdown: FC<Options> = memo(
|
||||
|
|
@ -25,6 +25,7 @@ export function Markdown({ content }: { content: string }) {
|
|||
|
||||
return (
|
||||
<MemoizedReactMarkdown
|
||||
remarkPlugins={[remarkGfm]}
|
||||
className="custom-markdown break-words"
|
||||
components={{
|
||||
p({ children }) {
|
||||
|
|
@ -77,23 +78,6 @@ export function Markdown({ content }: { content: string }) {
|
|||
)
|
||||
},
|
||||
a({ href, children }) {
|
||||
// If a text link starts with 'citation:', then render it as
|
||||
// a citation reference.
|
||||
if (
|
||||
Array.isArray(children) &&
|
||||
typeof children[0] === "string" &&
|
||||
children[0].startsWith("citation:")
|
||||
) {
|
||||
const index = Number(children[0].replace("citation:", ""))
|
||||
|
||||
if (!isNaN(index)) {
|
||||
return <SourceNumberButton index={index} />
|
||||
}
|
||||
|
||||
// Citation is not looked up yet, don't render anything.
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<a href={href} target="_blank" rel="noopener noreferrer">
|
||||
{children}
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
import { cn } from "@/lib/utils"
|
||||
|
||||
export function SourceNumberButton({ index, className }: { index: number; className?: string }) {
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
"inline-flex h-5 w-5 items-center justify-center rounded-full bg-gray-100 text-xs",
|
||||
className,
|
||||
)}>
|
||||
{index + 1}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue