import React, { useContext } from 'react' import emoji from 'react-easy-emoji' import ReactMarkdown, { ReactMarkdownProps } from 'react-markdown' import { HashLink as Link } from 'react-router-hash-link' import { EngineContext } from './contexts' import { RuleLinkWithContext } from './RuleLink' import PublicodesBlock from './PublicodesBlock' export function LinkRenderer({ href, children, ...otherProps }: Omit, 'ref'>) { const engine = useContext(EngineContext) if (!engine) { throw new Error('an engine should be provided in context') } const rules = engine.getParsedRules() if (href && rules[href]) { return ( {children} ) } if (href && !href.startsWith('http')) { return ( {children} ) } return ( {children} ) } const CodeBlock = ({ value, language }: { value: string; language: string }) => language === 'yaml' ? ( ) : (
			{value}
		
) const TextRenderer = ({ children }: { children: string }) => ( <>{emoji(children)} ) type MarkdownProps = ReactMarkdownProps & { source: string | undefined className?: string } export const Markdown = ({ source, className = '', renderers = {}, ...otherProps }: MarkdownProps) => ( )