import path from "node:path/posix"; import ReactMarkdown, { defaultUrlTransform } from "react-markdown"; import rehypeRaw from "rehype-raw"; import rehypeSanitize from "rehype-sanitize"; import remarkGfm from "remark-gfm"; import { encodePath } from "@/lib/format"; import { remarkWikiLinks, wikiUrl } from "@/lib/wiki-links"; /** * Renders GitHub-flavored markdown. Inline HTML is allowed but sanitized with * GitHub's own allowlist, so untrusted READMEs and issue bodies are safe. When * `context` is given, relative links and images resolve against the file's * location in the repository. With `wiki` (the wiki's base URL) instead, they * resolve to the wiki's pages and files, and [[Wiki Links]] work. */ export function Markdown({ children, context, wiki, }: { children: string; context?: { base: string; gitRef: string; dir: string }; wiki?: string; }) { return (