diff --git a/app/src/components/markdown.tsx b/app/src/components/markdown.tsx
index 74ed7b03..b38b833e 100644
--- a/app/src/components/markdown.tsx
+++ b/app/src/components/markdown.tsx
@@ -53,6 +53,7 @@ const ImagePreview = styled.div`
export interface MarkdownProps {
content: string;
className?: string;
+ katex? : boolean;
}
export function Markdown(props: MarkdownProps) {
@@ -68,11 +69,19 @@ export function Markdown(props: MarkdownProps) {
return classes;
}, [props.className])
- const elem = useMemo(() => (
-
+ const elem = useMemo(() => {
+ const remarkPlugins: any[] = [remarkGfm];
+ const rehypePlugins: any[] = [];
+
+ if (props.katex) {
+ remarkPlugins.push(remarkMath);
+ rehypePlugins.push(rehypeKatex);
+ }
+
+ return
@@ -129,8 +138,8 @@ export function Markdown(props: MarkdownProps) {
)
}
}}>{props.content}
-
- ), [props.content, classes, intl]);
+
;
+ }, [props.content, props.katex, classes, intl]);
return elem;
}
diff --git a/app/src/components/message.tsx b/app/src/components/message.tsx
index 46507130..9567aace 100644
--- a/app/src/components/message.tsx
+++ b/app/src/components/message.tsx
@@ -1,6 +1,7 @@
import styled from '@emotion/styled';
import { Button, CopyButton, Loader, Textarea } from '@mantine/core';
+import { useOption } from '../core/options/use-option';
import { Message } from "../core/chat/types";
import { share } from '../core/utils';
import { TTSButton } from './tts-button';
@@ -210,6 +211,8 @@ export default function MessageComponent(props: { message: Message, last: boolea
const [content, setContent] = useState('');
const intl = useIntl();
+ const [katex] = useOption('markdown', 'katex');
+
const tab = useAppSelector(selectSettingsTab);
const getRoleName = useCallback((role: string, share = false) => {
@@ -288,7 +291,9 @@ export default function MessageComponent(props: { message: Message, last: boolea
)}
- {!editing && }
+ {!editing && }
{editing && (