Merge pull request #184 from ChatGPTNextWeb/main

123
This commit is contained in:
sijinhui 2024-10-07 20:39:59 +08:00 committed by GitHub
commit ed6c69bdc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -208,23 +208,6 @@ function CustomCode(props: { children: any; className?: string }) {
);
}
function escapeDollarNumber(text: string) {
let escapedText = "";
for (let i = 0; i < text.length; i += 1) {
let char = text[i];
const nextChar = text[i + 1] || " ";
if (char === "$" && nextChar >= "0" && nextChar <= "9") {
char = "\\$";
}
escapedText += char;
}
return escapedText;
}
function escapeBrackets(text: string) {
const pattern =
/(```[\s\S]*?```|`.*?`)|\\\[([\s\S]*?[^\\])\\\]|\\\((.*?)\\\)/g;
@ -262,7 +245,7 @@ function tryWrapHtmlCode(text: string) {
function _MarkDownContent(props: { content: string }) {
const escapedContent = useMemo(() => {
return tryWrapHtmlCode(escapeBrackets(escapeDollarNumber(props.content)));
return tryWrapHtmlCode(escapeBrackets(props.content));
}, [props.content]);
return (