|  | @@ -10,6 +10,7 @@ import SyntaxHighlighter from 'react-syntax-highlighter'
 | 
	
		
			
				|  |  |  import { atelierHeathLight } from 'react-syntax-highlighter/dist/esm/styles/hljs'
 | 
	
		
			
				|  |  |  import { Component, memo, useMemo, useRef, useState } from 'react'
 | 
	
		
			
				|  |  |  import type { CodeComponent } from 'react-markdown/lib/ast-to-react'
 | 
	
		
			
				|  |  | +import { flow } from 'lodash/fp'
 | 
	
		
			
				|  |  |  import cn from '@/utils/classnames'
 | 
	
		
			
				|  |  |  import CopyBtn from '@/app/components/base/copy-btn'
 | 
	
		
			
				|  |  |  import SVGBtn from '@/app/components/base/svg'
 | 
	
	
		
			
				|  | @@ -58,9 +59,24 @@ const getCorrectCapitalizationLanguageName = (language: string) => {
 | 
	
		
			
				|  |  |  const preprocessLaTeX = (content: string) => {
 | 
	
		
			
				|  |  |    if (typeof content !== 'string')
 | 
	
		
			
				|  |  |      return content
 | 
	
		
			
				|  |  | -  return content.replace(/\\\[(.*?)\\\]/g, (_, equation) => `$$${equation}$$`)
 | 
	
		
			
				|  |  | -    .replace(/\\\((.*?)\\\)/g, (_, equation) => `$$${equation}$$`)
 | 
	
		
			
				|  |  | -    .replace(/(^|[^\\])\$(.+?)\$/g, (_, prefix, equation) => `${prefix}$${equation}$`)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  return flow([
 | 
	
		
			
				|  |  | +    (str: string) => str.replace(/\\\[(.*?)\\\]/g, (_, equation) => `$$${equation}$$`),
 | 
	
		
			
				|  |  | +    (str: string) => str.replace(/\\\((.*?)\\\)/g, (_, equation) => `$$${equation}$$`),
 | 
	
		
			
				|  |  | +    (str: string) => str.replace(/(^|[^\\])\$(.+?)\$/g, (_, prefix, equation) => `${prefix}$${equation}$`),
 | 
	
		
			
				|  |  | +  ])(content)
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const preprocessThinkTag = (content: string) => {
 | 
	
		
			
				|  |  | +  if (!content.trim().startsWith('<think>\n'))
 | 
	
		
			
				|  |  | +    return content
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  return flow([
 | 
	
		
			
				|  |  | +    (str: string) => str.replace('<think>\n', '<details open><summary class="text-gray-500 font-bold">Thinking</summary><div class="text-gray-500 p-3 ml-2 bg-gray-50 border-l border-gray-300">\n'),
 | 
	
		
			
				|  |  | +    (str: string) => str.includes('\n</think>')
 | 
	
		
			
				|  |  | +      ? str.replace('\n</think>', '\n</div></details>')
 | 
	
		
			
				|  |  | +      : `${str}\n</div></details>`,
 | 
	
		
			
				|  |  | +  ])(content)
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  export function PreCode(props: { children: any }) {
 | 
	
	
		
			
				|  | @@ -225,7 +241,10 @@ const Link = ({ node, ...props }: any) => {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  export function Markdown(props: { content: string; className?: string }) {
 | 
	
		
			
				|  |  | -  const latexContent = preprocessLaTeX(props.content)
 | 
	
		
			
				|  |  | +  const latexContent = flow([
 | 
	
		
			
				|  |  | +    preprocessThinkTag,
 | 
	
		
			
				|  |  | +    preprocessLaTeX,
 | 
	
		
			
				|  |  | +  ])(props.content)
 | 
	
		
			
				|  |  |    return (
 | 
	
		
			
				|  |  |      <div className={cn(props.className, 'markdown-body')}>
 | 
	
		
			
				|  |  |        <ReactMarkdown
 |