fraudTech commited on
Commit
2b736fa
·
1 Parent(s): 74aa195

fix latex rendering

Browse files
Files changed (1) hide show
  1. web/src/App.tsx +4 -6
web/src/App.tsx CHANGED
@@ -9,7 +9,6 @@ import 'katex/dist/katex.min.css';
9
  import katex from 'katex';
10
  import Login from './Login';
11
  import './App.css';
12
- import { preprocessMathContent } from './math-preprocessing';
13
 
14
 
15
  const LOGIC_SAYINGS = [
@@ -511,8 +510,7 @@ const mdOnlyComponents = {
511
  * Only the trailing partial-text segment re-renders on each stream chunk.
512
  */
513
  const SegmentedMarkdown = React.memo(function SegmentedMarkdown({ content }: { content: string }) {
514
- const processed = useMemo(() => preprocessMathContent(content), [content]);
515
- const segments = useMemo(() => segmentMath(processed), [processed]);
516
  return (
517
  <>
518
  {segments.map((seg, i) => {
@@ -692,7 +690,7 @@ const MessageItem = React.memo(function MessageItem({
692
  img({ src, alt, ...props }: any) { return <PlotImage src={src} alt={alt} {...props} />; },
693
  }}
694
  >
695
- {preprocessMathContent(message.content)}
696
  </ReactMarkdown>
697
  )}
698
  </div>
@@ -809,7 +807,7 @@ const MessageItem = React.memo(function MessageItem({
809
  img({ src, alt, ...props }: any) { return <PlotImage src={src} alt={alt} {...props} />; },
810
  }}
811
  >
812
- {preprocessMathContent(tool.output)}
813
  </ReactMarkdown>
814
  </div>
815
  </div>
@@ -1787,7 +1785,7 @@ function App() {
1787
  <button key={example.label} className="example-btn" onClick={() => setInput(example.prompt)}>
1788
  <ReactMarkdown
1789
  remarkPlugins={[remarkMath]}
1790
- rehypePlugins={[rehypeKatex]}
1791
  components={{
1792
  p: ({ children }) => <span>{children}</span>,
1793
  }}
 
9
  import katex from 'katex';
10
  import Login from './Login';
11
  import './App.css';
 
12
 
13
 
14
  const LOGIC_SAYINGS = [
 
510
  * Only the trailing partial-text segment re-renders on each stream chunk.
511
  */
512
  const SegmentedMarkdown = React.memo(function SegmentedMarkdown({ content }: { content: string }) {
513
+ const segments = useMemo(() => segmentMath(content), [content]);
 
514
  return (
515
  <>
516
  {segments.map((seg, i) => {
 
690
  img({ src, alt, ...props }: any) { return <PlotImage src={src} alt={alt} {...props} />; },
691
  }}
692
  >
693
+ {message.content}
694
  </ReactMarkdown>
695
  )}
696
  </div>
 
807
  img({ src, alt, ...props }: any) { return <PlotImage src={src} alt={alt} {...props} />; },
808
  }}
809
  >
810
+ {tool.output}
811
  </ReactMarkdown>
812
  </div>
813
  </div>
 
1785
  <button key={example.label} className="example-btn" onClick={() => setInput(example.prompt)}>
1786
  <ReactMarkdown
1787
  remarkPlugins={[remarkMath]}
1788
+ rehypePlugins={[[rehypeKatex, { throwOnError: false, strict: false }]]}
1789
  components={{
1790
  p: ({ children }) => <span>{children}</span>,
1791
  }}