diff --git a/src/app/feed/route.tsx b/src/app/feed/route.tsx index befda11c95..78789262da 100644 --- a/src/app/feed/route.tsx +++ b/src/app/feed/route.tsx @@ -164,7 +164,7 @@ const ALERT_BLOCKQUOTE_R = const KateXRule: MarkdownToJSX.Rule = { match: simpleInlineRegex( - /^\$\s{0,}((?:\[.*?\]|<.*?>(?:.*?<.*?>)?|`.*?`|.)*?)\s{0,}\$/, + /^(?!\\)\$\s{0,}((?:\[(?:[^$]|(?=\\)\$)*?\]|<(?:[^$]|(?=\\)\$)*?>(?:(?:[^$]|(?=\\)\$)*?<(?:[^$]|(?=\\)\$)*?>)?|`(?:[^$]|(?=\\)\$)*?`|(?:[^$]|(?=\\)\$))*?)\s{0,}(?!\\)\$/, ), order: Priority.LOW, parse: parseCaptureInline, diff --git a/src/components/ui/markdown/parsers/katex.tsx b/src/components/ui/markdown/parsers/katex.tsx index 66bb2ef45b..449704d71b 100644 --- a/src/components/ui/markdown/parsers/katex.tsx +++ b/src/components/ui/markdown/parsers/katex.tsx @@ -10,7 +10,7 @@ const useInsertionEffect = React.useInsertionEffect || React.useEffect // $ c = \pm\sqrt{a^2 + b^2} $ export const KateXRule: MarkdownToJSX.Rule = { match: simpleInlineRegex( - /^\$\s{0,}((?:\[.*?\]|<.*?>(?:.*?<.*?>)?|`.*?`|.)*?)\s{0,}\$/, + /^(?!\\)\$\s{0,}((?:\[(?:[^$]|(?=\\)\$)*?\]|<(?:[^$]|(?=\\)\$)*?>(?:(?:[^$]|(?=\\)\$)*?<(?:[^$]|(?=\\)\$)*?>)?|`(?:[^$]|(?=\\)\$)*?`|(?:[^$]|(?=\\)\$))*?)\s{0,}(?!\\)\$/, ), order: Priority.MED, parse(capture) {