chore: improve meili error handling

This commit is contained in:
Daniel Avila 2023-03-22 17:15:32 -04:00
parent 68979015c1
commit 655e7ce6d6
9 changed files with 182 additions and 64 deletions

View file

@ -4,31 +4,28 @@ import rehypeKatex from 'rehype-katex';
import rehypeHighlight from 'rehype-highlight';
import remarkMath from 'remark-math';
import remarkGfm from 'remark-gfm';
// import supersub from 'remark-supersub'
import remarkSubSuper from 'remark-sub-super';
import rehypeRaw from 'rehype-raw'
import CodeBlock from './CodeBlock';
import { langSubset } from '~/utils/languages';
const Content = React.memo(({ content }) => {
const Content = React.memo(({ content, isCreatedByUser = false }) => {
const rehypePlugins = [
[rehypeKatex, { output: 'mathml' }],
[
rehypeHighlight,
{
detect: true,
ignoreMissing: true,
subset: langSubset
}
],
[rehypeRaw],
]
return (
<>
<ReactMarkdown
remarkPlugins={[remarkGfm, [remarkMath, { singleDollarTextMath: false }], remarkSubSuper]}
rehypePlugins={[
[rehypeKatex, { output: 'mathml' }],
[
rehypeHighlight,
{
detect: true,
ignoreMissing: true,
subset: langSubset
}
]
]}
renderers={{
sub: 'sub',
sup: 'sup',
}}
remarkPlugins={[remarkGfm, [remarkMath, { singleDollarTextMath: false }]]}
rehypePlugins={isCreatedByUser ? rehypePlugins.slice(-1) : rehypePlugins}
linkTarget="_new"
components={{
code,
@ -63,30 +60,30 @@ const p = React.memo((props) => {
return <span className="whitespace-pre-wrap mb-2">{props?.children}</span>;
});
const blinker = ({ node }) => {
if (node.type === 'text' && node.value === '█') {
return <span className="result-streaming">{node.value}</span>;
}
// const blinker = ({ node }) => {
// if (node.type === 'text' && node.value === '') {
// return <span className="result-streaming">{node.value}</span>;
// }
return null;
};
// return null;
// };
const em = React.memo(({ node, ...props }) => {
if (
props.children[0] &&
typeof props.children[0] === 'string' &&
props.children[0].startsWith('^')
) {
return <sup>{props.children[0].substring(1)}</sup>;
}
if (
props.children[0] &&
typeof props.children[0] === 'string' &&
props.children[0].startsWith('~')
) {
return <sub>{props.children[0].substring(1)}</sub>;
}
return <i {...props} />;
});
// const em = React.memo(({ node, ...props }) => {
// if (
// props.children[0] &&
// typeof props.children[0] === 'string' &&
// props.children[0].startsWith('^')
// ) {
// return <sup>{props.children[0].substring(1)}</sup>;
// }
// if (
// props.children[0] &&
// typeof props.children[0] === 'string' &&
// props.children[0].startsWith('~')
// ) {
// return <sub>{props.children[0].substring(1)}</sub>;
// }
// return <i {...props} />;
// });
export default Content;