diff --git a/desktop/src/shared/ui/markdown.tsx b/desktop/src/shared/ui/markdown.tsx index 2997f394d..ad980a6b4 100644 --- a/desktop/src/shared/ui/markdown.tsx +++ b/desktop/src/shared/ui/markdown.tsx @@ -1,3 +1,4 @@ +import { GitPullRequest } from "lucide-react"; import * as React from "react"; import ReactMarkdown, { type Components } from "react-markdown"; import remarkBreaks from "remark-breaks"; @@ -11,6 +12,9 @@ import { rewriteRelayUrl } from "@/shared/lib/mediaUrl"; import remarkChannelLinks from "@/shared/lib/remarkChannelLinks"; import remarkMentions from "@/shared/lib/remarkMentions"; +const GITHUB_PR_RE = + /^https?:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)\/?$/; + type MarkdownProps = { channelNames?: string[]; className?: string; @@ -41,17 +45,35 @@ function createMarkdownComponents( : "space-y-1 pl-6 marker:text-muted-foreground"; return { - a: ({ children, href, ...props }) => ( - - {children} - - ), + a: ({ children, href, ...props }) => { + const prMatch = href ? GITHUB_PR_RE.exec(href) : null; + if (prMatch) { + const [, owner, repo, number] = prMatch; + return ( + + + {owner}/{repo}#{number} + + ); + } + return ( + + {children} + + ); + }, blockquote: ({ children }) => (
{children}