/** * T074: Markdown rendering configuration and wikilink handling */ import React from 'react'; import type { Components } from 'react-markdown'; export interface WikilinkComponentProps { linkText: string; resolved: boolean; onClick?: (linkText: string) => void; } /** * Custom renderer for wikilinks in markdown */ export function createWikilinkComponent( onWikilinkClick?: (linkText: string) => void ): Components { return { // Style links a: ({ href, children, ...props }) => { if (href?.startsWith('wikilink:')) { const linkText = decodeURIComponent(href.replace('wikilink:', '')); return ( { e.preventDefault(); onWikilinkClick?.(linkText); }} role="link" tabIndex={0} onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onWikilinkClick?.(linkText); } }} title={`Go to ${linkText}`} > {children} ); } const isExternal = href?.startsWith('http'); return ( {children} ); }, // Style headings h1: ({ children, ...props }) => (

{children}

), h2: ({ children, ...props }) => (

{children}

), h3: ({ children, ...props }) => (

{children}

), // Style lists ul: ({ children, ...props }) => ( ), ol: ({ children, ...props }) => (
    {children}
), // Style blockquotes blockquote: ({ children, ...props }) => (
{children}
), // Style tables table: ({ children, ...props }) => (
{children}
), th: ({ children, ...props }) => ( {children} ), td: ({ children, ...props }) => ( {children} ), }; } /** * Render broken wikilinks with distinct styling */ export function renderBrokenWikilink( linkText: string, onCreate?: () => void ): React.ReactElement { return ( [[{linkText}]] ); }