vantage-md 0.1.0
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.
- package/README.md +123 -0
- package/dist/index.cjs +271 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +111 -0
- package/dist/index.d.ts +111 -0
- package/dist/index.js +249 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +853 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +165 -0
- package/dist/react.d.ts +165 -0
- package/dist/react.js +826 -0
- package/dist/react.js.map +1 -0
- package/dist/styles.css +22 -0
- package/package.json +103 -0
|
@@ -0,0 +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":["parseTOML","jsxs","jsx","memo","HIGHLIGHT_CLASS","useEffect","useRef","useMemo","useCallback","remarkGfm","remarkMath","rehypeRaw","rehypeSanitize","rehypeSlug","rehypeHighlight","rehypeKatex"],"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,Q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AAY,UAAU,GAAA,CAAI,YAAA,EAAc,EAAE,kBAAA,EAAoB,MAAM,CAAA;AACpE,EAAA,KAAA,MAAW,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,IAAI,eAAe,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.js","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"]}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* src/styles/line-anchor.css */
|
|
2
|
+
.line-anchor-highlight {
|
|
3
|
+
background: rgb(59 130 246 / 0.08);
|
|
4
|
+
border-left: 3px solid rgb(59 130 246 / 0.5);
|
|
5
|
+
padding-left: 12px;
|
|
6
|
+
border-radius: 4px;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
transition: background 0.2s;
|
|
9
|
+
scroll-margin-top: 32px;
|
|
10
|
+
}
|
|
11
|
+
.line-anchor-highlight:hover {
|
|
12
|
+
background: rgb(59 130 246 / 0.12);
|
|
13
|
+
}
|
|
14
|
+
.dark .line-anchor-highlight {
|
|
15
|
+
background: rgb(59 130 246 / 0.1);
|
|
16
|
+
border-left-color: rgb(96 165 250 / 0.5);
|
|
17
|
+
}
|
|
18
|
+
.dark .line-anchor-highlight:hover {
|
|
19
|
+
background: rgb(59 130 246 / 0.16);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* src/styles/index.css */
|
package/package.json
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vantage-md",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Markdown rendering pipeline with GitHub-style line anchors, mermaid diagrams, KaTeX math, and syntax highlighting",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"./react": {
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./dist/react.d.ts",
|
|
23
|
+
"default": "./dist/react.js"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./dist/react.d.cts",
|
|
27
|
+
"default": "./dist/react.cjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"./styles": "./dist/styles.css"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsup",
|
|
37
|
+
"dev": "tsup --watch",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"prepublishOnly": "npm run build"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"markdown",
|
|
43
|
+
"viewer",
|
|
44
|
+
"line-anchors",
|
|
45
|
+
"rehype",
|
|
46
|
+
"remark",
|
|
47
|
+
"mermaid",
|
|
48
|
+
"katex",
|
|
49
|
+
"syntax-highlighting",
|
|
50
|
+
"gfm"
|
|
51
|
+
],
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "https://github.com/mschulkind-oss/vantage",
|
|
56
|
+
"directory": "packages/vantage-md"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"react": ">=18.0.0",
|
|
60
|
+
"react-dom": ">=18.0.0",
|
|
61
|
+
"react-markdown": ">=9.0.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"react": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"react-dom": {
|
|
68
|
+
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"react-markdown": {
|
|
71
|
+
"optional": true
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"katex": "^0.16.33",
|
|
76
|
+
"rehype-highlight": "^7.0.2",
|
|
77
|
+
"rehype-katex": "^7.0.1",
|
|
78
|
+
"rehype-raw": "^7.0.0",
|
|
79
|
+
"rehype-sanitize": "^6.0.0",
|
|
80
|
+
"rehype-slug": "^6.0.0",
|
|
81
|
+
"rehype-stringify": "^10.0.0",
|
|
82
|
+
"remark-gfm": "^4.0.1",
|
|
83
|
+
"remark-math": "^6.0.0",
|
|
84
|
+
"remark-parse": "^11.0.0",
|
|
85
|
+
"remark-rehype": "^11.0.0",
|
|
86
|
+
"smol-toml": "^1.6.1",
|
|
87
|
+
"unified": "^11.0.0",
|
|
88
|
+
"yaml": "^2.8.2"
|
|
89
|
+
},
|
|
90
|
+
"optionalDependencies": {
|
|
91
|
+
"mermaid": "^11.12.2"
|
|
92
|
+
},
|
|
93
|
+
"devDependencies": {
|
|
94
|
+
"@types/hast": "^3.0.0",
|
|
95
|
+
"@types/react": "^19.2.5",
|
|
96
|
+
"@types/react-dom": "^19.2.3",
|
|
97
|
+
"react": "^19.2.0",
|
|
98
|
+
"react-dom": "^19.2.0",
|
|
99
|
+
"react-markdown": "^10.1.0",
|
|
100
|
+
"tsup": "^8.0.0",
|
|
101
|
+
"typescript": "~5.9.3"
|
|
102
|
+
}
|
|
103
|
+
}
|