@@ -10,6 +10,7 @@ import SyntaxHighlighter from 'react-syntax-highlighter'
10
10
import { atelierHeathLight } from 'react-syntax-highlighter/dist/esm/styles/hljs'
11
11
import { Component , memo , useMemo , useRef , useState } from 'react'
12
12
import type { CodeComponent } from 'react-markdown/lib/ast-to-react'
13
+ import SVGRenderer from './svg-gallery'
13
14
import cn from '@/utils/classnames'
14
15
import CopyBtn from '@/app/components/base/copy-btn'
15
16
import SVGBtn from '@/app/components/base/svg'
@@ -118,13 +119,13 @@ const CodeBlock: CodeComponent = memo(({ inline, className, children, ...props }
118
119
</ div >
119
120
)
120
121
}
121
- // else if (language === 'svg' && isSVG) {
122
- // return (
123
- // <ErrorBoundary>
124
- // <SVGRenderer content={content} />
125
- // </ErrorBoundary>
126
- // )
127
- // }
122
+ else if ( language === 'svg' && isSVG ) {
123
+ return (
124
+ < ErrorBoundary >
125
+ < SVGRenderer content = { content } />
126
+ </ ErrorBoundary >
127
+ )
128
+ }
128
129
else {
129
130
return (
130
131
< SyntaxHighlighter
@@ -224,16 +225,8 @@ const Link = ({ node, ...props }: any) => {
224
225
}
225
226
}
226
227
227
- function escapeSVGTags ( htmlString : string ) : string {
228
- return htmlString . replace ( / ( < s v g [ \s \S ] * ?> ) ( [ \s \S ] * ?) ( < \/ s v g > ) / gi, ( match : string , openTag : string , innerContent : string , closeTag : string ) : string => {
229
- return openTag . replace ( / < / g, '<' ) . replace ( / > / g, '>' )
230
- + innerContent . replace ( / < / g, '<' ) . replace ( / > / g, '>' )
231
- + closeTag . replace ( / < / g, '<' ) . replace ( / > / g, '>' )
232
- } )
233
- }
234
-
235
228
export function Markdown ( props : { content : string ; className ?: string } ) {
236
- const latexContent = preprocessLaTeX ( escapeSVGTags ( props . content ) )
229
+ const latexContent = preprocessLaTeX ( props . content )
237
230
return (
238
231
< div className = { cn ( props . className , 'markdown-body' ) } >
239
232
< ReactMarkdown
0 commit comments