/** * 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}), // Style tables table: ({ children, ...props }) => (