import ReactMarkdown, { type Components } from "react-markdown";
import remarkGfm from "remark-gfm";
/**
* Server-rendered markdown for SOPs and the SOP README.
*
* The WFDASH app doesn't depend on `@tailwindcss/typography`, so we
* hand-style the elements that show up in the SOPs (headings,
* paragraphs, lists, tables, code blocks, blockquotes, hr).
*
* The `components` map below is the single source of truth for those
* styles. If a new markdown shape shows up in an SOP, add a class
* here rather than introducing the typography plugin.
*/
export function Markdown({ children }: { children: string }) {
return (
{children}
), ul: ({ children, ...props }) => ({children}), hr: (props) => (
pair
// and inline code in a bare . The presence of a `className`
// (set by `react-markdown` for fenced blocks, e.g. "language-ts")
// is the discriminator. For inline code we just style the chip.
const isBlock = typeof className === "string" && className.length > 0;
if (isBlock) {
return (
{children}
);
}
return (
{children}
);
},
pre: ({ children, ...props }) => (
{children}
),
strong: ({ children, ...props }) => (
{children}
),
em: ({ children, ...props }) => (
{children}
),
input: ({ type, checked, disabled, ...props }) => {
// GFM task-list checkboxes render as disabled checkboxes. Just
// pass them through — we don't need a custom checkbox component,
// the default browser style is fine and conveys "completed task".
if (type === "checkbox") {
return (
);
}
return ;
},
};