Skip to content

Commit

Permalink
Formulas: fix rendering for OpenAI-style inline '\(' and block '\[' l…
Browse files Browse the repository at this point in the history
…atex. Fixes #508
  • Loading branch information
enricoros committed Apr 22, 2024
1 parent cbe156a commit 372b19a
Show file tree
Hide file tree
Showing 7 changed files with 289 additions and 61 deletions.
253 changes: 253 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
"react-player": "^2.16.0",
"react-resizable-panels": "^2.0.18",
"react-timeago": "^7.2.0",
"rehype-katex": "^7.0.0",
"remark-gfm": "^4.0.0",
"remark-math": "^6.0.0",
"sharp": "^0.33.3",
"superjson": "^2.2.1",
"tesseract.js": "^5.0.5",
Expand Down
13 changes: 5 additions & 8 deletions src/modules/blocks/BlocksRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { InlineError } from '~/common/components/InlineError';
import { RenderCode, RenderCodeMemo } from './code/RenderCode';
import { RenderHtml } from './RenderHtml';
import { RenderImage } from './RenderImage';
import { RenderLatex } from './RenderLatex';
import { RenderMarkdown, RenderMarkdownMemo } from './markdown/RenderMarkdown';
import { RenderChatText } from './RenderChatText';
import { RenderTextDiff } from './RenderTextDiff';
Expand Down Expand Up @@ -210,13 +209,11 @@ export const BlocksRenderer = React.forwardRef<HTMLDivElement, BlocksRendererPro
? <RenderCodeMemoOrNot key={'code-' + index} codeBlock={block} fitScreen={props.fitScreen} initialShowHTML={props.showUnsafeHtml} noCopyButton={props.specialDiagramMode} optimizeLightweight={!optimizeWithMemo} sx={scaledCodeSx} />
: block.type === 'image'
? <RenderImage key={'image-' + index} imageBlock={block} onRunAgain={props.isBottom ? props.onImageRegenerate : undefined} sx={scaledImageSx} />
: block.type === 'latex'
? <RenderLatex key={'latex-' + index} latexBlock={block} sx={scaledTypographySx} />
: block.type === 'diff'
? <RenderTextDiff key={'latex-' + index} diffBlock={block} sx={scaledTypographySx} />
: (props.renderTextAsMarkdown && !fromSystem && !(fromUser && block.content.startsWith('/')))
? <RenderMarkdownMemoOrNot key={'text-md-' + index} textBlock={block} sx={scaledTypographySx} />
: <RenderChatText key={'text-' + index} textBlock={block} sx={scaledTypographySx} />;
: block.type === 'diff'
? <RenderTextDiff key={'text-diff-' + index} diffBlock={block} sx={scaledTypographySx} />
: (props.renderTextAsMarkdown && !fromSystem && !(fromUser && block.content.startsWith('/')))
? <RenderMarkdownMemoOrNot key={'text-md-' + index} textBlock={block} sx={scaledTypographySx} />
: <RenderChatText key={'text-' + index} textBlock={block} sx={scaledTypographySx} />;
})

)}
Expand Down
Loading

0 comments on commit 372b19a

Please sign in to comment.