),
- // Paragraphs: keep existing text colour, add spacing
p: ({ children }) => (
{children}
),
- // Bold
strong: ({ children }) => (
{children}
),
- // Italic
- em: ({ children }) => (
- {children}
- ),
- // Inline code
+ em: ({ children }) => {children},
code: ({ children, className }) => {
const isBlock = className?.startsWith("language-");
if (isBlock) {
@@ -60,22 +91,18 @@ const components: Components = {
);
},
- // Code blocks
pre: ({ children }) => (
{children}
),
- // Unordered lists
ul: ({ children }) => (
),
- // Ordered lists
ol: ({ children }) => (
{children}
),
li: ({ children }) => {children},
- // Headings (rarely appear in descriptions but handle them gracefully)
h1: ({ children }) => (
{children}
),
@@ -85,24 +112,72 @@ const components: Components = {
h3: ({ children }) => (
{children}
),
- // Blockquotes
blockquote: ({ children }) => (
{children}
),
- // Horizontal rule
hr: () =>
,
};
+/* ── Citations footer sub-component ─────────────────────────────── */
+
+function CitationsFooter({ citations }: { citations: string[] }) {
+ // Auto-expand if few citations; collapse for many
+ const [open, setOpen] = useState(citations.length <= 3);
+
+ return (
+
+
+
+ {open && (
+
+ {citations.map((cite, i) => (
+ -
+
+ {toSuperscript(i + 1)}
+
+ {cite}
+
+ ))}
+
+ )}
+
+ );
+}
+
+/* ── Main component ──────────────────────────────────────────────── */
+
+interface MarkdownTextProps {
+ content: string | null | undefined;
+ /** Extra classes on the wrapper div */
+ className?: string;
+}
+
export default function MarkdownText({ content, className }: MarkdownTextProps) {
if (!content) return null;
+ const { text, citations } = processCitations(content);
+
return (
-
- {content}
+
+ {text}
+ {citations.length > 0 && }
);
}