import classNames from 'classnames'; import { ExclamationIcon } from '@heroicons/react/outline'; import type { InlineMath, Math } from 'myst-spec'; import { InlineError } from './inlineError'; import { HashLink } from './heading'; import type { NodeRenderer } from './types'; // function Math({ value, html }: { value: string; html: string }) { // const [loaded, setLoaded] = useState(false); // const ref = useRef(null); // useEffect(() => { // import('katex').then(() => { // setLoaded(true); // }); // }, []); // useEffect(() => { // if (!loaded) return; // import('katex').then(({ default: katex }) => { // if (!ref.current) return; // katex.render(value, ref.current, { displayMode: true }); // }); // }, [loaded, ref]); // return ( // <> // {(typeof document === 'undefined' || !loaded) && ( //
// )} // {loaded &&
} // // ); // } type MathLike = (InlineMath | Math) & { error?: boolean; message?: string; html?: string; }; const mathRenderer: NodeRenderer = (node) => { if (node.type === 'math') { if (node.error || !node.html) { return (
          
            
            {node.message}
            {'\n\n'}
          
          {node.value}
        
); } const id = node.html_id || node.identifier || node.key; return (
{node.enumerator && (
({node.enumerator})
)}
); } if (node.error || !node.html) { return ; } return ; // return ; }; const MATH_RENDERERS = { math: mathRenderer, inlineMath: mathRenderer, }; export default MATH_RENDERERS;