Skip to content

Commit 810deb4

Browse files
committed
fix: katex regexp
Signed-off-by: Innei <i@innei.in>
1 parent a6f5533 commit 810deb4

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/app/feed/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const ALERT_BLOCKQUOTE_R =
164164

165165
const KateXRule: MarkdownToJSX.Rule = {
166166
match: simpleInlineRegex(
167-
/^\$\s{0,}((?:\[.*?\]|<.*?>(?:.*?<.*?>)?|`.*?`|.)*?)\s{0,}\$/,
167+
/^(?!\\)\$\s{0,}((?:\[(?:[^$]|(?=\\)\$)*?\]|<(?:[^$]|(?=\\)\$)*?>(?:(?:[^$]|(?=\\)\$)*?<(?:[^$]|(?=\\)\$)*?>)?|`(?:[^$]|(?=\\)\$)*?`|(?:[^$]|(?=\\)\$))*?)\s{0,}(?!\\)\$/,
168168
),
169169
order: Priority.LOW,
170170
parse: parseCaptureInline,

src/components/ui/markdown/parsers/katex.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const useInsertionEffect = React.useInsertionEffect || React.useEffect
1010
// $ c = \pm\sqrt{a^2 + b^2} $
1111
export const KateXRule: MarkdownToJSX.Rule = {
1212
match: simpleInlineRegex(
13-
/^\$\s{0,}((?:\[.*?\]|<.*?>(?:.*?<.*?>)?|`.*?`|.)*?)\s{0,}\$/,
13+
/^(?!\\)\$\s{0,}((?:\[(?:[^$]|(?=\\)\$)*?\]|<(?:[^$]|(?=\\)\$)*?>(?:(?:[^$]|(?=\\)\$)*?<(?:[^$]|(?=\\)\$)*?>)?|`(?:[^$]|(?=\\)\$)*?`|(?:[^$]|(?=\\)\$))*?)\s{0,}(?!\\)\$/,
1414
),
1515
order: Priority.MED,
1616
parse(capture) {

0 commit comments

Comments
 (0)