Skip to content

Commit

Permalink
fix: katex regexp
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Apr 23, 2024
1 parent a6f5533 commit 810deb4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/feed/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/markdown/parsers/katex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 810deb4

Please sign in to comment.