Explorar o código

Add GitHub-flavored Markdown support

cte hai 10 meses
pai
achega
347c69ebe6

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 985 - 44
webview-ui/package-lock.json


+ 1 - 0
webview-ui/package.json

@@ -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",

+ 2 - 18
webview-ui/src/components/ui/markdown/Markdown.tsx

@@ -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}

+ 0 - 13
webview-ui/src/components/ui/markdown/SourceNumberButton.tsx

@@ -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>
-	)
-}

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio