vantage-md 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/rehypeSourceLines.ts","../src/sanitize.ts","../src/frontmatter.ts","../src/mermaidCache.ts","../src/mermaidLoader.ts","../src/MermaidDiagram.tsx","../src/FrontmatterDisplay.tsx","../src/scrollToLineAnchor.ts","../src/useLineAnchor.ts","../src/MarkdownViewer.tsx","../src/renderMarkdown.ts"],"names":["defaultSchema","parseTOML","YAML","jsxs","jsx","useEffect","useState","useRef","useMemo","Fragment","memo","HIGHLIGHT_CLASS","useCallback","ReactMarkdown","remarkGfm","remarkMath","rehypeRaw","rehypeSanitize","rehypeSlug","rehypeHighlight","rehypeKatex","unified","remarkParse","remarkRehype","rehypeStringify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAM,UAAA,uBAAiB,GAAA,CAAI;AAAA,EACzB,GAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,YAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,SAAS,MAAM,IAAA,EAAsB;AACnC,EAAA,IAAI,cAAc,IAAA,EAAM;AACtB,IAAA,KAAA,MAAW,KAAA,IAAS,KAAK,QAAA,EAAU;AACjC,MAAA,IAAI,KAAA,CAAM,SAAS,SAAA,EAAW;AAC5B,QAAA,IAAI,UAAA,CAAW,IAAI,KAAA,CAAM,OAAO,KAAK,KAAA,CAAM,QAAA,EAAU,OAAO,IAAA,EAAM;AAChE,UAAA,KAAA,CAAM,UAAA,GAAa,KAAA,CAAM,UAAA,IAAc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,CAAC,MAAA,EAAQ,GAAG,IAAI,KAAK,aAAA,EAAe;AAC7C,IAAA,SAAA,GAAY,SAAA,CAAU,GAAA,CAAI,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA,EAC3C;AACA,EAAA,SAAA,GAAY,SAAA,CAAU,IAAIC,gCAAe,CAAA;AAEzC,EAAA,MAAM,MAAA,GAAS,MAAM,SAAA,CAAU,OAAA,CAAQ,OAAO,IAAI,CAAA;AAElD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,OAAO,MAAM,CAAA;AAAA,IACnB,aAAa,MAAA,CAAO,WAAA;AAAA,IACpB,MAAM,MAAA,CAAO;AAAA,GACf;AACF","file":"react.cjs","sourcesContent":["/**\n * Rehype plugin that adds `data-source-line` attributes to block-level\n * elements based on their position in the original markdown source.\n *\n * This enables GitHub-style line anchors (#L42, #L42-L50) by giving\n * each rendered block a traceable line number from the source.\n */\n\nimport type { Root, Element } from \"hast\";\nimport type { Plugin } from \"unified\";\n\nconst BLOCK_TAGS = new Set([\n \"p\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"li\",\n \"blockquote\",\n \"pre\",\n \"table\",\n \"tr\",\n \"ul\",\n \"ol\",\n \"hr\",\n \"div\",\n]);\n\nfunction visit(node: Root | Element) {\n if (\"children\" in node) {\n for (const child of node.children) {\n if (child.type === \"element\") {\n if (BLOCK_TAGS.has(child.tagName) && child.position?.start?.line) {\n child.properties = child.properties || {};\n child.properties[\"dataSourceLine\"] = child.position.start.line;\n }\n visit(child);\n }\n }\n }\n}\n\nconst rehypeSourceLines: Plugin<[], Root> = () => {\n return (tree: Root) => {\n visit(tree);\n };\n};\n\nexport default rehypeSourceLines;\n","/**\n * Sanitization schema for the rendering pipeline.\n * Allows GFM, KaTeX MathML, syntax highlighting classes, and\n * data-source-line attributes while blocking XSS vectors.\n */\n\nimport { defaultSchema } from \"rehype-sanitize\";\n\ntype Schema = typeof defaultSchema;\n\nexport const sanitizeSchema: Schema = {\n ...defaultSchema,\n tagNames: [\n ...(defaultSchema.tagNames || []),\n // KaTeX MathML elements\n \"math\",\n \"semantics\",\n \"mrow\",\n \"mi\",\n \"mo\",\n \"mn\",\n \"msup\",\n \"msub\",\n \"mfrac\",\n \"mover\",\n \"munder\",\n \"msqrt\",\n \"mroot\",\n \"mtable\",\n \"mtr\",\n \"mtd\",\n \"mtext\",\n \"mspace\",\n \"annotation\",\n // Other\n \"figure\",\n \"figcaption\",\n \"summary\",\n \"details\",\n ],\n attributes: {\n ...defaultSchema.attributes,\n \"*\": [\n ...(defaultSchema.attributes?.[\"*\"] || []),\n \"className\",\n \"style\",\n \"dataSourceLine\",\n ],\n code: [...(defaultSchema.attributes?.code || []), \"className\"],\n span: [...(defaultSchema.attributes?.span || []), \"className\", \"style\"],\n div: [...(defaultSchema.attributes?.div || []), \"className\", \"style\"],\n a: [...(defaultSchema.attributes?.a || []), \"id\", \"className\"],\n math: [\"xmlns\"],\n annotation: [\"encoding\"],\n img: [...(defaultSchema.attributes?.img || []), \"loading\"],\n td: [...(defaultSchema.attributes?.td || []), \"style\"],\n th: [...(defaultSchema.attributes?.th || []), \"style\"],\n },\n};\n","/**\n * Frontmatter parser for YAML (---) and TOML (+++) delimited content.\n * Works in both browser and server environments.\n */\n\nimport YAML from \"yaml\";\nimport { parse as parseTOML } from \"smol-toml\";\n\nexport type FrontmatterFormat = \"yaml\" | \"toml\" | \"none\";\n\nexport interface ParsedFrontmatter {\n frontmatter: Record<string, unknown>;\n body: string;\n format: FrontmatterFormat;\n}\n\n/**\n * Parse frontmatter from markdown content.\n * Supports YAML (delimited by ---) and TOML (delimited by +++).\n */\nexport function parseFrontmatter(content: string): ParsedFrontmatter {\n if (content.startsWith(\"+++\")) {\n return parseFrontmatterWithDelimiter(content, \"+++\", \"toml\");\n }\n if (content.startsWith(\"---\")) {\n return parseFrontmatterWithDelimiter(content, \"---\", \"yaml\");\n }\n return { frontmatter: {}, body: content, format: \"none\" };\n}\n\nfunction parseFrontmatterWithDelimiter(\n content: string,\n delimiter: string,\n format: \"yaml\" | \"toml\",\n): ParsedFrontmatter {\n const searchStart = delimiter.length;\n const endIndex = content.indexOf(`\\n${delimiter}`, searchStart);\n if (endIndex === -1) {\n return { frontmatter: {}, body: content, format: \"none\" };\n }\n\n const raw = content.slice(searchStart + 1, endIndex).trim();\n const bodyStart = endIndex + 1 + delimiter.length;\n const body = content.slice(bodyStart).replace(/^\\n/, \"\");\n\n try {\n const frontmatter =\n format === \"toml\"\n ? (parseTOML(raw) as Record<string, unknown>)\n : (YAML.parse(raw) as Record<string, unknown>);\n return { frontmatter: frontmatter || {}, body, format };\n } catch {\n return { frontmatter: {}, body: content, format: \"none\" };\n }\n}\n","// Global cache for rendered SVGs to prevent re-renders\nexport const svgCache = new Map<string, string>();\n\nexport function clearMermaidCache() {\n svgCache.clear();\n}\n","import type mermaidAPI from \"mermaid\";\n\nlet mermaidInstance: typeof mermaidAPI | null = null;\nlet mermaidLoading: Promise<typeof mermaidAPI> | null = null;\n\nconst isDark = () =>\n typeof document !== \"undefined\" &&\n document.documentElement.classList.contains(\"dark\");\n\nexport async function getMermaid(): Promise<typeof mermaidAPI> {\n if (mermaidInstance) return mermaidInstance;\n if (!mermaidLoading) {\n mermaidLoading = import(\"mermaid\").then((mod) => {\n const m = mod.default;\n m.initialize({\n startOnLoad: false,\n theme: isDark() ? \"dark\" : \"default\",\n securityLevel: \"strict\",\n suppressErrorRendering: true,\n });\n mermaidInstance = m;\n return m;\n });\n }\n return mermaidLoading;\n}\n\nexport function resetMermaidLoader() {\n mermaidInstance = null;\n mermaidLoading = null;\n}\n","import React, { useEffect, useState, useRef, useMemo, memo } from \"react\";\nimport { svgCache } from \"./mermaidCache.js\";\nimport { getMermaid } from \"./mermaidLoader.js\";\n\n// Inline SVG icons to avoid lucide-react dependency\nconst AlertTriangleIcon = () => (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"w-4 h-4 shrink-0\">\n <path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" /><path d=\"M12 9v4\" /><path d=\"M12 17h.01\" />\n </svg>\n);\n\nconst ChevronDownIcon = () => (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"w-3 h-3\">\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n);\n\nconst ChevronUpIcon = () => (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"w-3 h-3\">\n <path d=\"m18 15-6-6-6 6\" />\n </svg>\n);\n\nconst MaximizeIcon = () => (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"w-4 h-4 text-gray-600\">\n <polyline points=\"15 3 21 3 21 9\" /><polyline points=\"9 21 3 21 3 15\" /><line x1=\"21\" x2=\"14\" y1=\"3\" y2=\"10\" /><line x1=\"3\" x2=\"10\" y1=\"21\" y2=\"14\" />\n </svg>\n);\n\nconst CloseIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"w-5 h-5\">\n <path d=\"M18 6 6 18\" /><path d=\"m6 6 12 12\" />\n </svg>\n);\n\ninterface MermaidDiagramProps {\n code: string;\n}\n\nfunction extractErrorMessage(err: unknown): string {\n if (err instanceof Error) {\n const msg = err.message;\n const parseMatch = msg.match(\n /(?:Parse error|Syntax error|Error).*?(?:line \\d+.*)/i,\n );\n if (parseMatch) return parseMatch[0];\n return msg.split(\"\\n\")[0].slice(0, 200);\n }\n if (typeof err === \"string\") return err.split(\"\\n\")[0].slice(0, 200);\n return \"Unknown error\";\n}\n\n/** Simple modal for expanding diagrams */\nfunction DiagramModal({\n isOpen,\n onClose,\n children,\n}: {\n isOpen: boolean;\n onClose: () => void;\n children: React.ReactNode;\n}) {\n useEffect(() => {\n if (!isOpen) return;\n const handler = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onClose();\n };\n document.addEventListener(\"keydown\", handler);\n document.body.style.overflow = \"hidden\";\n return () => {\n document.removeEventListener(\"keydown\", handler);\n document.body.style.overflow = \"unset\";\n };\n }, [isOpen, onClose]);\n\n if (!isOpen) return null;\n\n return (\n <div\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4\"\n onClick={onClose}\n >\n <div\n className=\"bg-white rounded-lg shadow-xl w-full max-w-5xl max-h-[90vh] flex flex-col\"\n role=\"dialog\"\n aria-modal=\"true\"\n onClick={(e) => e.stopPropagation()}\n >\n <div className=\"flex items-center justify-between p-4 border-b\">\n <h2 className=\"text-lg font-semibold\">Mermaid Diagram</h2>\n <button\n onClick={onClose}\n className=\"p-1 hover:bg-gray-100 rounded-full transition-colors\"\n aria-label=\"Close modal\"\n >\n <CloseIcon />\n </button>\n </div>\n <div className=\"p-4 overflow-auto flex-1\">{children}</div>\n </div>\n </div>\n );\n}\n\nconst MermaidDiagramInner: React.FC<MermaidDiagramProps> = ({ code }) => {\n const hasCached = svgCache.has(code);\n const [svg, setSvg] = useState<string>(() => svgCache.get(code) || \"\");\n const [errorMessage, setErrorMessage] = useState<string | null>(null);\n const [showSource, setShowSource] = useState(false);\n const [isModalOpen, setIsModalOpen] = useState(false);\n const [isLoading, setIsLoading] = useState(!hasCached);\n const [minHeight, setMinHeight] = useState<string>(\"auto\");\n const containerRef = useRef<HTMLDivElement>(null);\n const lastHeightRef = useRef<number | null>(null);\n\n const stableId = useMemo(() => {\n let hash = 0;\n for (let i = 0; i < code.length; i++) {\n const char = code.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return `mermaid-${Math.abs(hash).toString(36)}`;\n }, [code]);\n\n useEffect(() => {\n if (hasCached) return;\n\n let mounted = true;\n\n const renderDiagram = async () => {\n try {\n if (containerRef.current) {\n const height = containerRef.current.offsetHeight;\n lastHeightRef.current = height;\n setMinHeight(`${height}px`);\n }\n\n const m = await getMermaid();\n const id = `${stableId}-${Date.now()}`;\n const { svg: renderedSvg } = await m.render(id, code);\n\n if (mounted) {\n svgCache.set(code, renderedSvg);\n setSvg(renderedSvg);\n setErrorMessage(null);\n setIsLoading(false);\n }\n } catch (err) {\n console.error(\"Mermaid render error:\", err);\n if (mounted) {\n setErrorMessage(extractErrorMessage(err));\n setIsLoading(false);\n }\n }\n };\n\n renderDiagram();\n return () => {\n mounted = false;\n };\n }, [code, stableId, hasCached]);\n\n if (errorMessage) {\n return (\n <div\n data-testid=\"mermaid-container\"\n className=\"my-4 rounded-md border border-yellow-300/40 bg-yellow-50/50 dark:border-yellow-700/40 dark:bg-yellow-950/20 overflow-hidden\"\n >\n <div className=\"flex items-center gap-2 px-4 py-2.5 text-sm text-yellow-800 dark:text-yellow-200\">\n <AlertTriangleIcon />\n <span className=\"font-medium\">Diagram syntax error</span>\n <span className=\"text-yellow-700/70 dark:text-yellow-300/60\">\n — {errorMessage}\n </span>\n </div>\n <div className=\"border-t border-yellow-300/30 dark:border-yellow-700/30\">\n <button\n onClick={() => setShowSource(!showSource)}\n className=\"flex items-center gap-1.5 px-4 py-1.5 text-xs text-yellow-700/60 dark:text-yellow-400/50 hover:text-yellow-800 dark:hover:text-yellow-300 transition-colors w-full\"\n >\n {showSource ? <ChevronUpIcon /> : <ChevronDownIcon />}\n {showSource ? \"Hide source\" : \"Show source\"}\n </button>\n {showSource && (\n <pre className=\"px-4 pb-3 text-xs font-mono text-yellow-800/70 dark:text-yellow-200/60 overflow-auto whitespace-pre-wrap\">\n {code}\n </pre>\n )}\n </div>\n </div>\n );\n }\n\n return (\n <>\n <div\n ref={containerRef}\n data-testid=\"mermaid-container\"\n className=\"relative group inline-block max-w-full\"\n style={{ minHeight: isLoading ? minHeight : \"auto\" }}\n >\n <div\n className={`mermaid flex justify-center my-4 overflow-x-auto transition-opacity duration-150 ${isLoading ? \"opacity-50\" : \"opacity-100\"}`}\n dangerouslySetInnerHTML={{ __html: svg }}\n />\n {svg && (\n <button\n onClick={() => setIsModalOpen(true)}\n className=\"absolute top-2 right-2 p-2 bg-white/90 shadow-sm border rounded-md opacity-0 group-hover:opacity-100 transition-opacity hover:bg-gray-50\"\n aria-label=\"Maximize diagram\"\n >\n <MaximizeIcon />\n </button>\n )}\n </div>\n\n <DiagramModal\n isOpen={isModalOpen}\n onClose={() => setIsModalOpen(false)}\n >\n <div\n className=\"flex justify-center items-center min-h-[50vh]\"\n dangerouslySetInnerHTML={{ __html: svg }}\n />\n </DiagramModal>\n </>\n );\n};\n\nexport const MermaidDiagram = memo(\n MermaidDiagramInner,\n (prevProps, nextProps) => prevProps.code === nextProps.code,\n);\n","import React, { memo } from \"react\";\n\n// Inline FileText icon\nconst FileTextIcon = () => (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"text-slate-400\">\n <path d=\"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z\" /><path d=\"M14 2v4a2 2 0 0 0 2 2h4\" /><path d=\"M10 9H8\" /><path d=\"M16 13H8\" /><path d=\"M16 17H8\" />\n </svg>\n);\n\ninterface FrontmatterDisplayProps {\n frontmatter: Record<string, unknown>;\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return (\n Array.isArray(value) && value.every((item) => typeof item === \"string\")\n );\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction formatValue(value: unknown): React.ReactNode {\n if (value instanceof Date) {\n return value.toISOString().split(\"T\")[0];\n }\n if (Array.isArray(value)) {\n return value.map(String).join(\", \");\n }\n if (typeof value === \"boolean\") {\n return value ? \"true\" : \"false\";\n }\n if (isPlainObject(value)) {\n return JSON.stringify(value, null, 2);\n }\n return String(value);\n}\n\nfunction TagList({ items }: { items: string[] }) {\n return (\n <div className=\"flex flex-wrap gap-1.5\">\n {items.map((item) => (\n <span\n key={item}\n className=\"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300\"\n >\n {item}\n </span>\n ))}\n </div>\n );\n}\n\nfunction ValueCell({ value }: { value: unknown }) {\n if (isStringArray(value) && value.length > 0) {\n return <TagList items={value} />;\n }\n if (isPlainObject(value)) {\n return (\n <pre className=\"bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-md px-3 py-2 text-xs font-mono overflow-x-auto text-slate-600 dark:text-slate-300\">\n {formatValue(value)}\n </pre>\n );\n }\n return <span className=\"font-medium\">{formatValue(value)}</span>;\n}\n\nfunction flattenEntries(entries: [string, unknown][]): [string, unknown][] {\n const result: [string, unknown][] = [];\n for (const [key, value] of entries) {\n if (key === \"taxonomies\" && isPlainObject(value)) {\n for (const [taxKey, taxVal] of Object.entries(value)) {\n result.push([taxKey, taxVal]);\n }\n } else if (key === \"extra\" && isPlainObject(value)) {\n for (const [extraKey, extraVal] of Object.entries(value)) {\n result.push([extraKey, extraVal]);\n }\n } else {\n result.push([key, value]);\n }\n }\n return result;\n}\n\nconst FrontmatterDisplayInner: React.FC<FrontmatterDisplayProps> = ({\n frontmatter,\n}) => {\n const raw = Object.entries(frontmatter);\n if (raw.length === 0) return null;\n\n const entries = flattenEntries(raw);\n\n return (\n <div className=\"mb-8 rounded-lg overflow-hidden bg-gradient-to-br from-slate-50 to-slate-100 dark:from-slate-800 dark:to-slate-800/80 border border-slate-200 dark:border-slate-700 shadow-sm\">\n <div className=\"px-4 py-2.5 bg-white/60 dark:bg-slate-900/40 border-b border-slate-200 dark:border-slate-700 flex items-center gap-2\">\n <FileTextIcon />\n <span className=\"text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider\">\n Metadata\n </span>\n </div>\n <div className=\"p-4\">\n <table className=\"w-full text-sm\">\n <tbody>\n {entries.map(([key, value]) => (\n <tr\n key={key}\n className=\"border-b border-slate-200/60 dark:border-slate-700/60 last:border-0\"\n >\n <td className=\"py-2 pr-4 font-medium text-slate-500 dark:text-slate-400 whitespace-nowrap align-top w-1/4 min-w-[100px]\">\n {key}\n </td>\n <td className=\"py-2 text-slate-800 dark:text-slate-200 align-top\">\n <ValueCell value={value} />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </div>\n );\n};\n\nexport const FrontmatterDisplay = memo(FrontmatterDisplayInner);\n","/**\n * Framework-agnostic line anchor utilities.\n * Parse GitHub-style line anchors (#L42, #L42-L50) and scroll/highlight\n * matching elements in a container.\n */\n\nconst HIGHLIGHT_CLASS = \"line-anchor-highlight\";\n\n/**\n * Parse a GitHub-style line anchor hash.\n * Supports: #L42, #L42-L50, #L42-50\n * Returns null if the hash is not a line anchor.\n */\nexport function parseLineAnchor(\n hash: string,\n): { start: number; end: number } | null {\n if (!hash) return null;\n const frag = hash.startsWith(\"#\") ? hash.slice(1) : hash;\n const match = frag.match(/^L(\\d+)(?:-L?(\\d+))?$/);\n if (!match) return null;\n\n const start = parseInt(match[1], 10);\n const end = match[2] ? parseInt(match[2], 10) : start;\n return { start: Math.min(start, end), end: Math.max(start, end) };\n}\n\n/**\n * Clear all line anchor highlights from a container.\n */\nexport function clearLineAnchorHighlights(container: HTMLElement): void {\n container.querySelectorAll(`.${HIGHLIGHT_CLASS}`).forEach((node) => {\n (node as HTMLElement).classList.remove(HIGHLIGHT_CLASS);\n });\n}\n\n/**\n * Scroll to and highlight line-anchored elements in a container.\n *\n * @param container - The DOM element containing rendered markdown\n * @param hash - The URL hash (e.g. \"#L42\" or \"#L42-L50\")\n * @returns A cleanup function that removes the highlights\n */\nexport function scrollToLineAnchor(\n container: HTMLElement,\n hash: string,\n): (() => void) | null {\n clearLineAnchorHighlights(container);\n\n const range = parseLineAnchor(hash);\n if (!range) return null;\n\n const blocks = container.querySelectorAll(\"[data-source-line]\");\n let firstMatch: HTMLElement | null = null;\n\n for (const block of blocks) {\n const line = parseInt(\n (block as HTMLElement).dataset.sourceLine || \"0\",\n 10,\n );\n if (line >= range.start && line <= range.end) {\n (block as HTMLElement).classList.add(HIGHLIGHT_CLASS);\n if (!firstMatch) firstMatch = block as HTMLElement;\n }\n }\n\n // If exact line not found, find the nearest block before the target line\n if (!firstMatch) {\n let closest: HTMLElement | null = null;\n let closestLine = 0;\n for (const block of blocks) {\n const line = parseInt(\n (block as HTMLElement).dataset.sourceLine || \"0\",\n 10,\n );\n if (line <= range.start && line > closestLine) {\n closestLine = line;\n closest = block as HTMLElement;\n }\n }\n if (closest) {\n closest.classList.add(HIGHLIGHT_CLASS);\n firstMatch = closest;\n }\n }\n\n // Scroll to the first highlighted element\n if (firstMatch) {\n requestAnimationFrame(() => {\n // Find the nearest scrollable ancestor\n const scrollParent = findScrollParent(container);\n if (scrollParent) {\n const offset =\n firstMatch!.getBoundingClientRect().top -\n scrollParent.getBoundingClientRect().top +\n scrollParent.scrollTop;\n scrollParent.scrollTo({ top: offset - 32, behavior: \"smooth\" });\n } else {\n firstMatch!.scrollIntoView({ behavior: \"smooth\", block: \"start\" });\n }\n });\n }\n\n return () => clearLineAnchorHighlights(container);\n}\n\nfunction findScrollParent(el: HTMLElement): HTMLElement | null {\n let node: HTMLElement | null = el;\n while (node) {\n const overflow = getComputedStyle(node).overflowY;\n if (overflow === \"auto\" || overflow === \"scroll\") return node;\n node = node.parentElement;\n }\n return null;\n}\n","import { useEffect, useCallback, type RefObject } from \"react\";\nimport {\n parseLineAnchor,\n clearLineAnchorHighlights,\n} from \"./scrollToLineAnchor.js\";\n\nconst HIGHLIGHT_CLASS = \"line-anchor-highlight\";\n\n/**\n * React hook that handles GitHub-style line anchors (#L42, #L42-L50).\n *\n * - Parses the URL hash for line references\n * - Finds block elements with matching `data-source-line` attributes\n * - Scrolls to and highlights them\n * - Dismisses on Escape or click on the highlight\n *\n * @param containerRef - Ref to the DOM element containing rendered markdown\n * @param hash - The current URL hash (e.g. \"#L42\", from location.hash or window.location.hash)\n */\nexport function useLineAnchor(\n containerRef: RefObject<HTMLElement | null>,\n hash: string,\n) {\n const clearHighlights = useCallback(() => {\n const el = containerRef.current;\n if (!el) return;\n clearLineAnchorHighlights(el);\n }, [containerRef]);\n\n // Apply highlights when hash changes\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n\n clearHighlights();\n\n const range = parseLineAnchor(hash);\n if (!range) return;\n\n const blocks = el.querySelectorAll(\"[data-source-line]\");\n let firstMatch: HTMLElement | null = null;\n\n for (const block of blocks) {\n const line = parseInt(\n (block as HTMLElement).dataset.sourceLine || \"0\",\n 10,\n );\n if (line >= range.start && line <= range.end) {\n (block as HTMLElement).classList.add(HIGHLIGHT_CLASS);\n if (!firstMatch) firstMatch = block as HTMLElement;\n }\n }\n\n // If exact line not found, find the nearest block before the target line\n if (!firstMatch) {\n let closest: HTMLElement | null = null;\n let closestLine = 0;\n for (const block of blocks) {\n const line = parseInt(\n (block as HTMLElement).dataset.sourceLine || \"0\",\n 10,\n );\n if (line <= range.start && line > closestLine) {\n closestLine = line;\n closest = block as HTMLElement;\n }\n }\n if (closest) {\n closest.classList.add(HIGHLIGHT_CLASS);\n firstMatch = closest;\n }\n }\n\n // Scroll to the first highlighted element\n if (firstMatch) {\n // Find the scrollable parent\n let scrollParent: HTMLElement | null = el;\n while (scrollParent) {\n const overflow = getComputedStyle(scrollParent).overflowY;\n if (overflow === \"auto\" || overflow === \"scroll\") break;\n scrollParent = scrollParent.parentElement;\n }\n if (scrollParent) {\n const target = firstMatch;\n requestAnimationFrame(() => {\n const offset =\n target.getBoundingClientRect().top -\n scrollParent!.getBoundingClientRect().top +\n scrollParent!.scrollTop;\n scrollParent!.scrollTo({ top: offset - 32, behavior: \"smooth\" });\n });\n }\n }\n }, [hash, containerRef, clearHighlights]);\n\n // Dismiss on Escape\n useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n clearHighlights();\n if (window.location.hash) {\n history.replaceState(null, \"\", window.location.pathname);\n }\n }\n };\n document.addEventListener(\"keydown\", handler);\n return () => document.removeEventListener(\"keydown\", handler);\n }, [clearHighlights]);\n\n // Dismiss on click on highlighted area\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n\n const handler = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n if (target.closest(`.${HIGHLIGHT_CLASS}`)) {\n clearHighlights();\n if (window.location.hash) {\n history.replaceState(null, \"\", window.location.pathname);\n }\n }\n };\n el.addEventListener(\"click\", handler);\n return () => el.removeEventListener(\"click\", handler);\n }, [containerRef, clearHighlights]);\n\n return { clearHighlights };\n}\n","/**\n * React markdown viewer component.\n *\n * Renders markdown with the full Vantage pipeline: GFM, math, syntax\n * highlighting, mermaid diagrams, line anchors, and frontmatter display.\n *\n * This is a standalone component with no dependency on Vantage's stores,\n * router, or review system.\n */\n\nimport React, { memo, useCallback, useMemo, useRef } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport rehypeRaw from \"rehype-raw\";\nimport rehypeSanitize from \"rehype-sanitize\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeSlug from \"rehype-slug\";\nimport rehypeSourceLines from \"./rehypeSourceLines.js\";\nimport { sanitizeSchema } from \"./sanitize.js\";\nimport { parseFrontmatter } from \"./frontmatter.js\";\nimport { MermaidDiagram } from \"./MermaidDiagram.js\";\nimport { FrontmatterDisplay } from \"./FrontmatterDisplay.js\";\nimport { useLineAnchor } from \"./useLineAnchor.js\";\n\nexport interface MarkdownViewerProps {\n /** Markdown content to render */\n content: string;\n /** Current file path (used for resolving relative links and images) */\n currentPath?: string;\n /** URL hash for line anchor highlighting (e.g. \"#L42\") */\n hash?: string;\n /** Base URL for resolving relative links */\n baseUrl?: string;\n /** Base URL for loading images via API (e.g. \"/api\") */\n imageApiBase?: string;\n /** Additional CSS class names */\n className?: string;\n /** Callback when an internal link is clicked */\n onNavigate?: (path: string) => void;\n}\n\nconst MarkdownViewerInner: React.FC<MarkdownViewerProps> = ({\n content,\n currentPath = \"\",\n hash = \"\",\n baseUrl = \"/\",\n imageApiBase,\n className,\n onNavigate,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Line anchor highlighting\n useLineAnchor(containerRef, hash);\n\n // Parse frontmatter from content\n const { frontmatter, body } = useMemo(() => {\n return parseFrontmatter(content);\n }, [content]);\n\n const handleLinkClick = useCallback(\n (e: React.MouseEvent<HTMLAnchorElement>, href: string) => {\n // Anchor links within the same doc\n if (href.startsWith(\"#\")) {\n e.preventDefault();\n const id = href.slice(1);\n const el = document.getElementById(id);\n if (el) {\n const scrollContainer =\n el.closest(\"[data-content-scroll]\") ||\n el.closest(\".overflow-y-auto\");\n if (scrollContainer) {\n const offset =\n el.getBoundingClientRect().top -\n scrollContainer.getBoundingClientRect().top +\n scrollContainer.scrollTop;\n scrollContainer.scrollTo({ top: offset - 16 });\n } else {\n el.scrollIntoView();\n }\n }\n return;\n }\n\n // External links — let the browser handle them\n if (href.startsWith(\"http\") || href.startsWith(\"mailto:\")) return;\n\n // Internal links — delegate to onNavigate if provided\n if (onNavigate) {\n // Respect Ctrl+click, Cmd+click\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n\n e.preventDefault();\n const [pathPart, hashPart] = href.split(\"#\");\n const parts = currentPath.split(\"/\");\n parts.pop();\n const dir = parts.join(\"/\");\n const cleanHref = pathPart.replace(/^\\.\\//, \"\");\n const resolvedPath = dir ? `${dir}/${cleanHref}` : cleanHref;\n onNavigate(resolvedPath + (hashPart ? `#${hashPart}` : \"\"));\n }\n },\n [currentPath, onNavigate],\n );\n\n const resolveHref = useCallback(\n (href: string | undefined): string => {\n if (!href) return \"\";\n if (\n href.startsWith(\"http\") ||\n href.startsWith(\"mailto:\") ||\n href.startsWith(\"#\") ||\n href.startsWith(\"/\")\n ) {\n return href;\n }\n\n const [pathPart, hashPart] = href.split(\"#\");\n const parts = currentPath.split(\"/\");\n parts.pop();\n const dir = parts.join(\"/\");\n const cleanHref = pathPart.replace(/^\\.\\//, \"\");\n const resolvedPath = dir ? `${dir}/${cleanHref}` : cleanHref;\n return `${baseUrl}${resolvedPath}${hashPart ? `#${hashPart}` : \"\"}`;\n },\n [currentPath, baseUrl],\n );\n\n const transformImageUri = useCallback(\n (uri: string, key?: string) => {\n if (key === \"href\") return uri;\n if (uri.startsWith(\"http\") || uri.startsWith(\"data:\")) return uri;\n\n // Resolve relative path based on currentPath\n const parts = currentPath.split(\"/\");\n parts.pop();\n const dir = parts.join(\"/\");\n const resolvedPath = dir ? `${dir}/${uri}` : uri;\n\n if (imageApiBase) {\n return `${imageApiBase}/content?path=${encodeURIComponent(resolvedPath)}`;\n }\n return `${baseUrl}${resolvedPath}`;\n },\n [currentPath, baseUrl, imageApiBase],\n );\n\n const markdownComponents = useMemo(\n () => ({\n a({\n href,\n children,\n ...props\n }: {\n href?: string;\n children?: React.ReactNode;\n } & React.AnchorHTMLAttributes<HTMLAnchorElement>) {\n const resolvedHref = resolveHref(href);\n return (\n <a\n href={resolvedHref}\n onClick={(e) => href && handleLinkClick(e, href)}\n {...props}\n >\n {children}\n </a>\n );\n },\n code(\n props: {\n children?: React.ReactNode;\n className?: string;\n } & React.HTMLAttributes<HTMLElement>,\n ) {\n const { children, className: codeClassName, ...rest } = props;\n const match = /language-(\\w+)/.exec(codeClassName || \"\");\n if (match && match[1] === \"mermaid\") {\n return <MermaidDiagram code={String(children).replace(/\\n$/, \"\")} />;\n }\n return (\n <code className={codeClassName} {...rest}>\n {children}\n </code>\n );\n },\n }),\n [handleLinkClick, resolveHref],\n );\n\n const proseClasses = [\n \"prose prose-slate dark:prose-invert max-w-none\",\n \"prose-headings:font-semibold prose-headings:tracking-tight prose-headings:text-slate-900 dark:prose-headings:text-slate-100\",\n \"prose-h1:text-[2em] prose-h1:mb-3 prose-h1:pb-[0.3em] prose-h1:border-b prose-h1:border-slate-200 dark:prose-h1:border-slate-700\",\n \"prose-h2:text-[1.5em] prose-h2:mt-6 prose-h2:mb-3 prose-h2:pb-[0.3em] prose-h2:border-b prose-h2:border-slate-200 dark:prose-h2:border-slate-700\",\n \"prose-h3:text-[1.25em] prose-h3:mt-6 prose-h3:mb-2\",\n \"prose-h4:text-[1em] prose-h4:mt-6 prose-h4:mb-2\",\n \"prose-p:text-slate-700 dark:prose-p:text-slate-300 prose-p:leading-[1.5] prose-p:my-[16px]\",\n \"prose-ul:my-[16px] prose-ul:list-disc prose-li:my-0.5 prose-li:marker:text-slate-900 dark:prose-li:marker:text-slate-300\",\n \"prose-ol:my-[16px] prose-li:marker:text-slate-900 dark:prose-li:marker:text-slate-300\",\n \"prose-pre:bg-slate-50 dark:prose-pre:bg-slate-800 prose-pre:border prose-pre:border-slate-200 dark:prose-pre:border-slate-700 prose-pre:p-4 prose-pre:rounded-md prose-pre:text-[85%] prose-pre:leading-[1.45]\",\n \"prose-a:text-blue-600 dark:prose-a:text-blue-400 prose-a:no-underline hover:prose-a:underline\",\n \"prose-img:rounded-lg prose-img:my-4\",\n \"prose-blockquote:border-l-[0.25em] prose-blockquote:border-slate-300 dark:prose-blockquote:border-slate-600 prose-blockquote:pl-4 prose-blockquote:text-slate-600 dark:prose-blockquote:text-slate-400 prose-blockquote:italic\",\n \"prose-code:before:content-none prose-code:after:content-none\",\n \"prose-code:bg-slate-100 dark:prose-code:bg-slate-800 prose-code:px-[0.4em] prose-code:py-[0.2em] prose-code:rounded-md prose-code:text-slate-800 dark:prose-code:text-slate-200 prose-code:font-mono prose-code:text-[85%] prose-code:font-normal prose-code:border prose-code:border-slate-200/50 dark:prose-code:border-slate-700/50\",\n \"prose-table:text-sm\",\n \"prose-th:px-3 prose-th:py-1.5 prose-th:border prose-th:border-slate-200 dark:prose-th:border-slate-700\",\n \"prose-td:px-3 prose-td:py-1.5 prose-td:border prose-td:border-slate-200 dark:prose-td:border-slate-700\",\n ].join(\" \");\n\n return (\n <div\n ref={containerRef}\n className={className ? `${proseClasses} ${className}` : proseClasses}\n >\n <FrontmatterDisplay frontmatter={frontmatter} />\n <ReactMarkdown\n remarkPlugins={[\n [remarkGfm, { singleTilde: false }],\n [remarkMath, { singleDollarTextMath: false }],\n ]}\n rehypePlugins={[\n rehypeRaw,\n rehypeSourceLines,\n [rehypeSanitize, sanitizeSchema],\n rehypeSlug,\n rehypeHighlight,\n rehypeKatex,\n ]}\n urlTransform={transformImageUri}\n components={markdownComponents}\n >\n {body}\n </ReactMarkdown>\n </div>\n );\n};\n\nexport const MarkdownViewer = memo(\n MarkdownViewerInner,\n (prevProps, nextProps) =>\n prevProps.content === nextProps.content &&\n prevProps.currentPath === nextProps.currentPath &&\n prevProps.hash === nextProps.hash &&\n prevProps.className === nextProps.className,\n);\n","/**\n * Framework-agnostic markdown -> HTML rendering pipeline.\n * Uses the same remark/rehype chain as the Vantage viewer.\n */\n\nimport { unified } from \"unified\";\nimport remarkParse from \"remark-parse\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport remarkRehype from \"remark-rehype\";\nimport rehypeRaw from \"rehype-raw\";\nimport rehypeSanitize from \"rehype-sanitize\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeSlug from \"rehype-slug\";\nimport rehypeStringify from \"rehype-stringify\";\nimport rehypeSourceLines from \"./rehypeSourceLines.js\";\nimport { sanitizeSchema } from \"./sanitize.js\";\nimport { parseFrontmatter } from \"./frontmatter.js\";\nimport type { ParsedFrontmatter } from \"./frontmatter.js\";\n\nexport interface RenderOptions {\n /** Enable GFM tables, strikethrough, task lists (default: true) */\n gfm?: boolean;\n /** Enable KaTeX math rendering (default: true) */\n math?: boolean;\n /** Enable syntax highlighting (default: true) */\n highlight?: boolean;\n /** Add data-source-line attributes for line anchors (default: true) */\n sourceLines?: boolean;\n /** Enable XSS sanitization (default: true) */\n sanitize?: boolean;\n /** Parse and strip frontmatter (default: true) */\n frontmatter?: boolean;\n}\n\nexport interface RenderResult {\n /** The rendered HTML string */\n html: string;\n /** Parsed frontmatter (empty object if none or disabled) */\n frontmatter: Record<string, unknown>;\n /** The markdown body with frontmatter stripped */\n body: string;\n}\n\n/**\n * Render a markdown string to HTML using the full Vantage pipeline.\n *\n * Features (all enabled by default):\n * - GitHub Flavored Markdown (tables, strikethrough, task lists)\n * - KaTeX math rendering ($$...$$ blocks)\n * - Syntax highlighting via highlight.js\n * - `data-source-line` attributes for line anchors\n * - XSS sanitization\n * - Heading slugs/anchors\n * - YAML/TOML frontmatter parsing\n *\n * Mermaid diagrams are NOT rendered server-side (they require a browser).\n * Mermaid code blocks are preserved as `<pre><code class=\"language-mermaid\">`.\n * Use the React `<MarkdownViewer>` component for client-side mermaid rendering.\n */\nexport async function renderMarkdown(\n content: string,\n options: RenderOptions = {},\n): Promise<RenderResult> {\n const {\n gfm = true,\n math = true,\n highlight = true,\n sourceLines = true,\n sanitize = true,\n frontmatter: parseFm = true,\n } = options;\n\n // Parse frontmatter\n let parsed: ParsedFrontmatter;\n if (parseFm) {\n parsed = parseFrontmatter(content);\n } else {\n parsed = { frontmatter: {}, body: content, format: \"none\" };\n }\n\n // Build the unified pipeline using a single chain.\n // We use `any` for the processor to avoid unified's strict generic\n // type constraints that make conditional plugin registration painful.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const remarkPlugins: [any, ...any[]][] = [];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const rehypePlugins: [any, ...any[]][] = [];\n\n if (gfm) remarkPlugins.push([remarkGfm, { singleTilde: false }]);\n if (math) remarkPlugins.push([remarkMath, { singleDollarTextMath: false }]);\n\n rehypePlugins.push([rehypeRaw]);\n if (sourceLines) rehypePlugins.push([rehypeSourceLines]);\n if (sanitize) rehypePlugins.push([rehypeSanitize, sanitizeSchema]);\n rehypePlugins.push([rehypeSlug]);\n if (highlight) rehypePlugins.push([rehypeHighlight]);\n if (math) rehypePlugins.push([rehypeKatex]);\n\n // Build the processor. We type as `any` because unified's generic\n // Processor type changes shape with every .use() call, making\n // conditional plugin registration impractical with strict types.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let processor: any = unified().use(remarkParse);\n for (const [plugin, ...args] of remarkPlugins) {\n processor = processor.use(plugin, ...args);\n }\n processor = processor.use(remarkRehype, { allowDangerousHtml: true });\n for (const [plugin, ...args] of rehypePlugins) {\n processor = processor.use(plugin, ...args);\n }\n processor = processor.use(rehypeStringify);\n\n const result = await processor.process(parsed.body);\n\n return {\n html: String(result),\n frontmatter: parsed.frontmatter,\n body: parsed.body,\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/rehypeSourceLines.ts","../src/sanitize.ts","../src/frontmatter.ts","../src/mermaidCache.ts","../src/mermaidLoader.ts","../src/MermaidDiagram.tsx","../src/FrontmatterDisplay.tsx","../src/scrollToLineAnchor.ts","../src/useLineAnchor.ts","../src/MarkdownViewer.tsx","../src/renderMarkdown.ts","../src/renderMermaidBlocks.ts","../src/resolveLinks.ts"],"names":["defaultSchema","parseTOML","YAML","jsxs","jsx","useEffect","useState","useRef","useMemo","Fragment","memo","HIGHLIGHT_CLASS","useCallback","ReactMarkdown","remarkGfm","remarkMath","rehypeRaw","rehypeSanitize","rehypeSlug","rehypeHighlight","rehypeKatex","unified","remarkParse","remarkRehype","rehypeStringify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAM,UAAA,uBAAiB,GAAA,CAAI;AAAA,EACzB,GAAA;AAAA,EACA,IAAA;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,MACtB;AAEA,MAAA,IAAI,QAAA,EAAU;AACZ,QAAA,MAAM,MAAA,GAAS,QAAA,CAAS,IAAA,EAAM,WAAW,CAAA;AACzC,QAAA,IAAI,WAAW,IAAA,EAAM;AACnB,UAAA,OAAO,SAAS,MAAM,CAAA,CAAA,CAAA;AAAA,QACxB;AACA,QAAA,OAAO,SAAS,IAAI,CAAA,CAAA,CAAA;AAAA,MACtB;AAGA,MAAA,MAAM,CAAC,QAAA,EAAU,QAAQ,CAAA,GAAI,IAAA,CAAK,MAAM,GAAG,CAAA;AAC3C,MAAA,MAAM,SAAA,GAAY,QAAA,CAAS,OAAA,CAAQ,OAAA,EAAS,EAAE,CAAA;AAC9C,MAAA,MAAM,eAAe,UAAA,GACjB,CAAA,EAAG,UAAU,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA,GAC1B,SAAA;AACJ,MAAA,MAAM,OAAO,QAAA,CAAS,QAAA,CAAS,GAAG,CAAA,GAAI,QAAA,GAAW,GAAG,QAAQ,CAAA,CAAA,CAAA;AAC5D,MAAA,MAAM,SAAA,GAAY,CAAA,EAAG,IAAI,CAAA,EAAG,YAAY,GAAG,QAAA,GAAW,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA;AAEzE,MAAA,OAAO,SAAS,SAAS,CAAA,CAAA,CAAA;AAAA,IAC3B;AAAA,GACF;AACF","file":"react.cjs","sourcesContent":["/**\n * Rehype plugin that adds `data-source-line` attributes to block-level\n * elements based on their position in the original markdown source.\n *\n * This enables GitHub-style line anchors (#L42, #L42-L50) by giving\n * each rendered block a traceable line number from the source.\n */\n\nimport type { Root, Element } from \"hast\";\nimport type { Plugin } from \"unified\";\n\nconst BLOCK_TAGS = new Set([\n \"p\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"li\",\n \"blockquote\",\n \"pre\",\n \"table\",\n \"tr\",\n \"ul\",\n \"ol\",\n \"hr\",\n \"div\",\n]);\n\nfunction visit(node: Root | Element) {\n if (\"children\" in node) {\n for (const child of node.children) {\n if (child.type === \"element\") {\n if (BLOCK_TAGS.has(child.tagName) && child.position?.start?.line) {\n child.properties = child.properties || {};\n child.properties[\"dataSourceLine\"] = child.position.start.line;\n }\n visit(child);\n }\n }\n }\n}\n\nconst rehypeSourceLines: Plugin<[], Root> = () => {\n return (tree: Root) => {\n visit(tree);\n };\n};\n\nexport default rehypeSourceLines;\n","/**\n * Sanitization schema for the rendering pipeline.\n * Allows GFM, KaTeX MathML, syntax highlighting classes, and\n * data-source-line attributes while blocking XSS vectors.\n */\n\nimport { defaultSchema } from \"rehype-sanitize\";\n\ntype Schema = typeof defaultSchema;\n\nexport const sanitizeSchema: Schema = {\n ...defaultSchema,\n tagNames: [\n ...(defaultSchema.tagNames || []),\n // KaTeX MathML elements\n \"math\",\n \"semantics\",\n \"mrow\",\n \"mi\",\n \"mo\",\n \"mn\",\n \"msup\",\n \"msub\",\n \"mfrac\",\n \"mover\",\n \"munder\",\n \"msqrt\",\n \"mroot\",\n \"mtable\",\n \"mtr\",\n \"mtd\",\n \"mtext\",\n \"mspace\",\n \"annotation\",\n // Other\n \"figure\",\n \"figcaption\",\n \"summary\",\n \"details\",\n ],\n attributes: {\n ...defaultSchema.attributes,\n \"*\": [\n ...(defaultSchema.attributes?.[\"*\"] || []),\n \"className\",\n \"style\",\n \"dataSourceLine\",\n ],\n code: [...(defaultSchema.attributes?.code || []), \"className\"],\n span: [...(defaultSchema.attributes?.span || []), \"className\", \"style\"],\n div: [...(defaultSchema.attributes?.div || []), \"className\", \"style\"],\n a: [...(defaultSchema.attributes?.a || []), \"id\", \"className\"],\n math: [\"xmlns\"],\n annotation: [\"encoding\"],\n img: [...(defaultSchema.attributes?.img || []), \"loading\"],\n td: [...(defaultSchema.attributes?.td || []), \"style\"],\n th: [...(defaultSchema.attributes?.th || []), \"style\"],\n },\n};\n","/**\n * Frontmatter parser for YAML (---) and TOML (+++) delimited content.\n * Works in both browser and server environments.\n */\n\nimport YAML from \"yaml\";\nimport { parse as parseTOML } from \"smol-toml\";\n\nexport type FrontmatterFormat = \"yaml\" | \"toml\" | \"none\";\n\nexport interface ParsedFrontmatter {\n frontmatter: Record<string, unknown>;\n body: string;\n format: FrontmatterFormat;\n}\n\n/**\n * Parse frontmatter from markdown content.\n * Supports YAML (delimited by ---) and TOML (delimited by +++).\n */\nexport function parseFrontmatter(content: string): ParsedFrontmatter {\n if (content.startsWith(\"+++\")) {\n return parseFrontmatterWithDelimiter(content, \"+++\", \"toml\");\n }\n if (content.startsWith(\"---\")) {\n return parseFrontmatterWithDelimiter(content, \"---\", \"yaml\");\n }\n return { frontmatter: {}, body: content, format: \"none\" };\n}\n\nfunction parseFrontmatterWithDelimiter(\n content: string,\n delimiter: string,\n format: \"yaml\" | \"toml\",\n): ParsedFrontmatter {\n const searchStart = delimiter.length;\n const endIndex = content.indexOf(`\\n${delimiter}`, searchStart);\n if (endIndex === -1) {\n return { frontmatter: {}, body: content, format: \"none\" };\n }\n\n const raw = content.slice(searchStart + 1, endIndex).trim();\n const bodyStart = endIndex + 1 + delimiter.length;\n const body = content.slice(bodyStart).replace(/^\\n/, \"\");\n\n try {\n const frontmatter =\n format === \"toml\"\n ? (parseTOML(raw) as Record<string, unknown>)\n : (YAML.parse(raw) as Record<string, unknown>);\n return { frontmatter: frontmatter || {}, body, format };\n } catch {\n return { frontmatter: {}, body: content, format: \"none\" };\n }\n}\n","// Global cache for rendered SVGs to prevent re-renders\nexport const svgCache = new Map<string, string>();\n\nexport function clearMermaidCache() {\n svgCache.clear();\n}\n","import type mermaidAPI from \"mermaid\";\n\nlet mermaidInstance: typeof mermaidAPI | null = null;\nlet mermaidLoading: Promise<typeof mermaidAPI> | null = null;\n\nconst isDark = () =>\n typeof document !== \"undefined\" &&\n document.documentElement.classList.contains(\"dark\");\n\nexport async function getMermaid(): Promise<typeof mermaidAPI> {\n if (mermaidInstance) return mermaidInstance;\n if (!mermaidLoading) {\n mermaidLoading = import(\"mermaid\").then((mod) => {\n const m = mod.default;\n m.initialize({\n startOnLoad: false,\n theme: isDark() ? \"dark\" : \"default\",\n securityLevel: \"strict\",\n suppressErrorRendering: true,\n });\n mermaidInstance = m;\n return m;\n });\n }\n return mermaidLoading;\n}\n\nexport function resetMermaidLoader() {\n mermaidInstance = null;\n mermaidLoading = null;\n}\n","import React, { useEffect, useState, useRef, useMemo, memo } from \"react\";\nimport { svgCache } from \"./mermaidCache.js\";\nimport { getMermaid } from \"./mermaidLoader.js\";\n\n// Inline SVG icons to avoid lucide-react dependency\nconst AlertTriangleIcon = () => (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"w-4 h-4 shrink-0\">\n <path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" /><path d=\"M12 9v4\" /><path d=\"M12 17h.01\" />\n </svg>\n);\n\nconst ChevronDownIcon = () => (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"w-3 h-3\">\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n);\n\nconst ChevronUpIcon = () => (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"w-3 h-3\">\n <path d=\"m18 15-6-6-6 6\" />\n </svg>\n);\n\nconst MaximizeIcon = () => (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"w-4 h-4 text-gray-600\">\n <polyline points=\"15 3 21 3 21 9\" /><polyline points=\"9 21 3 21 3 15\" /><line x1=\"21\" x2=\"14\" y1=\"3\" y2=\"10\" /><line x1=\"3\" x2=\"10\" y1=\"21\" y2=\"14\" />\n </svg>\n);\n\nconst CloseIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"w-5 h-5\">\n <path d=\"M18 6 6 18\" /><path d=\"m6 6 12 12\" />\n </svg>\n);\n\ninterface MermaidDiagramProps {\n code: string;\n}\n\nfunction extractErrorMessage(err: unknown): string {\n if (err instanceof Error) {\n const msg = err.message;\n const parseMatch = msg.match(\n /(?:Parse error|Syntax error|Error).*?(?:line \\d+.*)/i,\n );\n if (parseMatch) return parseMatch[0];\n return msg.split(\"\\n\")[0].slice(0, 200);\n }\n if (typeof err === \"string\") return err.split(\"\\n\")[0].slice(0, 200);\n return \"Unknown error\";\n}\n\n/** Simple modal for expanding diagrams */\nfunction DiagramModal({\n isOpen,\n onClose,\n children,\n}: {\n isOpen: boolean;\n onClose: () => void;\n children: React.ReactNode;\n}) {\n useEffect(() => {\n if (!isOpen) return;\n const handler = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onClose();\n };\n document.addEventListener(\"keydown\", handler);\n document.body.style.overflow = \"hidden\";\n return () => {\n document.removeEventListener(\"keydown\", handler);\n document.body.style.overflow = \"unset\";\n };\n }, [isOpen, onClose]);\n\n if (!isOpen) return null;\n\n return (\n <div\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4\"\n onClick={onClose}\n >\n <div\n className=\"bg-white rounded-lg shadow-xl w-full max-w-5xl max-h-[90vh] flex flex-col\"\n role=\"dialog\"\n aria-modal=\"true\"\n onClick={(e) => e.stopPropagation()}\n >\n <div className=\"flex items-center justify-between p-4 border-b\">\n <h2 className=\"text-lg font-semibold\">Mermaid Diagram</h2>\n <button\n onClick={onClose}\n className=\"p-1 hover:bg-gray-100 rounded-full transition-colors\"\n aria-label=\"Close modal\"\n >\n <CloseIcon />\n </button>\n </div>\n <div className=\"p-4 overflow-auto flex-1\">{children}</div>\n </div>\n </div>\n );\n}\n\nconst MermaidDiagramInner: React.FC<MermaidDiagramProps> = ({ code }) => {\n const hasCached = svgCache.has(code);\n const [svg, setSvg] = useState<string>(() => svgCache.get(code) || \"\");\n const [errorMessage, setErrorMessage] = useState<string | null>(null);\n const [showSource, setShowSource] = useState(false);\n const [isModalOpen, setIsModalOpen] = useState(false);\n const [isLoading, setIsLoading] = useState(!hasCached);\n const [minHeight, setMinHeight] = useState<string>(\"auto\");\n const containerRef = useRef<HTMLDivElement>(null);\n const lastHeightRef = useRef<number | null>(null);\n\n const stableId = useMemo(() => {\n let hash = 0;\n for (let i = 0; i < code.length; i++) {\n const char = code.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return `mermaid-${Math.abs(hash).toString(36)}`;\n }, [code]);\n\n useEffect(() => {\n if (hasCached) return;\n\n let mounted = true;\n\n const renderDiagram = async () => {\n try {\n if (containerRef.current) {\n const height = containerRef.current.offsetHeight;\n lastHeightRef.current = height;\n setMinHeight(`${height}px`);\n }\n\n const m = await getMermaid();\n const id = `${stableId}-${Date.now()}`;\n const { svg: renderedSvg } = await m.render(id, code);\n\n if (mounted) {\n svgCache.set(code, renderedSvg);\n setSvg(renderedSvg);\n setErrorMessage(null);\n setIsLoading(false);\n }\n } catch (err) {\n console.error(\"Mermaid render error:\", err);\n if (mounted) {\n setErrorMessage(extractErrorMessage(err));\n setIsLoading(false);\n }\n }\n };\n\n renderDiagram();\n return () => {\n mounted = false;\n };\n }, [code, stableId, hasCached]);\n\n if (errorMessage) {\n return (\n <div\n data-testid=\"mermaid-container\"\n className=\"my-4 rounded-md border border-yellow-300/40 bg-yellow-50/50 dark:border-yellow-700/40 dark:bg-yellow-950/20 overflow-hidden\"\n >\n <div className=\"flex items-center gap-2 px-4 py-2.5 text-sm text-yellow-800 dark:text-yellow-200\">\n <AlertTriangleIcon />\n <span className=\"font-medium\">Diagram syntax error</span>\n <span className=\"text-yellow-700/70 dark:text-yellow-300/60\">\n — {errorMessage}\n </span>\n </div>\n <div className=\"border-t border-yellow-300/30 dark:border-yellow-700/30\">\n <button\n onClick={() => setShowSource(!showSource)}\n className=\"flex items-center gap-1.5 px-4 py-1.5 text-xs text-yellow-700/60 dark:text-yellow-400/50 hover:text-yellow-800 dark:hover:text-yellow-300 transition-colors w-full\"\n >\n {showSource ? <ChevronUpIcon /> : <ChevronDownIcon />}\n {showSource ? \"Hide source\" : \"Show source\"}\n </button>\n {showSource && (\n <pre className=\"px-4 pb-3 text-xs font-mono text-yellow-800/70 dark:text-yellow-200/60 overflow-auto whitespace-pre-wrap\">\n {code}\n </pre>\n )}\n </div>\n </div>\n );\n }\n\n return (\n <>\n <div\n ref={containerRef}\n data-testid=\"mermaid-container\"\n className=\"relative group inline-block max-w-full\"\n style={{ minHeight: isLoading ? minHeight : \"auto\" }}\n >\n <div\n className={`mermaid flex justify-center my-4 overflow-x-auto transition-opacity duration-150 ${isLoading ? \"opacity-50\" : \"opacity-100\"}`}\n dangerouslySetInnerHTML={{ __html: svg }}\n />\n {svg && (\n <button\n onClick={() => setIsModalOpen(true)}\n className=\"absolute top-2 right-2 p-2 bg-white/90 shadow-sm border rounded-md opacity-0 group-hover:opacity-100 transition-opacity hover:bg-gray-50\"\n aria-label=\"Maximize diagram\"\n >\n <MaximizeIcon />\n </button>\n )}\n </div>\n\n <DiagramModal\n isOpen={isModalOpen}\n onClose={() => setIsModalOpen(false)}\n >\n <div\n className=\"flex justify-center items-center min-h-[50vh]\"\n dangerouslySetInnerHTML={{ __html: svg }}\n />\n </DiagramModal>\n </>\n );\n};\n\nexport const MermaidDiagram = memo(\n MermaidDiagramInner,\n (prevProps, nextProps) => prevProps.code === nextProps.code,\n);\n","import React, { memo } from \"react\";\n\n// Inline FileText icon\nconst FileTextIcon = () => (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"text-slate-400\">\n <path d=\"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z\" /><path d=\"M14 2v4a2 2 0 0 0 2 2h4\" /><path d=\"M10 9H8\" /><path d=\"M16 13H8\" /><path d=\"M16 17H8\" />\n </svg>\n);\n\ninterface FrontmatterDisplayProps {\n frontmatter: Record<string, unknown>;\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return (\n Array.isArray(value) && value.every((item) => typeof item === \"string\")\n );\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction formatValue(value: unknown): React.ReactNode {\n if (value instanceof Date) {\n return value.toISOString().split(\"T\")[0];\n }\n if (Array.isArray(value)) {\n return value.map(String).join(\", \");\n }\n if (typeof value === \"boolean\") {\n return value ? \"true\" : \"false\";\n }\n if (isPlainObject(value)) {\n return JSON.stringify(value, null, 2);\n }\n return String(value);\n}\n\nfunction TagList({ items }: { items: string[] }) {\n return (\n <div className=\"flex flex-wrap gap-1.5\">\n {items.map((item) => (\n <span\n key={item}\n className=\"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300\"\n >\n {item}\n </span>\n ))}\n </div>\n );\n}\n\nfunction ValueCell({ value }: { value: unknown }) {\n if (isStringArray(value) && value.length > 0) {\n return <TagList items={value} />;\n }\n if (isPlainObject(value)) {\n return (\n <pre className=\"bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-md px-3 py-2 text-xs font-mono overflow-x-auto text-slate-600 dark:text-slate-300\">\n {formatValue(value)}\n </pre>\n );\n }\n return <span className=\"font-medium\">{formatValue(value)}</span>;\n}\n\nfunction flattenEntries(entries: [string, unknown][]): [string, unknown][] {\n const result: [string, unknown][] = [];\n for (const [key, value] of entries) {\n if (key === \"taxonomies\" && isPlainObject(value)) {\n for (const [taxKey, taxVal] of Object.entries(value)) {\n result.push([taxKey, taxVal]);\n }\n } else if (key === \"extra\" && isPlainObject(value)) {\n for (const [extraKey, extraVal] of Object.entries(value)) {\n result.push([extraKey, extraVal]);\n }\n } else {\n result.push([key, value]);\n }\n }\n return result;\n}\n\nconst FrontmatterDisplayInner: React.FC<FrontmatterDisplayProps> = ({\n frontmatter,\n}) => {\n const raw = Object.entries(frontmatter);\n if (raw.length === 0) return null;\n\n const entries = flattenEntries(raw);\n\n return (\n <div className=\"mb-8 rounded-lg overflow-hidden bg-gradient-to-br from-slate-50 to-slate-100 dark:from-slate-800 dark:to-slate-800/80 border border-slate-200 dark:border-slate-700 shadow-sm\">\n <div className=\"px-4 py-2.5 bg-white/60 dark:bg-slate-900/40 border-b border-slate-200 dark:border-slate-700 flex items-center gap-2\">\n <FileTextIcon />\n <span className=\"text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider\">\n Metadata\n </span>\n </div>\n <div className=\"p-4\">\n <table className=\"w-full text-sm\">\n <tbody>\n {entries.map(([key, value]) => (\n <tr\n key={key}\n className=\"border-b border-slate-200/60 dark:border-slate-700/60 last:border-0\"\n >\n <td className=\"py-2 pr-4 font-medium text-slate-500 dark:text-slate-400 whitespace-nowrap align-top w-1/4 min-w-[100px]\">\n {key}\n </td>\n <td className=\"py-2 text-slate-800 dark:text-slate-200 align-top\">\n <ValueCell value={value} />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </div>\n );\n};\n\nexport const FrontmatterDisplay = memo(FrontmatterDisplayInner);\n","/**\n * Framework-agnostic line anchor utilities.\n * Parse GitHub-style line anchors (#L42, #L42-L50) and scroll/highlight\n * matching elements in a container.\n */\n\nconst HIGHLIGHT_CLASS = \"line-anchor-highlight\";\n\n/**\n * Parse a GitHub-style line anchor hash.\n * Supports: #L42, #L42-L50, #L42-50\n * Returns null if the hash is not a line anchor.\n */\nexport function parseLineAnchor(\n hash: string,\n): { start: number; end: number } | null {\n if (!hash) return null;\n const frag = hash.startsWith(\"#\") ? hash.slice(1) : hash;\n const match = frag.match(/^L(\\d+)(?:-L?(\\d+))?$/);\n if (!match) return null;\n\n const start = parseInt(match[1], 10);\n const end = match[2] ? parseInt(match[2], 10) : start;\n return { start: Math.min(start, end), end: Math.max(start, end) };\n}\n\n/**\n * Clear all line anchor highlights from a container.\n */\nexport function clearLineAnchorHighlights(container: HTMLElement): void {\n container.querySelectorAll(`.${HIGHLIGHT_CLASS}`).forEach((node) => {\n (node as HTMLElement).classList.remove(HIGHLIGHT_CLASS);\n });\n}\n\n/**\n * Scroll to and highlight line-anchored elements in a container.\n *\n * @param container - The DOM element containing rendered markdown\n * @param hash - The URL hash (e.g. \"#L42\" or \"#L42-L50\")\n * @returns A cleanup function that removes the highlights\n */\nexport function scrollToLineAnchor(\n container: HTMLElement,\n hash: string,\n): (() => void) | null {\n clearLineAnchorHighlights(container);\n\n const range = parseLineAnchor(hash);\n if (!range) return null;\n\n const blocks = container.querySelectorAll(\"[data-source-line]\");\n let firstMatch: HTMLElement | null = null;\n\n for (const block of blocks) {\n const line = parseInt(\n (block as HTMLElement).dataset.sourceLine || \"0\",\n 10,\n );\n if (line >= range.start && line <= range.end) {\n (block as HTMLElement).classList.add(HIGHLIGHT_CLASS);\n if (!firstMatch) firstMatch = block as HTMLElement;\n }\n }\n\n // If exact line not found, find the nearest block before the target line\n if (!firstMatch) {\n let closest: HTMLElement | null = null;\n let closestLine = 0;\n for (const block of blocks) {\n const line = parseInt(\n (block as HTMLElement).dataset.sourceLine || \"0\",\n 10,\n );\n if (line <= range.start && line > closestLine) {\n closestLine = line;\n closest = block as HTMLElement;\n }\n }\n if (closest) {\n closest.classList.add(HIGHLIGHT_CLASS);\n firstMatch = closest;\n }\n }\n\n // Scroll to the first highlighted element\n if (firstMatch) {\n requestAnimationFrame(() => {\n // Find the nearest scrollable ancestor\n const scrollParent = findScrollParent(container);\n if (scrollParent) {\n const offset =\n firstMatch!.getBoundingClientRect().top -\n scrollParent.getBoundingClientRect().top +\n scrollParent.scrollTop;\n scrollParent.scrollTo({ top: offset - 32, behavior: \"smooth\" });\n } else {\n firstMatch!.scrollIntoView({ behavior: \"smooth\", block: \"start\" });\n }\n });\n }\n\n return () => clearLineAnchorHighlights(container);\n}\n\nfunction findScrollParent(el: HTMLElement): HTMLElement | null {\n let node: HTMLElement | null = el;\n while (node) {\n const overflow = getComputedStyle(node).overflowY;\n if (overflow === \"auto\" || overflow === \"scroll\") return node;\n node = node.parentElement;\n }\n return null;\n}\n","import { useEffect, useCallback, type RefObject } from \"react\";\nimport {\n parseLineAnchor,\n clearLineAnchorHighlights,\n} from \"./scrollToLineAnchor.js\";\n\nconst HIGHLIGHT_CLASS = \"line-anchor-highlight\";\n\n/**\n * React hook that handles GitHub-style line anchors (#L42, #L42-L50).\n *\n * - Parses the URL hash for line references\n * - Finds block elements with matching `data-source-line` attributes\n * - Scrolls to and highlights them\n * - Dismisses on Escape or click on the highlight\n *\n * @param containerRef - Ref to the DOM element containing rendered markdown\n * @param hash - The current URL hash (e.g. \"#L42\", from location.hash or window.location.hash)\n */\nexport function useLineAnchor(\n containerRef: RefObject<HTMLElement | null>,\n hash: string,\n) {\n const clearHighlights = useCallback(() => {\n const el = containerRef.current;\n if (!el) return;\n clearLineAnchorHighlights(el);\n }, [containerRef]);\n\n // Apply highlights when hash changes\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n\n clearHighlights();\n\n const range = parseLineAnchor(hash);\n if (!range) return;\n\n const blocks = el.querySelectorAll(\"[data-source-line]\");\n let firstMatch: HTMLElement | null = null;\n\n for (const block of blocks) {\n const line = parseInt(\n (block as HTMLElement).dataset.sourceLine || \"0\",\n 10,\n );\n if (line >= range.start && line <= range.end) {\n (block as HTMLElement).classList.add(HIGHLIGHT_CLASS);\n if (!firstMatch) firstMatch = block as HTMLElement;\n }\n }\n\n // If exact line not found, find the nearest block before the target line\n if (!firstMatch) {\n let closest: HTMLElement | null = null;\n let closestLine = 0;\n for (const block of blocks) {\n const line = parseInt(\n (block as HTMLElement).dataset.sourceLine || \"0\",\n 10,\n );\n if (line <= range.start && line > closestLine) {\n closestLine = line;\n closest = block as HTMLElement;\n }\n }\n if (closest) {\n closest.classList.add(HIGHLIGHT_CLASS);\n firstMatch = closest;\n }\n }\n\n // Scroll to the first highlighted element\n if (firstMatch) {\n // Find the scrollable parent\n let scrollParent: HTMLElement | null = el;\n while (scrollParent) {\n const overflow = getComputedStyle(scrollParent).overflowY;\n if (overflow === \"auto\" || overflow === \"scroll\") break;\n scrollParent = scrollParent.parentElement;\n }\n if (scrollParent) {\n const target = firstMatch;\n requestAnimationFrame(() => {\n const offset =\n target.getBoundingClientRect().top -\n scrollParent!.getBoundingClientRect().top +\n scrollParent!.scrollTop;\n scrollParent!.scrollTo({ top: offset - 32, behavior: \"smooth\" });\n });\n }\n }\n }, [hash, containerRef, clearHighlights]);\n\n // Dismiss on Escape\n useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n clearHighlights();\n if (window.location.hash) {\n history.replaceState(null, \"\", window.location.pathname);\n }\n }\n };\n document.addEventListener(\"keydown\", handler);\n return () => document.removeEventListener(\"keydown\", handler);\n }, [clearHighlights]);\n\n // Dismiss on click on highlighted area\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n\n const handler = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n if (target.closest(`.${HIGHLIGHT_CLASS}`)) {\n clearHighlights();\n if (window.location.hash) {\n history.replaceState(null, \"\", window.location.pathname);\n }\n }\n };\n el.addEventListener(\"click\", handler);\n return () => el.removeEventListener(\"click\", handler);\n }, [containerRef, clearHighlights]);\n\n return { clearHighlights };\n}\n","/**\n * React markdown viewer component.\n *\n * Renders markdown with the full Vantage pipeline: GFM, math, syntax\n * highlighting, mermaid diagrams, line anchors, and frontmatter display.\n *\n * This is a standalone component with no dependency on Vantage's stores,\n * router, or review system.\n */\n\nimport React, { memo, useCallback, useMemo, useRef } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport rehypeRaw from \"rehype-raw\";\nimport rehypeSanitize from \"rehype-sanitize\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeSlug from \"rehype-slug\";\nimport rehypeSourceLines from \"./rehypeSourceLines.js\";\nimport { sanitizeSchema } from \"./sanitize.js\";\nimport { parseFrontmatter } from \"./frontmatter.js\";\nimport { MermaidDiagram } from \"./MermaidDiagram.js\";\nimport { FrontmatterDisplay } from \"./FrontmatterDisplay.js\";\nimport { useLineAnchor } from \"./useLineAnchor.js\";\n\nexport interface MarkdownViewerProps {\n /** Markdown content to render */\n content: string;\n /** Current file path (used for resolving relative links and images) */\n currentPath?: string;\n /** URL hash for line anchor highlighting (e.g. \"#L42\") */\n hash?: string;\n /** Base URL for resolving relative links */\n baseUrl?: string;\n /** Base URL for loading images via API (e.g. \"/api\") */\n imageApiBase?: string;\n /** Additional CSS class names */\n className?: string;\n /** Callback when an internal link is clicked */\n onNavigate?: (path: string) => void;\n}\n\nconst MarkdownViewerInner: React.FC<MarkdownViewerProps> = ({\n content,\n currentPath = \"\",\n hash = \"\",\n baseUrl = \"/\",\n imageApiBase,\n className,\n onNavigate,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Line anchor highlighting\n useLineAnchor(containerRef, hash);\n\n // Parse frontmatter from content\n const { frontmatter, body } = useMemo(() => {\n return parseFrontmatter(content);\n }, [content]);\n\n const handleLinkClick = useCallback(\n (e: React.MouseEvent<HTMLAnchorElement>, href: string) => {\n // Anchor links within the same doc\n if (href.startsWith(\"#\")) {\n e.preventDefault();\n const id = href.slice(1);\n const el = document.getElementById(id);\n if (el) {\n const scrollContainer =\n el.closest(\"[data-content-scroll]\") ||\n el.closest(\".overflow-y-auto\");\n if (scrollContainer) {\n const offset =\n el.getBoundingClientRect().top -\n scrollContainer.getBoundingClientRect().top +\n scrollContainer.scrollTop;\n scrollContainer.scrollTo({ top: offset - 16 });\n } else {\n el.scrollIntoView();\n }\n }\n return;\n }\n\n // External links — let the browser handle them\n if (href.startsWith(\"http\") || href.startsWith(\"mailto:\")) return;\n\n // Internal links — delegate to onNavigate if provided\n if (onNavigate) {\n // Respect Ctrl+click, Cmd+click\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n\n e.preventDefault();\n const [pathPart, hashPart] = href.split(\"#\");\n const parts = currentPath.split(\"/\");\n parts.pop();\n const dir = parts.join(\"/\");\n const cleanHref = pathPart.replace(/^\\.\\//, \"\");\n const resolvedPath = dir ? `${dir}/${cleanHref}` : cleanHref;\n onNavigate(resolvedPath + (hashPart ? `#${hashPart}` : \"\"));\n }\n },\n [currentPath, onNavigate],\n );\n\n const resolveHref = useCallback(\n (href: string | undefined): string => {\n if (!href) return \"\";\n if (\n href.startsWith(\"http\") ||\n href.startsWith(\"mailto:\") ||\n href.startsWith(\"#\") ||\n href.startsWith(\"/\")\n ) {\n return href;\n }\n\n const [pathPart, hashPart] = href.split(\"#\");\n const parts = currentPath.split(\"/\");\n parts.pop();\n const dir = parts.join(\"/\");\n const cleanHref = pathPart.replace(/^\\.\\//, \"\");\n const resolvedPath = dir ? `${dir}/${cleanHref}` : cleanHref;\n return `${baseUrl}${resolvedPath}${hashPart ? `#${hashPart}` : \"\"}`;\n },\n [currentPath, baseUrl],\n );\n\n const transformImageUri = useCallback(\n (uri: string, key?: string) => {\n if (key === \"href\") return uri;\n if (uri.startsWith(\"http\") || uri.startsWith(\"data:\")) return uri;\n\n // Resolve relative path based on currentPath\n const parts = currentPath.split(\"/\");\n parts.pop();\n const dir = parts.join(\"/\");\n const resolvedPath = dir ? `${dir}/${uri}` : uri;\n\n if (imageApiBase) {\n return `${imageApiBase}/content?path=${encodeURIComponent(resolvedPath)}`;\n }\n return `${baseUrl}${resolvedPath}`;\n },\n [currentPath, baseUrl, imageApiBase],\n );\n\n const markdownComponents = useMemo(\n () => ({\n a({\n href,\n children,\n ...props\n }: {\n href?: string;\n children?: React.ReactNode;\n } & React.AnchorHTMLAttributes<HTMLAnchorElement>) {\n const resolvedHref = resolveHref(href);\n return (\n <a\n href={resolvedHref}\n onClick={(e) => href && handleLinkClick(e, href)}\n {...props}\n >\n {children}\n </a>\n );\n },\n code(\n props: {\n children?: React.ReactNode;\n className?: string;\n } & React.HTMLAttributes<HTMLElement>,\n ) {\n const { children, className: codeClassName, ...rest } = props;\n const match = /language-(\\w+)/.exec(codeClassName || \"\");\n if (match && match[1] === \"mermaid\") {\n return <MermaidDiagram code={String(children).replace(/\\n$/, \"\")} />;\n }\n return (\n <code className={codeClassName} {...rest}>\n {children}\n </code>\n );\n },\n }),\n [handleLinkClick, resolveHref],\n );\n\n const proseClasses = [\n \"prose prose-slate dark:prose-invert max-w-none\",\n \"prose-headings:font-semibold prose-headings:tracking-tight prose-headings:text-slate-900 dark:prose-headings:text-slate-100\",\n \"prose-h1:text-[2em] prose-h1:mb-3 prose-h1:pb-[0.3em] prose-h1:border-b prose-h1:border-slate-200 dark:prose-h1:border-slate-700\",\n \"prose-h2:text-[1.5em] prose-h2:mt-6 prose-h2:mb-3 prose-h2:pb-[0.3em] prose-h2:border-b prose-h2:border-slate-200 dark:prose-h2:border-slate-700\",\n \"prose-h3:text-[1.25em] prose-h3:mt-6 prose-h3:mb-2\",\n \"prose-h4:text-[1em] prose-h4:mt-6 prose-h4:mb-2\",\n \"prose-p:text-slate-700 dark:prose-p:text-slate-300 prose-p:leading-[1.5] prose-p:my-[16px]\",\n \"prose-ul:my-[16px] prose-ul:list-disc prose-li:my-0.5 prose-li:marker:text-slate-900 dark:prose-li:marker:text-slate-300\",\n \"prose-ol:my-[16px] prose-li:marker:text-slate-900 dark:prose-li:marker:text-slate-300\",\n \"prose-pre:bg-slate-50 dark:prose-pre:bg-slate-800 prose-pre:border prose-pre:border-slate-200 dark:prose-pre:border-slate-700 prose-pre:p-4 prose-pre:rounded-md prose-pre:text-[85%] prose-pre:leading-[1.45]\",\n \"prose-a:text-blue-600 dark:prose-a:text-blue-400 prose-a:no-underline hover:prose-a:underline\",\n \"prose-img:rounded-lg prose-img:my-4\",\n \"prose-blockquote:border-l-[0.25em] prose-blockquote:border-slate-300 dark:prose-blockquote:border-slate-600 prose-blockquote:pl-4 prose-blockquote:text-slate-600 dark:prose-blockquote:text-slate-400 prose-blockquote:italic\",\n \"prose-code:before:content-none prose-code:after:content-none\",\n \"prose-code:bg-slate-100 dark:prose-code:bg-slate-800 prose-code:px-[0.4em] prose-code:py-[0.2em] prose-code:rounded-md prose-code:text-slate-800 dark:prose-code:text-slate-200 prose-code:font-mono prose-code:text-[85%] prose-code:font-normal prose-code:border prose-code:border-slate-200/50 dark:prose-code:border-slate-700/50\",\n \"prose-table:text-sm\",\n \"prose-th:px-3 prose-th:py-1.5 prose-th:border prose-th:border-slate-200 dark:prose-th:border-slate-700\",\n \"prose-td:px-3 prose-td:py-1.5 prose-td:border prose-td:border-slate-200 dark:prose-td:border-slate-700\",\n ].join(\" \");\n\n return (\n <div\n ref={containerRef}\n className={className ? `${proseClasses} ${className}` : proseClasses}\n >\n <FrontmatterDisplay frontmatter={frontmatter} />\n <ReactMarkdown\n remarkPlugins={[\n [remarkGfm, { singleTilde: false }],\n [remarkMath, { singleDollarTextMath: false }],\n ]}\n rehypePlugins={[\n rehypeRaw,\n rehypeSourceLines,\n [rehypeSanitize, sanitizeSchema],\n rehypeSlug,\n rehypeHighlight,\n rehypeKatex,\n ]}\n urlTransform={transformImageUri}\n components={markdownComponents}\n >\n {body}\n </ReactMarkdown>\n </div>\n );\n};\n\nexport const MarkdownViewer = memo(\n MarkdownViewerInner,\n (prevProps, nextProps) =>\n prevProps.content === nextProps.content &&\n prevProps.currentPath === nextProps.currentPath &&\n prevProps.hash === nextProps.hash &&\n prevProps.className === nextProps.className,\n);\n","/**\n * Framework-agnostic markdown -> HTML rendering pipeline.\n * Uses the same remark/rehype chain as the Vantage viewer.\n */\n\nimport { unified } from \"unified\";\nimport remarkParse from \"remark-parse\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport remarkRehype from \"remark-rehype\";\nimport rehypeRaw from \"rehype-raw\";\nimport rehypeSanitize from \"rehype-sanitize\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeSlug from \"rehype-slug\";\nimport rehypeStringify from \"rehype-stringify\";\nimport rehypeSourceLines from \"./rehypeSourceLines.js\";\nimport { sanitizeSchema } from \"./sanitize.js\";\nimport { parseFrontmatter } from \"./frontmatter.js\";\nimport type { ParsedFrontmatter } from \"./frontmatter.js\";\n\nexport interface RenderOptions {\n /** Enable GFM tables, strikethrough, task lists (default: true) */\n gfm?: boolean;\n /** Enable KaTeX math rendering (default: true) */\n math?: boolean;\n /** Enable syntax highlighting (default: true) */\n highlight?: boolean;\n /** Add data-source-line attributes for line anchors (default: true) */\n sourceLines?: boolean;\n /** Enable XSS sanitization (default: true) */\n sanitize?: boolean;\n /** Parse and strip frontmatter (default: true) */\n frontmatter?: boolean;\n}\n\nexport interface RenderResult {\n /** The rendered HTML string */\n html: string;\n /** Parsed frontmatter (empty object if none or disabled) */\n frontmatter: Record<string, unknown>;\n /** The markdown body with frontmatter stripped */\n body: string;\n}\n\n/**\n * Render a markdown string to HTML using the full Vantage pipeline.\n *\n * Features (all enabled by default):\n * - GitHub Flavored Markdown (tables, strikethrough, task lists)\n * - KaTeX math rendering ($$...$$ blocks)\n * - Syntax highlighting via highlight.js\n * - `data-source-line` attributes for line anchors\n * - XSS sanitization\n * - Heading slugs/anchors\n * - YAML/TOML frontmatter parsing\n *\n * Mermaid diagrams are NOT rendered server-side (they require a browser).\n * Mermaid code blocks are preserved as `<pre><code class=\"language-mermaid\">`.\n * Use the React `<MarkdownViewer>` component for client-side mermaid rendering.\n */\nexport async function renderMarkdown(\n content: string,\n options: RenderOptions = {},\n): Promise<RenderResult> {\n const {\n gfm = true,\n math = true,\n highlight = true,\n sourceLines = true,\n sanitize = true,\n frontmatter: parseFm = true,\n } = options;\n\n // Parse frontmatter\n let parsed: ParsedFrontmatter;\n if (parseFm) {\n parsed = parseFrontmatter(content);\n } else {\n parsed = { frontmatter: {}, body: content, format: \"none\" };\n }\n\n // Build the unified pipeline using a single chain.\n // We use `any` for the processor to avoid unified's strict generic\n // type constraints that make conditional plugin registration painful.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const remarkPlugins: [any, ...any[]][] = [];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const rehypePlugins: [any, ...any[]][] = [];\n\n if (gfm) remarkPlugins.push([remarkGfm, { singleTilde: false }]);\n if (math) remarkPlugins.push([remarkMath, { singleDollarTextMath: false }]);\n\n rehypePlugins.push([rehypeRaw]);\n if (sourceLines) rehypePlugins.push([rehypeSourceLines]);\n if (sanitize) rehypePlugins.push([rehypeSanitize, sanitizeSchema]);\n rehypePlugins.push([rehypeSlug]);\n if (highlight) rehypePlugins.push([rehypeHighlight]);\n if (math) rehypePlugins.push([rehypeKatex]);\n\n // Build the processor. We type as `any` because unified's generic\n // Processor type changes shape with every .use() call, making\n // conditional plugin registration impractical with strict types.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let processor: any = unified().use(remarkParse);\n for (const [plugin, ...args] of remarkPlugins) {\n processor = processor.use(plugin, ...args);\n }\n processor = processor.use(remarkRehype, { allowDangerousHtml: true });\n for (const [plugin, ...args] of rehypePlugins) {\n processor = processor.use(plugin, ...args);\n }\n processor = processor.use(rehypeStringify);\n\n const result = await processor.process(parsed.body);\n\n return {\n html: String(result),\n frontmatter: parsed.frontmatter,\n body: parsed.body,\n };\n}\n","/**\n * Client-side utility to find and render mermaid code blocks in a container.\n *\n * After calling `renderMarkdown()`, mermaid blocks come through as\n * `<pre><code class=\"language-mermaid\">...</code></pre>`. This function\n * finds those blocks and replaces them with rendered SVG diagrams.\n *\n * Framework-agnostic — works in any browser environment.\n */\n\nimport { svgCache } from \"./mermaidCache.js\";\nimport { getMermaid } from \"./mermaidLoader.js\";\n\nexport interface RenderMermaidOptions {\n /** CSS class to add to the SVG wrapper div (default: \"mermaid\") */\n className?: string;\n /** Called when a diagram fails to render */\n onError?: (code: string, error: Error) => void;\n}\n\n/**\n * Find all `<pre><code class=\"language-mermaid\">` blocks in a container\n * and replace them with rendered SVG diagrams.\n *\n * @param container - DOM element containing rendered markdown HTML\n * @param options - Optional configuration\n * @returns Promise that resolves when all diagrams are rendered\n *\n * @example\n * ```ts\n * import { renderMarkdown, renderMermaidBlocks } from \"vantage-md\";\n *\n * const { html } = await renderMarkdown(content);\n * container.innerHTML = html;\n * await renderMermaidBlocks(container);\n * ```\n */\nexport async function renderMermaidBlocks(\n container: HTMLElement,\n options: RenderMermaidOptions = {},\n): Promise<void> {\n const { className = \"mermaid\", onError } = options;\n\n const codeBlocks = container.querySelectorAll(\n 'pre > code.language-mermaid, pre > code[class*=\"language-mermaid\"]',\n );\n if (codeBlocks.length === 0) return;\n\n const mermaid = await getMermaid();\n\n const renderPromises = Array.from(codeBlocks).map(async (codeEl) => {\n const preEl = codeEl.parentElement;\n if (!preEl) return;\n\n const code = codeEl.textContent || \"\";\n if (!code.trim()) return;\n\n // Check cache first\n const cached = svgCache.get(code);\n if (cached) {\n replaceWithSvg(preEl, cached, className);\n return;\n }\n\n try {\n // Generate a stable ID from code hash\n let hash = 0;\n for (let i = 0; i < code.length; i++) {\n hash = (hash << 5) - hash + code.charCodeAt(i);\n hash = hash & hash;\n }\n const id = `mermaid-${Math.abs(hash).toString(36)}-${Date.now()}`;\n\n const { svg } = await mermaid.render(id, code);\n svgCache.set(code, svg);\n replaceWithSvg(preEl, svg, className);\n } catch (err) {\n if (onError) {\n onError(code, err instanceof Error ? err : new Error(String(err)));\n }\n }\n });\n\n await Promise.all(renderPromises);\n}\n\nfunction replaceWithSvg(\n preEl: HTMLElement,\n svg: string,\n className: string,\n): void {\n const wrapper = document.createElement(\"div\");\n wrapper.className = className;\n wrapper.innerHTML = svg;\n preEl.replaceWith(wrapper);\n}\n","/**\n * Rewrite relative links in rendered markdown HTML.\n *\n * After `renderMarkdown()` produces HTML, relative `href` values need to\n * be mapped to the consumer's routing structure. This utility handles that\n * without requiring a DOM — it operates on the HTML string directly.\n */\n\nexport interface ResolveLinkOptions {\n /** Base path to prepend to relative links (default: \"/\") */\n basePath?: string;\n /**\n * Custom rewriter function. Called for every relative href.\n * Return the rewritten href, or null to leave it unchanged.\n * If provided, basePath is ignored.\n */\n rewriter?: (href: string, currentPath: string) => string | null;\n /** Current file path — used to resolve relative references like `./other.md` */\n currentPath?: string;\n}\n\n/**\n * Rewrite relative links in rendered HTML.\n *\n * Processes all `href=\"...\"` attributes, skipping:\n * - Absolute URLs (http://, https://, mailto:, etc.)\n * - Anchor-only links (#section)\n * - Already-absolute paths (/path/to/file)\n *\n * @example\n * ```ts\n * import { renderMarkdown, resolveLinks } from \"vantage-md\";\n *\n * const { html } = await renderMarkdown(content);\n *\n * // Simple: prepend a base path\n * const resolved = resolveLinks(html, { basePath: \"/docs/\", currentPath: \"guides/setup.md\" });\n *\n * // Custom: full control over link rewriting\n * const resolved = resolveLinks(html, {\n * currentPath: \"guides/setup.md\",\n * rewriter: (href, currentPath) => `/kb/${currentPath}/../${href}`,\n * });\n * ```\n */\nexport function resolveLinks(\n html: string,\n options: ResolveLinkOptions = {},\n): string {\n const { basePath = \"/\", rewriter, currentPath = \"\" } = options;\n\n // Resolve the directory of the current file\n const parts = currentPath.split(\"/\");\n parts.pop(); // remove filename\n const currentDir = parts.join(\"/\");\n\n return html.replace(\n /href=\"([^\"]*?)\"/g,\n (_match: string, href: string): string => {\n // Skip absolute URLs, anchors, and already-absolute paths\n if (\n href.startsWith(\"http://\") ||\n href.startsWith(\"https://\") ||\n href.startsWith(\"mailto:\") ||\n href.startsWith(\"data:\") ||\n href.startsWith(\"#\") ||\n href.startsWith(\"/\")\n ) {\n return `href=\"${href}\"`;\n }\n\n if (rewriter) {\n const result = rewriter(href, currentPath);\n if (result !== null) {\n return `href=\"${result}\"`;\n }\n return `href=\"${href}\"`;\n }\n\n // Default: resolve relative to currentPath, prepend basePath\n const [pathPart, hashPart] = href.split(\"#\");\n const cleanHref = pathPart.replace(/^\\.\\//, \"\");\n const resolvedPath = currentDir\n ? `${currentDir}/${cleanHref}`\n : cleanHref;\n const base = basePath.endsWith(\"/\") ? basePath : `${basePath}/`;\n const finalHref = `${base}${resolvedPath}${hashPart ? `#${hashPart}` : \"\"}`;\n\n return `href=\"${finalHref}\"`;\n },\n );\n}\n"]}
package/dist/react.d.cts CHANGED
@@ -162,4 +162,83 @@ declare function parseFrontmatter(content: string): ParsedFrontmatter;
162
162
  type Schema = typeof defaultSchema;
163
163
  declare const sanitizeSchema: Schema;
164
164
 
165
- export { FrontmatterDisplay, type FrontmatterFormat, MarkdownViewer, type MarkdownViewerProps, MermaidDiagram, type ParsedFrontmatter, type RenderOptions, type RenderResult, clearLineAnchorHighlights, parseFrontmatter, parseLineAnchor, rehypeSourceLines, renderMarkdown, sanitizeSchema, scrollToLineAnchor, useLineAnchor };
165
+ /**
166
+ * Client-side utility to find and render mermaid code blocks in a container.
167
+ *
168
+ * After calling `renderMarkdown()`, mermaid blocks come through as
169
+ * `<pre><code class="language-mermaid">...</code></pre>`. This function
170
+ * finds those blocks and replaces them with rendered SVG diagrams.
171
+ *
172
+ * Framework-agnostic — works in any browser environment.
173
+ */
174
+ interface RenderMermaidOptions {
175
+ /** CSS class to add to the SVG wrapper div (default: "mermaid") */
176
+ className?: string;
177
+ /** Called when a diagram fails to render */
178
+ onError?: (code: string, error: Error) => void;
179
+ }
180
+ /**
181
+ * Find all `<pre><code class="language-mermaid">` blocks in a container
182
+ * and replace them with rendered SVG diagrams.
183
+ *
184
+ * @param container - DOM element containing rendered markdown HTML
185
+ * @param options - Optional configuration
186
+ * @returns Promise that resolves when all diagrams are rendered
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * import { renderMarkdown, renderMermaidBlocks } from "vantage-md";
191
+ *
192
+ * const { html } = await renderMarkdown(content);
193
+ * container.innerHTML = html;
194
+ * await renderMermaidBlocks(container);
195
+ * ```
196
+ */
197
+ declare function renderMermaidBlocks(container: HTMLElement, options?: RenderMermaidOptions): Promise<void>;
198
+
199
+ /**
200
+ * Rewrite relative links in rendered markdown HTML.
201
+ *
202
+ * After `renderMarkdown()` produces HTML, relative `href` values need to
203
+ * be mapped to the consumer's routing structure. This utility handles that
204
+ * without requiring a DOM — it operates on the HTML string directly.
205
+ */
206
+ interface ResolveLinkOptions {
207
+ /** Base path to prepend to relative links (default: "/") */
208
+ basePath?: string;
209
+ /**
210
+ * Custom rewriter function. Called for every relative href.
211
+ * Return the rewritten href, or null to leave it unchanged.
212
+ * If provided, basePath is ignored.
213
+ */
214
+ rewriter?: (href: string, currentPath: string) => string | null;
215
+ /** Current file path — used to resolve relative references like `./other.md` */
216
+ currentPath?: string;
217
+ }
218
+ /**
219
+ * Rewrite relative links in rendered HTML.
220
+ *
221
+ * Processes all `href="..."` attributes, skipping:
222
+ * - Absolute URLs (http://, https://, mailto:, etc.)
223
+ * - Anchor-only links (#section)
224
+ * - Already-absolute paths (/path/to/file)
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * import { renderMarkdown, resolveLinks } from "vantage-md";
229
+ *
230
+ * const { html } = await renderMarkdown(content);
231
+ *
232
+ * // Simple: prepend a base path
233
+ * const resolved = resolveLinks(html, { basePath: "/docs/", currentPath: "guides/setup.md" });
234
+ *
235
+ * // Custom: full control over link rewriting
236
+ * const resolved = resolveLinks(html, {
237
+ * currentPath: "guides/setup.md",
238
+ * rewriter: (href, currentPath) => `/kb/${currentPath}/../${href}`,
239
+ * });
240
+ * ```
241
+ */
242
+ declare function resolveLinks(html: string, options?: ResolveLinkOptions): string;
243
+
244
+ export { FrontmatterDisplay, type FrontmatterFormat, MarkdownViewer, type MarkdownViewerProps, MermaidDiagram, type ParsedFrontmatter, type RenderMermaidOptions, type RenderOptions, type RenderResult, type ResolveLinkOptions, clearLineAnchorHighlights, parseFrontmatter, parseLineAnchor, rehypeSourceLines, renderMarkdown, renderMermaidBlocks, resolveLinks, sanitizeSchema, scrollToLineAnchor, useLineAnchor };
package/dist/react.d.ts CHANGED
@@ -162,4 +162,83 @@ declare function parseFrontmatter(content: string): ParsedFrontmatter;
162
162
  type Schema = typeof defaultSchema;
163
163
  declare const sanitizeSchema: Schema;
164
164
 
165
- export { FrontmatterDisplay, type FrontmatterFormat, MarkdownViewer, type MarkdownViewerProps, MermaidDiagram, type ParsedFrontmatter, type RenderOptions, type RenderResult, clearLineAnchorHighlights, parseFrontmatter, parseLineAnchor, rehypeSourceLines, renderMarkdown, sanitizeSchema, scrollToLineAnchor, useLineAnchor };
165
+ /**
166
+ * Client-side utility to find and render mermaid code blocks in a container.
167
+ *
168
+ * After calling `renderMarkdown()`, mermaid blocks come through as
169
+ * `<pre><code class="language-mermaid">...</code></pre>`. This function
170
+ * finds those blocks and replaces them with rendered SVG diagrams.
171
+ *
172
+ * Framework-agnostic — works in any browser environment.
173
+ */
174
+ interface RenderMermaidOptions {
175
+ /** CSS class to add to the SVG wrapper div (default: "mermaid") */
176
+ className?: string;
177
+ /** Called when a diagram fails to render */
178
+ onError?: (code: string, error: Error) => void;
179
+ }
180
+ /**
181
+ * Find all `<pre><code class="language-mermaid">` blocks in a container
182
+ * and replace them with rendered SVG diagrams.
183
+ *
184
+ * @param container - DOM element containing rendered markdown HTML
185
+ * @param options - Optional configuration
186
+ * @returns Promise that resolves when all diagrams are rendered
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * import { renderMarkdown, renderMermaidBlocks } from "vantage-md";
191
+ *
192
+ * const { html } = await renderMarkdown(content);
193
+ * container.innerHTML = html;
194
+ * await renderMermaidBlocks(container);
195
+ * ```
196
+ */
197
+ declare function renderMermaidBlocks(container: HTMLElement, options?: RenderMermaidOptions): Promise<void>;
198
+
199
+ /**
200
+ * Rewrite relative links in rendered markdown HTML.
201
+ *
202
+ * After `renderMarkdown()` produces HTML, relative `href` values need to
203
+ * be mapped to the consumer's routing structure. This utility handles that
204
+ * without requiring a DOM — it operates on the HTML string directly.
205
+ */
206
+ interface ResolveLinkOptions {
207
+ /** Base path to prepend to relative links (default: "/") */
208
+ basePath?: string;
209
+ /**
210
+ * Custom rewriter function. Called for every relative href.
211
+ * Return the rewritten href, or null to leave it unchanged.
212
+ * If provided, basePath is ignored.
213
+ */
214
+ rewriter?: (href: string, currentPath: string) => string | null;
215
+ /** Current file path — used to resolve relative references like `./other.md` */
216
+ currentPath?: string;
217
+ }
218
+ /**
219
+ * Rewrite relative links in rendered HTML.
220
+ *
221
+ * Processes all `href="..."` attributes, skipping:
222
+ * - Absolute URLs (http://, https://, mailto:, etc.)
223
+ * - Anchor-only links (#section)
224
+ * - Already-absolute paths (/path/to/file)
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * import { renderMarkdown, resolveLinks } from "vantage-md";
229
+ *
230
+ * const { html } = await renderMarkdown(content);
231
+ *
232
+ * // Simple: prepend a base path
233
+ * const resolved = resolveLinks(html, { basePath: "/docs/", currentPath: "guides/setup.md" });
234
+ *
235
+ * // Custom: full control over link rewriting
236
+ * const resolved = resolveLinks(html, {
237
+ * currentPath: "guides/setup.md",
238
+ * rewriter: (href, currentPath) => `/kb/${currentPath}/../${href}`,
239
+ * });
240
+ * ```
241
+ */
242
+ declare function resolveLinks(html: string, options?: ResolveLinkOptions): string;
243
+
244
+ export { FrontmatterDisplay, type FrontmatterFormat, MarkdownViewer, type MarkdownViewerProps, MermaidDiagram, type ParsedFrontmatter, type RenderMermaidOptions, type RenderOptions, type RenderResult, type ResolveLinkOptions, clearLineAnchorHighlights, parseFrontmatter, parseLineAnchor, rehypeSourceLines, renderMarkdown, renderMermaidBlocks, resolveLinks, sanitizeSchema, scrollToLineAnchor, useLineAnchor };
package/dist/react.js CHANGED
@@ -821,6 +821,78 @@ async function renderMarkdown(content, options = {}) {
821
821
  };
822
822
  }
823
823
 
824
- export { FrontmatterDisplay, MarkdownViewer, MermaidDiagram, clearLineAnchorHighlights, parseFrontmatter, parseLineAnchor, rehypeSourceLines_default as rehypeSourceLines, renderMarkdown, sanitizeSchema, scrollToLineAnchor, useLineAnchor };
824
+ // src/renderMermaidBlocks.ts
825
+ async function renderMermaidBlocks(container, options = {}) {
826
+ const { className = "mermaid", onError } = options;
827
+ const codeBlocks = container.querySelectorAll(
828
+ 'pre > code.language-mermaid, pre > code[class*="language-mermaid"]'
829
+ );
830
+ if (codeBlocks.length === 0) return;
831
+ const mermaid = await getMermaid();
832
+ const renderPromises = Array.from(codeBlocks).map(async (codeEl) => {
833
+ const preEl = codeEl.parentElement;
834
+ if (!preEl) return;
835
+ const code = codeEl.textContent || "";
836
+ if (!code.trim()) return;
837
+ const cached = svgCache.get(code);
838
+ if (cached) {
839
+ replaceWithSvg(preEl, cached, className);
840
+ return;
841
+ }
842
+ try {
843
+ let hash = 0;
844
+ for (let i = 0; i < code.length; i++) {
845
+ hash = (hash << 5) - hash + code.charCodeAt(i);
846
+ hash = hash & hash;
847
+ }
848
+ const id = `mermaid-${Math.abs(hash).toString(36)}-${Date.now()}`;
849
+ const { svg } = await mermaid.render(id, code);
850
+ svgCache.set(code, svg);
851
+ replaceWithSvg(preEl, svg, className);
852
+ } catch (err) {
853
+ if (onError) {
854
+ onError(code, err instanceof Error ? err : new Error(String(err)));
855
+ }
856
+ }
857
+ });
858
+ await Promise.all(renderPromises);
859
+ }
860
+ function replaceWithSvg(preEl, svg, className) {
861
+ const wrapper = document.createElement("div");
862
+ wrapper.className = className;
863
+ wrapper.innerHTML = svg;
864
+ preEl.replaceWith(wrapper);
865
+ }
866
+
867
+ // src/resolveLinks.ts
868
+ function resolveLinks(html, options = {}) {
869
+ const { basePath = "/", rewriter, currentPath = "" } = options;
870
+ const parts = currentPath.split("/");
871
+ parts.pop();
872
+ const currentDir = parts.join("/");
873
+ return html.replace(
874
+ /href="([^"]*?)"/g,
875
+ (_match, href) => {
876
+ if (href.startsWith("http://") || href.startsWith("https://") || href.startsWith("mailto:") || href.startsWith("data:") || href.startsWith("#") || href.startsWith("/")) {
877
+ return `href="${href}"`;
878
+ }
879
+ if (rewriter) {
880
+ const result = rewriter(href, currentPath);
881
+ if (result !== null) {
882
+ return `href="${result}"`;
883
+ }
884
+ return `href="${href}"`;
885
+ }
886
+ const [pathPart, hashPart] = href.split("#");
887
+ const cleanHref = pathPart.replace(/^\.\//, "");
888
+ const resolvedPath = currentDir ? `${currentDir}/${cleanHref}` : cleanHref;
889
+ const base = basePath.endsWith("/") ? basePath : `${basePath}/`;
890
+ const finalHref = `${base}${resolvedPath}${hashPart ? `#${hashPart}` : ""}`;
891
+ return `href="${finalHref}"`;
892
+ }
893
+ );
894
+ }
895
+
896
+ export { FrontmatterDisplay, MarkdownViewer, MermaidDiagram, clearLineAnchorHighlights, parseFrontmatter, parseLineAnchor, rehypeSourceLines_default as rehypeSourceLines, renderMarkdown, renderMermaidBlocks, resolveLinks, sanitizeSchema, scrollToLineAnchor, useLineAnchor };
825
897
  //# sourceMappingURL=react.js.map
826
898
  //# sourceMappingURL=react.js.map